Open loop motion control
12.1 Using the PWM output
12.1.2
PWMx_RUN subroutine
To simplify the use of Pulse Width Modulation (PWM) control in your application,
STEP 7-Micro/WIN SMART provides a PWM wizard (Page 596) to configure your on-board
PWM generators and control the duty cycle of a PWM output.
The PWMx_RUN subroutine is used to execute PWM under program control.
LAD / FBD
STL
CALL PWMx_RUN, Cycle, Pulse, Error
Table 12- 1
Parameters for the PWMx_RUN subroutine
Inputs/Outputs
Cycle, Pulse
Error
The Cycle input is a word value that defines the cycle time for the pulse width modulation
(PWM) output. The allowed range is from 2 to 65535 when milliseconds is the time base and
10 to 65535 when microseconds is the time base.
The Pulse input is a word value that defines the pulse width (Duty Cycle) for the PWM
output. The allowed range of values is from 0 to 65535 units of the time base (microseconds
or milliseconds) that was specified within the PWM wizard.
The Error is a byte value returned by the PWMx_RUN subroutine that indicates the result of
execution. See the following table for a description of the possible error codes.
Table 12- 2
PWMx_RUN instruction error codes
Error code
Description
0
No error, normal completion
131
Pulse generator already in use by another PWM or by a motion axis, or illegal time base change
598
Data types
Operands
Word
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *AC, *LD, Constant
Byte
IB, QB, VB, MBV, SMB, LB, AC, *VD, *AC, *LD, Constant
Description
The PWMx_RUN subroutine allows you to
control the duty cycle of the output by vary-
ing the pulse width from 0 to the pulse
width of the cycle time.
System Manual, V2.3, 07/2017, A5E03822230-AF
S7-200 SMART