PWM: Command a Pulse Width Modulation Signal

Overview

The Pulse Width Modulation function block commands a pulse width modulated signal output at the specified frequency and duty cycle.

Graphical Representation

G-SE-0015152.1.gif-high.gif

 

 

IL and ST Representation

To see the general representation in IL or ST language, refer to the chapter Function and Function Block Representation.

Input Variables

This table describes the input variables:

Inputs

Type

Comment

EN_Enable

BOOL

TRUE = authorizes the PWM enable via the IN_EN input (if configured).

F_Enable

BOOL

TRUE = forces the Enable function.

EN_SYNC

BOOL

TRUE = authorizes the restart via the IN_Sync input of the internal timer relative to the time base (if configured).

F_SYNC

BOOL

On a rising edge, forces a restart of the internal timer relative to the time base.

Frequency

DWORD

Frequency of the PWM output signal in tenths of Hz (range: 200 (20 Hz)...10,000 (1 kHz)).

Duty

WORD

Duty cycle of the PWM output signal in tenths of a % (range: 10 (1%)...990 (99%)).

Output Variables

This table describes the output variables:

Outputs

Type

Comment

InFrequency

BOOL

TRUE = the Pulse Width Modulation signal is currently being output at the specified frequency and duty cycle.

Busy

BOOL

Busy is used to indicate that a command change is in progress: the frequency is changed.

Set to TRUE when the Enable command is set and the Frequency Generator signal is not output at the specified Frequency.

Reset to FALSE when InFrequency or Error is set, or when the Enable command is reset.

When a command change execution is immediate, Busy remains FALSE.

Error

BOOL

TRUE = indicates that an error was detected.

ErrID

PTOPWM_ERR_TYPE

When Error is set: type of the detected error.