General description

The DO-PWM block sets PWM output(s) directly to '0' or '1'.

This technique is typically used for Model-Predictive Control (MPC) or Direct Torque Control (DTC). An example of an application is shown in AN004: Direct Torque Control of a Permanent Magnet Synchronous Motor.

Like the other PWM blocks, it supports dead-time generation and can be activated or deactivated. More information is available on the PWM page.

Simulink block

Signal specification

  • The input in sets the PWM output to ‘1' (in>0) or to '0’ (in<=0)

  • The input A allows the activation (>0) or deactivation (<=0) of the PWM output(s).

  • The output(s) is/are the generated PWM signal(s), according to the selected output mode. The output(s) is/are only used in simulation.

The parameters output mode, addressed PWM, dead-time and show ”activate” input are common to all PWM blocks and are further documented on the PWM page.

Parameters

  • Device ID selects which B-Box/B-Board to address when used in a multi-device configuration.

  • Output mode selects between a single PWM signal or complementary signals with a deadtime.

  • Addressed PWM selects the PWM outputs to address.

  • Show ”activate” input makes the A signal input visible. If not checked, the block is active by default.

  • Dead-time duration: configures the dead-time duration if the Output mode is set at Dual (PWM_H + PWM_L).

PLECS block

Signal specification

  • The input in sets the PWM output to ‘1' (in>0) or to '0’ (in<=0)

  • The input A allows the activation (A>0) or deactivation (A<=0) of the PWM output(s).

  • The target outport(s) (only visible at the atomic subsystem level) is/are the generated PWM signal(s), according to the selected output mode. The output(s) is/are only used in simulation.

Parameters

  • Device ID selects which B-Box/B-Board to address when used in a multi-device configuration.

  • Output mode selects between a single PWM signal or complementary signals with a deadtime.

  • Output lane(s) or Output channel(s) (vectorizable) selects the PWM outputs to address.

  • PWM activation makes the A signal input visible if the option “Use block input“ is selected. If not, the CB-PWM block is activated by default.

  • Dead-time duration configures the dead-time duration if the Output mode is set at Dual (PWM_H + PWM_L).

C++ functions

Functions specific to the direct output PWM

Set ON
void DoPwm_SetOn(tPwmOutput output, unsigned int device=0);
Set OFF
void DoPwm_SetOff(tPwmOutput output, unsigned int device=0);

Sets the PWM output to ‘1' (DoPwm_SetOn) or to '0' (DoPwm_SetOff).

Parameters

  • output: the PWM channel or lane to address

  • device: the id of the addressed device (optional, used in multi-device configuration only)

Functions common to all PWM blocks

These functions are common to all PWM blocks. Further documentation is available on the PWM page.

Select the output mode
void DoPwm_ConfigureOutputMode(tPwmOutput output, tPwmOutMode outMode,
	unsigned int device=0);

Selects the PWM output mode.

If the output mode selected is COMPLEMENTARY, a dead-time must be configured using the CbPwm_ConfigureDeadTime() function.

It has to be called in UserInit().

Parameters

  • output: the PWM channel or lane to address

  • outMode: the output mode to use (COMPLEMENTARY, INDEPENDENT or PWMH_ACTIVE)

  • device: the B-Box/B-Board to address when used in a multi-device configuration

Configure the dead-time
void DoPwm_ConfigureDeadTime(tPwmOutput output, float deadTime, unsigned int device=0);

Configures the dead-time duration if the output mode is set as COMPLEMENTARY.

It has to be called in UserInit().

Parameters

  • output: the PWM channel or lane to address

  • outMode: the output mode to use (COMPLEMENTARY, INDEPENDENT or PWMH_ACTIVE)

  • device: the B-Box/B-Board to address when used in a multi-device configuration

Activate the output
void DoPwm_Activate(tPwmOutput output, unsigned int device=0);
Deactivate the output
void DoPwm_Deactivate(tPwmOutput output, unsigned int device=0);

Activates or deactivates the addressed PWM output(s). If the addressed PWM output has been set as COMPLEMENTARY or PWMH_ACTIVE this function acts on both outputs.

It can be called in UserInit() or in the control interrupt routine.

Parameters

  • output: the PWM channel or lane to address

  • device: the B-Box/B-Board to address when used in a multi-device configuration

  • No labels