Engee documentation

Controlled PWM Voltage

Pulse width modulated voltage source.

controlled pwm voltage

Description

The Controlled PWM Voltage block represents a pulse width modulated (PWM) voltage source. You can simulate the electrical ports or input signal by setting the Modelling option to one of two values:

  • `Electrical input ports' - the block calculates the duty cycle based on the reference voltage at the ref+ and ref- ports. This parameter is used by default.

  • Signal input - setting the duty cycle value directly using the input control signal.

When the Modelling option is set to Electrical input ports, the squared value is:

where:

  • - input voltage at the ref+ and ref- ports.

  • - minimum reference voltage.

  • - maximum reference voltage.

The Output voltage amplitude parameter value determines the output voltage amplitude.

The pulse is initialised high at the start time unless the Pulse delay time parameter is greater than zero or the set pulse width is zero.

With the Pulse delay time and Pulse width offset parameters, a small on delay and a small off delay can be added. This can be useful when fine tuning the switching time to minimise switching losses.

In PWM mode, the block operates in asynchronous mode - PWM switching instants generate events, so the switching time is always determined accurately, regardless of the maximum simulation step size.

Assumptions and limitations

The model is based on the following assumptions:

  • The REF output of this block is floating, it is not tied to electrical ground. The consequence of this is that when connecting the PWM and REF electrical ports directly to the PWM and REF electrical ports of the H-Bridge block or gate driver, the Electrical Reference block must be connected to the REF connection line.

  • Do not connect the PWM control unit directly to the gate semiconductor as there is no gate driver output resistance to determine the switching dynamics. Use a gate driver block or half-bridge driver block to set the gate-source or gate-emitter voltage.

  • Do not use a controlled PWM block to directly control the motor block. In between PWM pulses, the motor driver enters the open-circuit state. Use the unit to control the motor unit H-Bridge.

  • When controlling the motor via the H-Bridge block, set the Simulation mode parameter to Averaged to speed up the simulation. The Simulation mode parameter of the H-Bridge block must also be set to Averaged. In this case, the average value of the required PWM voltage is applied to the motor. The `Averaged' mode assumes that the impedance of the motor inductive element is low at the PWM frequency. To verify this assumption, run the simulation in PWM mode and compare the results with those obtained in `Averaged' mode.

If you linearise the model, set the Simulation mode parameter to Averaged and ensure that you have correctly specified the block operating point. Block linearisation is only possible for inputs corresponding to a duty cycle greater than zero and less than 100%.

Ports

Input

u - control signal
scalar

Input signal that sets the squared value.

Dependencies

To use this port, set the Modelling option to Signal input.

Non-directional

ref+ - positive terminal
electricity

Electrical port associated with the positive terminal of the reference voltage.

Dependencies

To use this port, set the Modelling option to Electrical input ports.

ref- is the negative terminal
`electrical

Electrical port associated with the negative terminal of the reference voltage.

Dependencies

To use this port, set the Modelling option to Electrical input ports.

PWM - pulse width modulated signal (PWM signal)
`electrical

An electrical voltage port associated with a PWM modulated output signal.

REF is a floating ground port
electricity

The electrical port associated with the floating ground.

Parameters

Modelling option - squawk based on electrical input ports or control signal
Electrical input ports (by default) | Signal input

Option for specifying the type of block ports.

  • Electrical input ports - the block calculates the squared value based on the reference voltage on the ref+ and ref- ports. This parameter is used by default.

  • Signal input - set the squared value directly using the input signal port.

*PWM frequency` - PWM frequency
1000 Hz (By default).

Frequency of the output PWM signal.

Dependencies

This parameter is used when Simulation mode is set to PWM.

Pulse delay time - power-on delay
0 (By default)

The pulse sequence is not started until the simulation time is equal to the value of this parameter.

You can set a small value of Pulse delay time to fine tune the switching time and ensure that a switched off device is completely switched off before a switched on device is switched on. Larger delay time values can also be used, for example if you want the pulse sequence to start after only a few cycles. The specified value must be greater than or equal to zero.

Dependencies

This parameter is used if the Simulation mode parameter is set to PWM.

Pulse width offset - lengthens or shortens the pulse
0 (By default).

The required pulse width, determined by the product of pulse width and pulse frequency, can be offset by the value set for Pulse width offset. A positive value lengthens the pulse by a fixed amount. A negative value shortens the pulse. This parameter, together with the Pulse delay time parameter, can be used to fine tune the switching time to minimise switching losses in some circuits.

Dependencies

This parameter is used when Simulation mode is set to `PWM'.

Minimum pulse width - minimum pulse length
0 (By default).

Minimum pulse width based on the internal clock or set by software to protect the controlled device. The set value must be greater than or equal to zero.

Dependencies

This parameter is used when Simulation mode is set to `PWM'.

Simulation mode - simulation mode
PWM (By default) | Averaged.

Select one of the following options for the output voltage type:

  • PWM - The output voltage is a pulse width modulated signal. This is the By default option.

  • Averaged - The output voltage is the average value of the PWM signal.

Switching event type - Switching event type
Asynchronous - Best for variable-step solvers (by default) | Discrete-time - Best for fixed-step solvers
  • Asynchronous - Best for variable-step solvers - This option is more efficient for desktop simulations using variable-step solvers, as it requires fewer simulation steps to achieve the same level of accuracy.

  • Discrete-time - Best for fixed-step solvers - Used with fixed-step solvers, including the local solver.

Dependencies

This parameter is used if the Simulation mode parameter is set to PWM.

Sample time - interval between calculation steps
1e-6 (By default).

Time between updates of the block output state. The interval between calculation steps must be a multiple of the simulation step size. For the PWM control to have sufficient resolution, the interval between calculation steps must be less than one hundredth of the PWM period. (The PWM period is one unit greater than the PWM frequency).

Dependencies

This parameter is used when Switching event type is set to Discrete-time - Best for fixed-step solvers.

Input voltage for 0% duty cycle - Vmin
0 (By default)

The value of input voltage, V, at which the PWM signal has 0% duty cycle.

Dependencies

This parameter is used when Modelling option is set to Electrical input ports.

Input voltage for 100% duty cycle - Vmax
5 V (By default).

The value of input voltage at which the PWM signal duty cycle is 100%.

Dependencies

This parameter is used when Modelling option is set to Electrical input ports.

Input value for 0% duty cycle - minimum signal value
0 (By default).

Input signal value at which the PWM signal has 0% duty cycle.

Dependencies

This parameter is used when Modelling option is set to Signal input.

Input value for 100% duty cycle - maximum signal value
1 (By default).

Input signal value at which the PWM signal duty cycle is 100%.

Dependencies

This parameter is used when the Modelling option is set to Signal input.

Output voltage amplitude - signal amplitude for high output signal level
5 V (By default).

PWM output signal amplitude.