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.

F28069 ePWM phase shift problem

Hello,


I'm currently working on a project which is using the Piccolo F28069. I need eight PWM signals. Depending on the operation point I need a lagging or leading signal in respect to the first PWM signal.

I set up all the PWMs and it is working. The only problem I have now is when I change the phase shift during operation. I use a period of 900 (100kHz). If I want a lagging signal I change the phase shift register from 0 up to 225. If I need a leading signal I change the phase shift register from 900 down to 675.

Now when I start the PWM without any phase shift and then put a phase shift for a lagging signal in the following happens:

I get a period where the PWM signals that are being phase shifted will do nothing. This is not acceptible because this causes problems during the operation.

I already know the reason why this is happening (at least I think). But I don't know how to solve it.

I'm using 4 ePWM modules (ePWM1 - ePWM4). ePWM1 is the master while all the rest are slaves. According to the manual there is a delay between master and slaves of two cycles, which I can verify with debugging. The SYNCOSEL register is set to CTR_ZERO. So when the counter from the master is zero a sync signal will be generated. Now here lies the problem. Let's say I put a phase shift of 20 into the registers of ePWM3 and ePWM4. The counter of ePWM1 will get to zero and generate the pulse. At that time the counters of all the slave PWM modules are at 898. Writing the phase shift of 20 into the counters will now mess the one period up because we missed on counter event.


So...how can I solve that problem?

Thanks

  • Hello,

    Based on the description you've provided this is the expected behavior of the module because the reason you indicated - the TBCTR = 0 event is not happening.  Can you provide a few more details so I can help you resolve this issue?

    When and how are you generating the SYNC event?

    Can you provide a rough sketch of what you would like the output to look like during the SYNC transition between leading / lagging?

    Thanks,

    Kris

  • Hello Kris,


    the SYNC event is created with the first PWM module on CTR_ZERO.

    The problem is that my circuit triggers the trip zone if one period is too long because the current will get too high. If during a transition the period is smaller there won't be any problem whatsoever.


    I actually fixed the problem by moving by changing the action registers. Before I used to set the actions on zero and on CMPA. Now I changed that to CMPB and CMPA.

    If I change the phase shift now I check if it is a leading or lagging phase shift and change the CMPA and CMPB registers accordingly. If I put a value above my maximum phase shift (in this case 225) in the registers the problem does not appear anymore.

    Sample code:

    inline void CheckPSSignChange()
    {
    	if(OLDPS <= 0 && NEWPS > 0)
    	{
    		EALLOW;
    		EPwm1Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50+227;
    		EPwm2Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50+227;
    		EPwm3Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50+227;
    		EPwm4Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50+227;
    		EPwm1Regs.CMPB = 227;
    		EPwm2Regs.CMPB = 227;
    		EPwm3Regs.CMPB = 227;
    		EPwm4Regs.CMPB = 227;
    		EDIS;
    	}
    	else if(OLDPS > 0 && NEWPS <= 0)
    	{
    		EALLOW;
    		EPwm1Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50;
    		EPwm2Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50;
    		EPwm3Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50;
    		EPwm4Regs.CMPA.half.CMPA = PWM_DUTYCYCLE_50;
    		EPwm1Regs.CMPB = 0;
    		EPwm2Regs.CMPB = 0;
    		EPwm3Regs.CMPB = 0;
    		EPwm4Regs.CMPB = 0;
    		EDIS;
    	}
    }

  • That's a general problem of multiple PWM sync with phase delay on existing C2000 controllers.
    We are facing this, too.

    The datasheet only states (spruh18e p.265): "NOTE: An EPWMxSYNCI external synchronization event can cause a discontinuity in the TBCTR count sequence. This can lead to a compare event being skipped. This skipping is considered normal operation and must be taken into account."

    Since the PWM actions only occur on "PWM-Timer == (Compare|Zero|Period)" and not on >=/<= (depending on timer direction), you may have a skipped action due to a sync pulse changing the pwm-timer.

  • Yes, I know that I'm skipping one cycle when I change the phase shift registers. I know what caused the problem but I thought someone here would know a solution to that problem.


    But with my workaround which I posted above I'm not skipping a cycle anymore and my hardware now works as intended.

    Thanks for the answers!

  • Hello,

    Could you please provide your action qualify configuration for reference?

    Regards,