How can I syncronize two PWM on STM32 using the Embedded Coder Support Package
조회 수: 26 (최근 30일)
이전 댓글 표시
I need to generate two PWM signals with variable Duty cycle controlled by reading from two ADC, and that is simple. The problem is that I need to introduce a fixed phase difference between the two signals. I tryed using triggered subsystems, but it does not seem to work. The two PWM are on two different timers, should I use two different channels of the same timer ? Should I use a third timer in a master slave configuration ?

댓글 수: 0
채택된 답변
Tridib
2025년 10월 31일 9:41
It is better to use two different channels on the same timer. This way, both signals are controlled by the same hardware and will always be in sync.
Set the timer to PWM mode and choose the frequency you want. Assign each PWM output to a different channel. To set the phase difference between the signals, just adjust the “Pulse” or “Compare Value” for each channel. You can also change the duty cycle of each channel in real time by reading values from the ADC and updating the compare registers in your Simulink model.
If you try to use two separate timers, it is much harder to keep them perfectly in sync, since their counters might not line up exactly. If you need more control, you can use a master-slave timer setup.
Hope this helps!
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!