Pulse-width modulated voltage source
Simscape / Electrical / Integrated Circuits
The Controlled PWM Voltage block represents a pulse-width modulated (PWM) voltage source. The block has two modeling variants, accessible by right-clicking the block in your block diagram and then selecting the appropriate option from the context menu, under Simscape > Block choices:
Electrical input ports — The block calculates the duty cycle based on the reference voltage across its ref+ and ref- ports. This modeling variant is the default.
PS input — Specify the duty cycle value directly by using an input physical signal port.
For the Electrical input ports variant of the block, the demanded duty cycle is
where:
Vref is the reference voltage across the ref+ and ref- ports.
Vmin is the minimum reference voltage.
Vmax is the maximum reference voltage.
The value of the Output voltage amplitude parameter determines amplitude of the output voltage.
At time zero, the pulse is initialized as high, unless the Pulse delay time parameter is greater than zero, or the demanded duty cycle is zero.
You can use parameters Pulse delay time and Pulse width offset to add a small turn-on delay and a small turn-off advance. This can be useful when fine-tuning switching times so as to minimize switching losses.
In PWM mode, the block has two options for the type of switching event when moving between output high and output low states:
Asynchronous – Best for variable-step solvers
— Asynchronous events are better suited to variable step solvers, because
they require fewer simulation steps for the same level of accuracy. In
asynchronous mode the PWM switching events generate zero crossings, and
therefore switching times are always determined accurately, regardless of the
simulation maximum step size.
Discrete—time – Best for fixed-step solvers
— Discrete-time events are better suited to fixed-step operation, because
then the switching events are always synchronized with the simulation step.
Using an asynchronous implementation with fixed-step solvers may sometimes
result in events being up to one simulation step late. For more information, see
Simulating with Fixed Time Step — Local and Global Fixed-Step Solvers.
If you use a fixed-step or local solver and the discrete-time switching event type, the following restrictions apply to the Sample time parameter value:
The sample time must be a multiple of the simulation step size.
The sample time must be small compared to the PWM period, to ensure sufficient resolution.
The model is based on the following assumptions:
The REF output of this block is floating, it is not tied to the Electrical Reference. One consequence of this is that if you connect the PWM and REF electrical ports directly to the PWM and REF electrical ports of an H-bridge or a gate driver, you must attach an Electrical Reference block to the REF connection line.
Do not connect the Controlled PWM block directly to a semiconductor gate, because this omits the gate driver output impedance that determines switching dynamics. Use a Gate Driver or a Half-Bridge Driver block to set the gate-source or the gate-emitter voltage.
Do not use the Controlled PWM block to drive a motor block directly. A PWM motor driver goes open circuit in between pulses. Use the H-Bridge block to drive a motor block.
When driving a motor via the H-Bridge block, set the
Simulation mode parameter to
Averaged
to speed up simulations. You must
also set the Simulation mode parameter of the
H-Bridge block to Averaged
mode. This applies the average of the demanded PWM voltage to the motor. The
Averaged
mode assumes that the impedance of
the motor inductive term is small at the PWM frequency.
To verify this assumption, run the simulation using the
PWM
mode and compare the results to those
obtained from using the Averaged
mode.
If you are linearizing your model, set the Simulation
mode parameter to Averaged
and
ensure that you have specified the operating point of the block correctly.
You can only linearize the block for inputs corresponding to a duty cycle
greater than zero and less than 100 percent.
When you use this block in PWM
mode with the
Use local solver option selected in the Solver
Configuration block, set the Switching event type
parameter to Discrete—time – Best for fixed-step
solvers
. Using the Asynchronous – Best for
variable-step solvers
option in this situation may produce
inaccuracies, because simulation with the local solver implies fixed step,
and the PWM events will not always coincide precisely with the simulation
steps. This results in PWM events sometimes occurring one simulation step
late.