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.

Calculate speed from eQEP ticks

Other Parts Discussed in Thread: CONTROLSUITE

I have attached a speed sensor with 32 ticks/rev and 2 channels to channel A and B of the eQEP module. I am using the DRV8301-69M kit.

How can I calculate the speed from the eQEP tick count?

  • Hi Thomas,

    In the eQEP section of the TRM, you should find a section which describes the eQEP Edge Capture Unit.  I believe it will help you accomplish what you are trying to do (measure the amount of time between encoder ticks to estimate speed).

    The other potential approach is to look at the eQEP value during the current ISR and the last ISR to estimate speed. 

    The former is better for situations where the pulses happen slowly relative to the ISR frequency (which I believe describes your application better).


    Thank you,
    Brett

  • Brett,

    Thanks for the answer. The Edge Capture Unit is indeed what I am looking for. Are there perhaps any examples of code available where this feature is implemented?

  • Hi Thomas,

    Did you go through this example code: C:\ti\controlSUITE\device_support\f2806x\v141\F2806x_examples_ccsv5\eqep_pos_speed

    Regards,
    Gautam
  • I am doing that now, thanks. My sensor doesn't have an index channel though, so I need to reset the position at max count (32) instead of when an index occurs. Do I need to change 'EQep1Regs.QEPCTL.bit.PCRM=00' to 'PCRM=01' and 'EQep1Regs.QPOSMAX=0xffffffff' to '0x20' for this?
  • Hi Thomas,

    That seems correct.  Depending on your exact encoder and what your definition of ticks is, QPOSMAX to 0x40 or 0x80 may actually be correct.

    Take a look/experiment and I think you'll get it to do what you want.


    Thank you,
    Brett

  • Thanks.

    I'm having trouble adding this example code to my own project though. I have been using block diagram development instead of writing code, so I am not that familiar with programming. For testing purposes I want to add this speed function to project 12b (sensored control), and try to read the current speed in the variable window. What procedure should I follow?