2003-01-20 05:42 PM
2 pwm-signals with a different starting time
2002-12-17 12:50 AM
Hello,
I want to generate two pwm-signals with a different starting time (90° phase shift). I use the ST72521 and I have two timers on board. The signal and the pulselength is 50 : 50. To get the maximal frequency I need a starting ramp. I have the knowledge about generating a pwm signal with a timer, but the problem is the different starting time of the 2nd signal. Is it possible to generate this signals and the ramp with a Timerinterrupt ? Is there anybody who can help me, maybe with a example in c? Thanks a lot. thilo2002-12-19 12:47 PM
I think there is no easy way to synchronise the timers as you are saying.
(they are not designed for that) But you can imagine doing the function using one timer in compare mode and using the two output compare to generate the two signals. the disadvantage of this method is that you do not have anymore a precise control of your PWM period. What are your PWM frequency and precision requirement?2002-12-20 02:03 AM
Thanks a lot for your answer. My PWM frequency has to be between 500Hz to 1000Hz. The most important requirement in my application is the phase shift between the signals.
2002-12-23 08:43 AM
At such a low frequency you should have no problem to implement it by software.
try something like that: T is the PWM period and Ton+Toff=T. in Timer initialisation: OC1: Whatever OC2: OC1 + T/2 CR2 register: OC1E=OCE2=1, OPM=PWM=0, CC1:CC0=01 CR1 register: OCIE=1, FOLV1=FOLV2=1, OLVL1 & OLVL2 = original PWM state CR1 register: OCIE=1, FOLV1=FOLV2=0, OLVL1 & OLVL2 = complementary of previous line in OC1 Timer Interrupt routine: In case OLVL1 = 0: OC1 <- OC1+Ton Else: OC1 <- OC1+Toff Toggle OLVL1 in OC2 Timer Interrupt routine: In case OLVL2 = 0: OC2 <- OC1+Ton Else: OC2 <- OC1+Toff Toggle OLVL22003-01-20 05:42 PM
Thanks a lot. This was a great idea!