0
0
Simulinkdata~10 mins

PWM generation in Simulink - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a PWM signal using a Compare To Constant block.

Simulink
pwm_signal = (input_signal [1] threshold);
Drag options to blanks, or click blank then click option'
A==
B<
C!=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality operator instead of greater than.
Using less than operator which inverts the PWM signal.
2fill in blank
medium

Complete the code to set the PWM frequency by adjusting the carrier signal period.

Simulink
carrier_period = 1 / [1];
Drag options to blanks, or click blank then click option'
Aduty_cycle
Bphase_shift
Cfrequency
Damplitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using duty cycle instead of frequency.
Using amplitude or phase shift which do not set frequency.
3fill in blank
hard

Fix the error in the PWM duty cycle calculation code.

Simulink
duty_cycle = [1] / max_signal_value;
Drag options to blanks, or click blank then click option'
Ainput_signal
Bmin_signal_value
Ccarrier_signal
Dthreshold
Attempts:
3 left
💡 Hint
Common Mistakes
Using min_signal_value which does not represent the current input.
Using threshold or carrier_signal which are unrelated to duty cycle calculation.
4fill in blank
hard

Fill both blanks to create a PWM signal dictionary with duty cycle and frequency keys.

Simulink
pwm_params = {"duty_cycle": [1], "frequency": [2]
Drag options to blanks, or click blank then click option'
Aduty_cycle
Bfrequency
Cpwm_frequency
Dduty
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'frequency' variable instead of 'pwm_frequency'.
Using 'duty' instead of 'duty_cycle'.
5fill in blank
hard

Fill all three blanks to generate a PWM signal array with given duty cycle, frequency, and time vector.

Simulink
pwm_signal = (mod([1] * [2], 1) < [3])
Drag options to blanks, or click blank then click option'
Atime_vector
Bduty_cycle
Cfrequency
Damplitude
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up duty cycle and frequency in the multiplication.
Using amplitude which is unrelated here.