General description

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

Triangle

Inverted triangle

Sawtooth

Inverted sawtooth

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).

The frequency of the carrier is configured by connecting the CB-PWM block to a CLK - Clock generator. The frequency can even be tuned during the control execution as explain in PN121: 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.

Simulink 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 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.

  • Carrier type selects the type of carrier (TRIANGLE, SAWTOOTH, INVTRIANGLE, or INVSAWTOOTH)

  • Duty-cycle 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 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)

  • 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 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 simulation.

The parameters output mode, addressed PWM, dead-time and PWM activate 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.

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

  • 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)

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

C++ functions

The parameters output, outMode , and deadTime are common to all PWM blocks and are further documented on the PWM page.

Functions specific to the carrier-based PWM

Select a CLOCK
void CbPwm_ConfigureClock(tPwmOutput output, tClock clock, unsigned int device=0);

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_0, CLOCK_1, CLOCK_2 or CLOCK_3)

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

Select the carrier
void CbPwm_ConfigureCarrier(tPwmOutput output, tPwmCarrier carrier, unsigned int device=0);

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 (TRIANGLE, SAWTOOTH, INVTRIANGLE, or INVSAWTOOTH)

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

Select an update rate
void CbPwm_ConfigureUpdateRate(tPwmOutput output, tPwmRate rate, unsigned int device=0);

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

Set the phase
void CbPwm_SetPhase(tPwmOutput output, float phase, unsigned int device=0);

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

Set the duty-cycle
void CbPwm_SetDutyCycle(tPwmOutput output, float dutyCycle, unsigned int device=0);

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 blocks

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

Select the output mode
void CbPwm_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 CbPwm_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

  • deadTime: the dead-time duration in seconds

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

Activate the output
void CbPwm_Activate(tPwmOutput output, unsigned int device=0);
Deactivate the output
void CbPwm_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