Need PWM Signal for Sinusoid input

4 次查看(过去 30 天)
Goody
Goody 2023-7-31
回答: Sabin 2025-2-5
Hi all,
I need a matlab script that converts sinusoid input to corresponding PWM signal with adjustable duty cycle. I understand there is PWM generator in Simulink but my version does not have it.
The environment is simulink and my input is sine wave block with sinusoid signal with specified sampling time and frequency. I want to connect the sine wave block to matlab function block that converts the sinusoid to pwm. I find it challenging to do as pwm is usually between 0 and 1 but the sinusoid has negative values too. Also the pwm frequency should be lower than the sampling frequency I believe.
A picture similar to what I need is attached.
Thank you.

回答(1 个)

Sabin
Sabin 2025-2-5
PWM block was released in version R2020b: https://mathworks.com/help/simulink/slref/pwm.html
There are other blocks that can be used as well in Simscape Electrical: https://mathworks.com/help/sps/pulse-width-modulation.html
It is also possible to implement a simple one by comparing the modulation waveform (sinusoid) with a triangular carier (using a Repeating Sequence for instance https://mathworks.com/help/simulink/slref/repeatingsequence.html).

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by