How to change the phase of the PWM output

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change the phase of the PWM output

565 Views
thelam
Contributor I

Hello all,

 

I'm designing a single phase inverter using Freescale MCU, everything is working OK. Now I want to do one step further by connecting 2 separate inverters in parallel to share the load. With this configuration, I'd like to monitor the power deliver to the load by each inverter and then control them to share the load evenly. In order to do this,  outputs of the inverters must have the same phase, frequency, and magnitude. I think I don't have problem with the frequency or magnitude but phase where I got stuck. I think this has been done by someone before already. Thus, I have one question here:

How do I change the phase of my PWM signal? Is there any way to play with PWM phase. I know we can change the frequency but I could not find anything about the phase.

Any inputs, suggestions would be greatly appreciated. Thanks in advance all.

 

Best Regards,

 

T.L

Labels (1)
0 Kudos
1 Reply

343 Views
kef
Specialist I

It is easy and reliable to do this in 8bit mode for two adjacent PWM channels like PWM 2 and PWM3, or PWM 5 and PWM 6. We have two facts:

 

1) A write to PWMPERx is buffered, so current PWM cycle continues until the end of old PWMPERx.

2) The write to PWMCNTx register resets PWM counter (resets PWM phase to 0).

 

So to make phase shift of X PWM counter ticks you can

  

1) Reduce PWMPERx of one channel by X. So that PWMPER1 - PWMPER2 = X

2) Write in one cycle any value to PWMCNTx registers of both channels. For example for channels 2 and 3 you can do in C

 

PWMCNT23 = 0

 

3) Restore PWMPERx registers to be the same for both channels.

 

Steps 2 and 3 should take shorter than one PWM period, you may need to keep interrupts disabled while doing steps 2 and 3.

 

To make changes of duty cycle synchronous you should write to PWMDTYx registers of both channels also in one cycle. Like PMWDTY23 = duty*256 + duty.

 

0 Kudos