Using the pulse generators of the S7-1200
7.2 Pulse-width modulation (PWM)
Easy Book
88
Manual, 05/2009, A5E02486774-01
Using the CTRL_PWM instruction
When placing a CTRL_PWM instruction into the program editor,
a DB will be assigned. A data block (DB) is used by the
CTRL_PWM instruction to store parameter information. The
data block parameters are controlled by the CTRL_PWM
instruction.
Parameter
Data type
Description
PWM
WORD
PWM identifier: Names of enabled pulse generators will become tags
in the "constant" tag table, and will be available for use as the PWM
parameter.
ENABLE
BOOL
1=start pulse generator
0 = stop pulse generator
BUSY
BOOL
Function busy
STATUS
WORD
Execution condition code
Use the tag name for the PWM parameter to specify the enabled pulse generator.
When the EN input is TRUE, the PWM_CTRL instruction starts or stops the identified PWM
based on the value at the ENABLE input. Pulse width is specified by the value in the
associated Q word output address. Because the CPU processes the request when the
CTRL_PWM instruction is executed, parameter BUSY will always report FALSE on S7-1200
CPU models.
The pulse width will be set to the initial value configured in device configuration when the
PLC first enters the RUN mode. You write values to the word-length output (Q) address that
was specified in device configuration ("Output addresses" / "Start address:") as needed to
change the pulse width. Use an instruction, such as Move, Convert, Math, or PID, to write
the specified pulse width to the appropriate word-length output (Q). You must use the valid
range for the output value (percent, thousandths, ten-thousandths, or S7 analog format).