5.1.107. PWM output — variable frequency, synchronised (pdx_PWMSynchronisedOutput)

Pulse two output channel pins at a variable frequency and variable duty cycle. The second output channel is synchronised to the first.

5.1.107.1. Supported targets

M110-000, M250-000, M460-000 and M670-000

5.1.107.2. Required license

None (Main library). (See Section 2.3, “Licensed Features”.)

5.1.107.3. Description

The synchronised PWM output block causes two channel output pins to oscillate with independent frequency and duty cycle. The duty cycle is the High time divided by the Cycle time for a given channel.

The slave channel is generated relative to the master channel pulse (in this instance, both the master and slave channels are generated with the same frequency).

The slave pulse can be delayed relative to the master pulse by setting the parameter Slave delay to a non-zero value.

In all cases, only one pulse per cycle is generated by both the master and slave channels. For instance, if the frequency of the slave channel was twice that of the master channel, only one pulse would be generated by the slave channel.

The Master channel output (and thus the slave) can be offset from other PWM channels of the same frequency. The Master offset parameter is used to delay the start of the PWM cycle, so that the PWM pulse will not occur at the same time as other PWM signals of the same frequency.

This block calculates the master output duty cycle as:

output master duty cycle = Minimum duty cycle + (Maximum duty cycle - Minimum duty cycle) * master_duty_cycle

and the slave output duty cycle as:

output slave duty cycle = Minimum duty cycle + (Maximum duty cycle - Minimum duty cycle) * slave_duty_cycle

For a given channel, if the output duty cycle is 0, the output channel state is set low and does not oscillate. If the output duty cycle is 1, the output channel state is set high and does not oscillate.

If the inport master_fault input is non-zero, then the output master duty cycle is set to the mask parameter Master default duty cycle. Similarly for the output slave duty cycle.

5.1.107.4. Inports

  • master_duty_cycle

    Ratio of the high time to the signal cycle time for the master channel.

    Range: [0, 1] duty-cycle

  • master_frequency

    Frequency of the master channel signal.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • master_fault

    Set to 1 to force the block to use the default master frequency and master duty cycle for the master channel, 0 otherwise.

    Range: 0 or 1

  • slave_duty_cycle

    Ratio of the high time to the signal cycle time for the slave channel.

    Range: [0, 1] duty-cycle

  • slave_frequency

    Frequency of the slave channel signal.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • slave_fault

    Set to 1 to force the block to use the default slave frequency and slave duty cycle for the slave channel, 0 otherwise.

    Range: 0 or 1

5.1.107.5. Outports

  • sim_master_duty_cycle

    Only used in simulation. this outport is set to the calculated duty cycle for the master channel.

    Range: [0, 1] duty-cycle

  • sim_master_frequency

    Only used in simulation. this outport is set to the calculated frequency for the master channel.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • sim_slave_duty_cycle

    Only used in simulation. this outport is set to the calculated duty cycle for the slave channel.

    Range: [0, 1] duty-cycle

  • sim_slave_frequency

    Only used in simulation. this outport is set to the calculated frequency for the slave channel.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • sim_slave_delay

    Only used in simulation. this outport is set to the calculated frequency for the slave channel.

    Range: [0, 1000000] microseconds

5.1.107.6. Mask parameters

  • Master channel

    The master channel for this block. The slave channel is automatically assigned.

  • Master inversion

    If selected, the final master duty cycle is set to 1 minus the output master duty cycle, otherwise the final master duty cycle is the same as the output master duty cycle.

  • Master default duty cycle

    This is the final duty cycle of the channel when inport master_fault is set. The duty cycle is mapped directly to the output channel and is not inverted by parameter Master inversion.

    Range: 0 or 1 duty-cycle

  • Master initial duty cycle

    The duty cycle of the channel signal before the block has first been executed. This duty cycle is inverted if the mask parameter Master inversion is set to 1.

    Range: [0, 1] duty-cycle

  • Master initial frequency

    The frequency of the channel signal before the block first iterates.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • Master offset

    The offset of the master (and hence the slave) channel output.

    Range: Target dependent

    TargetRange
    M110Not supported
    M220Not supported
    M221Not supported
    M250[0, 2000] ms
    M460[0, 2000] ms
    M461Not supported
    M670Not supported

    Value type:Real
    Calibratable:No
  • Slave inversion

    If selected, the final slave duty cycle is set to 1 minus the output slave duty cycle, otherwise the final slave duty cycle is the same as the output slave duty cycle.

  • Slave default duty cycle

    This is the final duty cycle of the channel when inport slave_fault is set. The duty cycle is mapped directly to the output channel and is not inverted by parameter Slave inversion.

    Range: 0 or 1 duty-cycle

  • Slave initial duty cycle

    The duty cycle of the channel signal before the block has first been executed. This duty cycle is inverted if the mask parameter Slave inversion is set to 1.

    Range: [0, 1] duty-cycle

  • Slave initial frequency

    The frequency of the channel signal before the block first iterates.

    Range: [1, 10000] Hz (for M250, M460 targets)

  • Slave delay

    The time delay between synchronisation of the master and slave channel. The slave pulse is started Slave delay microseconds after the master pulse starts.

    Range: [0, 1000000] microseconds

  • Minimum duty cycle

    Must be in the range 0 to (Maximum duty cycle - 0.1).

    Range: [0, 0.9] duty-cycle

  • Maximum duty cycle

    Must be in the range (Minimum duty cycle + 0.1) to 1.0.

    Range: [0.1, 1] duty-cycle

  • Provide simulation output?

    Tick to enable outports sim_master_duty_cycle, sim_master_frequency, sim_slave_duty_cycle, sim_slave_frequency and sim_slave_delay.

    Value type:Boolean
    Calibratable:No

5.1.107.7. Notes

  • If the pulse for the slave channel extends through the synchronisation point, then the master and slave channel signals become undefined. Most likely is that the master channel continues to generate a PWM signal and the slave channel goes low, but this is not guaranteed under all conditions.

    To avoid an inconsistent update to the output, the low-lying driver (based on code from the silicon manufacturer) buffers new parameters before applying them. This results in a delay of two or three PWM cycles between the model updating the frequency or duty cycle and the effect being seen in the output waveform.