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.

TMS320F28379D: How to generate Rotary encode PG signal using ePWM Peripheral?

Guru 20035 points
Part Number: TMS320F28379D

Hello,

I am fairly new to the ePWM peripheral. 

How would I generate Rotary encoder PG signals using the ePWM Peripheral? I am thinking I will only need to generate PGA and PGB and then use a counter in a CPLD to generate PGZ.

Also, for PGA and PGB would it be best best to use A and B of a single ePWM module or two different ePWM modules?

Stephen

  • Hi Steven,

    I am not familiar with rotary encoder PG signals. Could you provide an example of the PWM output you would need to achieve along with the inputs to your algorithm that would correspond with this output?

    Thank you,

    Luke

  • I haven't seen the actual pulses from a rotary encoder.  However, the following website describes them.  A is 90 degs out of phase with B and the Z pulse occurs once every revolution.

    https://en.wikipedia.org/wiki/Rotary_encoder#/media/File:Quadrature_Diagram.svg

    The period of the pulses are directly proportional to how fast the encoder is spinning.

    I would need the PWM to generate the A and B pulses and the Z pulse would be generated from one or both of those pulses.

    Should I use two separate PWM modules or A/B from one PWM module?  How would I get the 90 degs phase shift?

  • Hi Steven,

    Is the duty cycle of A and B always 50%? If so, only one PWM module should be necessary to achieve this. To achieve the phase shift and duty cycle that you need, think of your PWM period as having 4 events that you need to achieve:

    • rising edge of A
    • rising edge of B
    • falling edge of A
    • falling edge of B

    These events should all be related to action qualifier events. In the image you shared, you could achieve this using up-down-count mode and a CMPA value of TBPRD/2, and have action qualifier events on 0, CMPA while the counter is counting up, TBPRD, and CMPA while the counter is counting down. if the phase shift is something other than 90 degrees, you would need to utilize both CMPA and CMPB to maintain a 50% duty cycle on output B. If the duty cycle of A and B varies from 50%, you would need to use 2 PWM modules that are synchronized together using TBPHS to achieve your phase shift.

    I'm not sure what you're trying to achieve with the Z pulse since it's not included in the image you sent, but you could achieve this using the CLB if the Z pulse is derived from A and B.

    Thank you,

    Luke