This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: Need Simulink help to read quadrature Encoder

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: ENERGIA

Hello all,

I have installed necessary software such as  Embedded coder target for energia and Matlab 2015 for Tiva c simulink support.

I have created simple simulink model to run DC motor and it works fine, but there is problem in getting encoder data.

As per the datasheet, Tiva C has two quadrature encoder interface(QEI) available and i want to use one QEI for getting encoder data.

I did not find any simulink block for quadrature encoder interface in simulink library.

I want to read Motor's shaft position using quadrature encoder interface using simulink model.

Basically i want to get the encoder data using embedded coder target for energia library or by any other means if possible.

Please help.

Thanks in advance.

  • Hi Anil,
    Sorry, probably no much help I can provide. There is no QEI simulink block available or any new development to support it.

    Below links provide some additional information that you may already know.

    e2e.ti.com/.../602000
    e2e.ti.com/.../1799553
  • Your objective requires a, "Multi-Link Chain" - and it is clear that, "Not all of the required links" are yet available.

    While the two "augmentation vehicles" you note provide "several required links" - they do not provide "ALL" of those required.

    You write of "any other means" - do those "augmentations" allow your introduction (thus mix) of normal "C Code" w/in their boundaries? If so - then your task would, "Mix your existing functions with newly created ones - either operating within or "outside" of those "Help Vehicles."

    The profound weakness of many/most such "help/augmentation" systems is their (thus far) "Limited number of (usually) required functions" - which appears, "Just as you've noted!" Casting (somewhat) away from "Safe/Easy Harbor" into "deep water" (i.e. MCU code you create) indeed meets your requirement for, "Any other means possible." (especially when "other means" is the "ONLY" means!)
  • Hi cb1_mobile & ,

    I want to read quadrature encoder signal on TM4C processor using simlink.

    There are only following simulink blocks available for TM4C processor.

    If the simulink block is not available then can we use some other protocol like spi to read 

     quadrature encoder signal??

    please help.

    Thanks in advance.

      

  • Anil gupta said:
    If the simulink block is not available then can we use some other protocol like spi to read  quadrature encoder signal??

    Not being a "simulink" user (nor is staff) I can only supply what I trust to be a logical method to (generally) solve such problem.

    Your neat listing of "simulink functions" reveals neither, "Quadrature Encoder" or "SPI" solution blocks.    Thus your mention of  "SPI" registers as "curious."

    You must learn - "if and how" simulink proves "accepting" of:

    • the introduction of a, "standard C code block" (implementing the "encoder read function) yet placed (entirely) outside of the simulink implementation
    • or - your creation of a (unique & proper) simulink block - which accomplishes your mission (QEI encoder read) 
    • perhaps - if simulink is "not accepting" of (either of the above methods) - is it possible to, "Switch simulink between "Enabled/Disabled" - such that you can regularly run your QEI, C code (simulink disabled) - and then return to simulink (now enabled)?    And regularly repeat this process - such that your QEI code (not part of simulink) is able to (effectively) co-exist w/simulink.

    Are these not (purely) simulink issues/questions - thus more pertinent to "simulink staff/helpers?"    Believe the "bullet points" listed are valid - and the "best response" likely results from simulink - not TM4C guides/signposts...

  • Trying to add to cb's comments here:

    - Start by forgetting the existence of simulink. First you need to be able to see the readings of your motor position inside the microcontroller code.
    - Can you take the leap of getting out of Energia and using "pure C" with Tivaware? That will give you much more control over your sensors and overall programming.
    - Then, use Tivaware's Quadrature Encoder libraries. You will quickly be able to see the encoder measurements as variables in your C code.
    - Only then you are allowed to see those values in your PC's Simulink screen! To do that, make a simple solution to transfer those values to the PC. I believe you have a physical serial (uart) port between the MCU and the computer, correct? If you start by simple CSV strings of data generated by a printf(), I'm pretty sure your Simulink can read those values out of the serial port and display them on those dials and instruments...

    Bruno
  • Hi cb1_mobile & Bruno,
    I am able to read quadrature encoder using code composer studio.
    As suggested by cb1_mobile, if i use simulink enabled/disabled then i have following questions
    1.How to enable/disable simulnik?
    2.If i am programming through simulink then previous code will be overwritten by simulink code and in that
    case even enable/disable of simulink wont help.
  • Strongly disagree w/your "Award" criteria.

    Did not the earlier arriving post - which identified the necessity to determine the, "Acceptance of C code by simulink" deserve award?      And then - uniquely - presented the, "Enable/Disable" (concept potential) of simulink - "bending it" to the (grudging) acceptance of the (required) C code.   That was key - was it not?

    It is believed that the combination of QEI code - with results (attempted) to be transferred via UART - force (unwanted) delays upon your QEI's speed and position measurement!    (degrading such measurements)    The implementation appears "uncertain" as well.

    Motivation requires nurture - may deserve further consideration...