CB-PWM - Carrier-based PWM

The Carrier-based PWM block generates PWM signals based on one of the 4 following carrier shapes:

When using the single-rate update configuration, the computed duty-cycle is synchronously applied at the end of the PWM period. With the double-rate update and a TRIANGLE carrier, the duty-cycle is updated twice per period: in the middle and at the end (in other words when the carrier reaches its maximum and when it reaches its minimum).

Triangle carrier
Inverted triangle carrier
Sawtooth carrier
Inverted sawtooth carrier

The frequency of the carrier is configured by connecting the CB-PWM block to a Clock generator. The frequency can even be tuned during the control execution as explained in Variable frequency operation with the B-Box/B-Board.

The phase-shift of the carrier can also be changed during execution, independently for each PWM block.

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

Signal specification

  • The input signal D is the duty-cycle (0.0 to 1.0)
  • The input signal P is the carrier phase-shift relative to the CLK (0.0 to 1.0)
  • The input signal > is the clock input and must be connected to the CONFIG block or to an independent CLK
  • 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.

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 dead-time.
  • Addressed channel(s) or Addressed lane(s) (vectorizable) selects the PWM outputs to address.
  • Modulation parameters
    • Carrier type selects the type of carrier (TRIANGLE, SAWTOOTH, INVTRIANGLE, or INVSAWTOOTH)
    • Duty-cycle(s) (vectorizable) configures the duty cycle. It can be tuned in real-time using the D signal input or be configured only once from the block mask parameter.
    • Phase(s) (vectorizable) configures the carrier phase-shift relative to the CLK. It can be tuned in real-time using the P signal input or be configured only once from the block mask parameter.
    • Show ”activate” input makes the A signal input visible. If not checked, the CB-PWM block is active by default.
    • PWM parameters update rate selects when the duty-cycle and phase parameters are applied.
      • Single-rate: they are applied at the end of the carrier period.
      • Double-rate: they are applied twice per carrier period: when the carrier reaches its lowest point and when it reaches its highest point. (for TRIANGLE and INVTRIANGLE carriers only)
    • Simulation output type
      • PWM signals: outputs are logic gate signals 0 or 1.
      • Duty-cycle: outputs are duty-cycles between 0 and 1. This option is only used with averaged power switch models.
  • Complementary signal parameters
    • Dead-time duration configures the dead-time duration if the Output mode is set to Dual (PWM_H + PWM_L).

PLECS block

Signal specification

  • The input signal D is the duty-cycle (0.0 to 1.0)
  • The input signal P is the carrier phase-shift relative to the CLK (0.0 to 1.0)
  • The input signal > is the clock input and must be connected to the CONFIG block or to an independent CLK
  • The input A allows the activation (>0) or deactivation (<=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 the simulation.

Parameters

  • Addressing
    • 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.
  • Modulation parameters
    • Carrier type: selects the type of carrier (Triangle, Sawtooth, Inverted triangle, or Inverted sawtooth)
    • Duty-cycle(s)(vectorizable) configures the duty-cycle. It can be tuned in real-time using the D signal input or be set as a constant and configured from the block mask parameter.
    • Carrier phase-shift(s)(vectorizable) configures the carrier phase-shift relative to the CLK. It can be tuned in real-time using the P signal input or be set as a constant and configured from the block mask parameter.
    • 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.
    • PWM parameters update rate selects when the duty-cycle and phase parameters are applied.
      • Single-rate: they are applied at the end of the carrier period.
      • Double-rate: they are applied twice per carrier period: when the carrier reaches its lowest point and when it reaches its highest point. (for triangle and invtriangle carriers only)
    • Simulation output type
      • PWM signals: outputs are logic gate signals 0 or 1.
      • Duty-cycle: outputs are duty-cycles between 0 and 1. This option is only used with averaged power switch models.
  • Complementary signal parameters
    • 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 carrier-based PWM

void CbPwm_ConfigureClock(tPwmOutput output, tClock clock, unsigned int device=0);
Code language: C++ (cpp)

Connects a clock generator to the modulator.

It has to be called in UserInit().

See: CLK – Clock generator

Parameters

  • output: the PWM channel or lane to address
  • clock: the clock to use (CLOCK_0CLOCK_1CLOCK_2 or CLOCK_3)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_ConfigureCarrier(tPwmOutput output, tPwmCarrier carrier, unsigned int device=0);
Code language: C++ (cpp)

Selects the carrier shape of the modulator.

It has to be called in UserInit().

Parameters

  • output: the PWM channel or lane to address
  • carrier: the carrier to use (TRIANGLESAWTOOTHINVTRIANGLE, or INVSAWTOOTH)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_ConfigureUpdateRate(tPwmOutput output, tPwmRate rate, unsigned int device=0);
Code language: C++ (cpp)

Select when the duty-cycle and phase parameters are applied.

  • Single-rate: they are applied at the end of the carrier period.
  • Double-rate: they are applied twice per carrier period: when the carrier reaches its lowest point and when it reaches its highest point. (for TRIANGLE and INVTRIANGLE carriers only)

It has to be called in UserInit().

Parameters

  • output: the PWM channel or lane to address
  • rate: the update rate to use (SINGLE_RATE or DOUBLE_RATE)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_SetPhase(tPwmOutput output, float phase, unsigned int device=0);
Code language: C++ (cpp)

Configures the carrier phase-shift relative to the CLK.

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

Parameters

  • output: the PWM channel or lane to address
  • phase: the carrier phase-shift relative to the CLK (0.0 to 1.0)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_SetDutyCycle(tPwmOutput output, float dutyCycle, unsigned int device=0);Code language: C++ (cpp)

Configures the duty-cycle.

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

Parameters

  • output: the PWM channel or lane to address
  • dutyCycle: the duty-cycle (0.0 to 1.0)
  • device: the B-Box/B-Board to address when used in a multi-device configuration

Functions common to all PWM drivers

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

void CbPwm_ConfigureOutputMode(tPwmOutput output, tPwmOutMode outMode, unsigned int device=0);Code language: C++ (cpp)

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 (COMPLEMENTARYINDEPENDENT or PWMH_ACTIVE)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_ConfigureDeadTime(tPwmOutput output, float deadTime, unsigned int device=0);Code language: C++ (cpp)

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 (COMPLEMENTARYINDEPENDENT or PWMH_ACTIVE)
  • device: the B-Box/B-Board to address when used in a multi-device configuration
void CbPwm_Activate(tPwmOutput output, unsigned int device=0);
Code language: C++ (cpp)

Activates 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
void CbPwm_Deactivate(tPwmOutput output, unsigned int device=0);Code language: C++ (cpp)

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