Model pulse-width modulated voltage source
The Controlled PWM Voltage block represents a pulse-width modulated (PWM) voltage source that depends on the reference voltage Vref across its +ref and -ref ports. The demanded duty cycle is
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 H-Bridge PWM and REF electrical ports, you must attach an Electrical Reference block to the REF connection line.
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.
Frequency of the PWM output signal. The default value is 1000 Hz.
The pulse train does not start until the simulation time is equal to the Pulse delay time. You can specify a small value for Pulse delay time to fine-tune switching times and ensure that an off-going device is fully off before the on-going device starts to turn on. You can also use larger delay times, for example, if you need the pulse train to start only after a number of cycles. The value you provide must be greater than or equal to zero. This parameter is only visible when you select PWM for the Simulation mode parameter. The default value is 0 s.
The demanded pulse width as defined by the product of the demanded duty cycle and one over the pulse frequency can be offset by the value you provide for Pulse width offset. A positive value acts to lengthen the pulse by a fixed amount. A negative value acts to shorten the pulse. You can use this parameter, along with the Pulse delay time, to fine-tune switching times so as to minimize switching losses in some circuits. This parameter is only visible when you select PWM for the Simulation mode parameter. The default value is 0 s.
Value of the input voltage at which the PWM signal has a 0% duty cycle. The default value is 0 V.
Value of the input voltage at which the PWM signal has a 100% duty cycle. The default value is 5 V.
Amplitude of the PWM signal when the output is high. The default value is 5 V.
The type of output voltage can be PWM or Averaged. The default mode, PWM, produces a pulse-width modulated signal. In Averaged mode, the output is a constant whose value is equal to the average value of the PWM signal.
This parameter is only visible when you select PWM for the Simulation mode parameter. Select the switching event type when moving between output high and output low states:
Asynchronous – Best for variable-step solvers — This option is more efficient for desktop simulation with variable-step solvers, because it requires fewer simulation steps for the same level of accuracy. This is the default.
Discrete—time – Best for fixed-step solvers — Use with fixed-step solvers, including the local solver. For more information, see Simulating with Fixed Time Step — Local and Global Fixed-Step Solvers.
The time between updates of the block output state. The sample time must be a multiple of the simulation step size. In order for the PWM control to have sufficient resolution, set the sample time to less than one hundredth of the PWM period. (The PWM period is one over the PWM frequency.) This parameter is only visible when you select Discrete—time – Best for fixed-step solvers for the Switching event type parameter. The default value is 1e-6 s.
The block has the following ports: