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: Phase shift formula

Part Number: TMS320F28379D


Tool/software:

Hi Team,

I have a question regarding the correct formula to calculate the phase shift for EPWM2 relative to EPWM1, 
specifically in different ePWM counter modes (up, down, and up-down).

I came across a formula on this forum (LAUNCHXL-F28379D: Phase Delay between ePWM1 and ePWM2 in example epwm_ex3_synchronization) for calculating the time base phase shift (TBPHS) for EPWM modules:

TBPHS =(TBPRD * Desired Phase (In Degrees))/180 degrees

Based on this, I have a phase shift value of 300: 

300 = (2000*x)/180, This results in a phase shift of approximately 27 degrees for EPWM2.
To achieve a delay of 153 degrees for EPWM2 with respect to EPWM1,
I calculate: 180 degrees - 27 degrees = 153 degrees
then : TBPHS = (2000*153)/180 = 1700
My question is whether these calculations apply to all counter modes (up, down, and up-down), or if they are specific to one mode, such as the up-counter mode.

Additionally, I noticed a different formula for phase shift calculation in the technical reference manual:
TBPHS = (phase angle*TBPRD)/360

If my counter mode is set to up-down, which formula should be used to correctly calculate the phase shift?

I would appreciate any clarification on this matter to ensure accurate phase synchronization in different counter modes.

Following the C2000 ePWM Developer’s Guide. Whichever formula mentioned in the developer guide didn't work for calculating TBPHS with an up-down counter. I noticed that for an up-down counter, TBPRD has to be multiplied by 2. When I use that phase shift value, I get the correct phase shift in the waveform. I calculated it for 22 degrees with the up-down counter." without multiple by 2 is 20.35, If I use multiple by then 40.7, If I am using multiple by 2  then only EPWM phase shift is working, For the up-down counter, multiply by 2. Please refer to the link below:



  • Hi Josel,

    I believe the formula you obtained from that thread was an approximation and not exactly accurate, apologies for the inconvenience.

    You can derive the formulas by referring to this diagram:

    The following formula is ALMOST correct:

    TBPHS =(TBPRD * Desired Phase (In Degrees))/180 degrees

    You just need to replace TBPRD with the correct number of TBCLK pulses per period, based on the TBPRD register value and the count mode.

    For up-count and down count it would be: TBPRD + 1

    For up-down count it would be: TBPRD*2.

    So the phase shift formulas for the two count modes would be

    up-count / down-count: TBPHS = ((TBPRD+1) * Desired Phase in degrees) / 180 degrees

    for up-down count: TBPHS = (TBPRD * 2 * Desired Phase in degrees) / 180 degrees

    There is one more thing to be aware of for phase shifting. Depending on the TBCLK frequency, there is a 1 to 2 cycle delay between when the SYNCIN pulse takes place and when the value in TBCTR is updated. If TBCLK is equal to SYSCLK/EPWMCLK, you should add 2 to your TBPHS value formula, if TBCLK is less than that, you should add 1 to your TBPHS value formula.

    Thank you,

    Luke

    Let me know if you have additional questions.

  • Hi Luke,

    I am trying to achieve a phase shift of 10 degrees using an up-down counter in an ePWM module, with a TBPRD Value of 100. If I use the formula: TBPHS = (TBPRD * 2 * Desired Phase in degrees) / 180 degrees) which gives me a TBPHS value of approximately 11.1. However, this value does not produce the correct phase shift in the ePWM module. When I use the formula provided in the manual: Up-down Counter :TBPHS= TBPRD * Desired Phase in degrees) / 360 degrees. With these I will get 2.77 ,with these I am not getting correct phase shift value . As per above mentioned diagram I have consider the TBPRD*2 for up-down counter TBPHS= TBPRD *2* Desired Phase in degrees) / 360 degrees.with these formula I am getting correct phase shift value. Can you confirm if the formula from the manual is correct for the given parameters, or if there is another adjustment I should consider to achieve the desired phase shift?

    Regards,

    Josel

  • Hi Josel,

    My apologies, I meant to use the formula TBPHS =(TBPRD * Desired Phase (In Degrees))/360 degrees for up-down count mode. I didn't realize the original formula you had referred to was already adjusted for up-down count mode.

    As I mentioned before, you may also need to add 1 or 2 to your TBPHS value due to the delay between the SYNCIN pulse and the TBCTR value being overrided with TBPHS. So the final formula would be either

    If TBCLK == EPWMCLK: TBPHS =(TBPRD * Desired Phase (In Degrees))/360 + 2

    OR

    If TBCLK < EPWMCLK: TBPHS =(TBPRD * Desired Phase (In Degrees))/360 + 1

    Thank you,

    Luke