0
0
Simulinkdata~10 mins

PWM generation in Simulink - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - PWM generation in Simulink
Set Reference Signal
Set Carrier Signal (Triangle Wave)
Compare Reference and Carrier
Generate PWM Output
Output PWM Signal
PWM generation compares a reference signal with a carrier wave to create a pulse-width modulated output.
Execution Sample
Simulink
Reference = 0.6;
Carrier = (sawtooth(2*pi*1000*t, 0.5) + 1)/2;
PWM = Reference > Carrier;
This code compares a constant reference with a triangle wave carrier to produce a PWM signal.
Execution Table
StepTime (ms)Reference ValueCarrier ValueCondition (Reference > Carrier)PWM Output
10.00.60.0True1
20.10.60.3True1
30.20.60.7False0
40.30.61.0False0
50.40.60.7False0
60.50.60.0True1
70.60.60.3True1
80.70.60.7False0
90.80.61.0False0
100.90.60.7False0
111.00.60.0True1
💡 Simulation ends at 1.0 ms, completing one full carrier wave cycle.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7After 8After 9After 10Final
Reference0.60.60.60.60.60.60.60.60.60.60.60.6
Carrier0.00.30.71.00.70.00.30.71.00.70.00.0
PWM Output110001100011
Key Moments - 2 Insights
Why does the PWM output switch from 1 to 0 when the carrier value exceeds the reference?
Because the PWM output is 1 only when the reference is greater than the carrier (see execution_table rows 2 and 3). When carrier > reference, condition is false, so output is 0.
Why does the PWM output repeat its pattern every 1 ms?
The carrier is a triangle wave with a 1 kHz frequency, so it completes a cycle every 1 ms, causing the PWM pattern to repeat (see execution_table time column).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 4. What is the PWM output and why?
A0, because carrier equals 1.0 which is greater than reference
B1, because reference is greater than carrier
C1, because carrier is less than reference
D0, because reference is zero
💡 Hint
Check the 'Condition' and 'PWM Output' columns at step 4 in the execution_table.
At which time does the PWM output first become 0?
A0.1 ms
B0.2 ms
C0.0 ms
D0.5 ms
💡 Hint
Look at the 'PWM Output' column in execution_table and find the first 0.
If the reference value increased to 0.8, how would the PWM output change at 0.7 ms?
APWM output would be 0 because carrier is 1.0
BPWM output would be 0 because 0.8 < 0.7
CPWM output would be 1 because 0.8 > 0.7
DPWM output would be 1 because carrier is 0.3
💡 Hint
Compare new reference 0.8 with carrier at 0.7 ms from execution_table.
Concept Snapshot
PWM generation in Simulink:
- Use a reference signal and a carrier triangle wave.
- Compare reference > carrier at each time step.
- Output 1 if true, else 0.
- PWM duty cycle depends on reference level.
- Carrier frequency sets PWM frequency.
Full Transcript
PWM generation in Simulink works by comparing a reference signal with a carrier triangle wave. At each time step, if the reference is greater than the carrier, the PWM output is 1; otherwise, it is 0. This creates a pulse-width modulated signal where the width of the pulses depends on the reference value. The carrier wave frequency determines how often the PWM signal repeats. For example, with a 1 kHz carrier, the PWM pattern repeats every 1 millisecond. This method is visualized step-by-step by tracking the reference, carrier, condition, and PWM output values over time.