Using the pulse generators of the S7-1200
7.2 Pulse-width modulation (PWM)
Easy Book
86
Manual, 05/2009, A5E02486774-01
●
Set the reference value to a NEW_RV value
●
Set the Period value (for frequency measurement mode) to a NEW_PERIOD value
If the following boolean flag values are set to 1 when the CTRL_HSC instruction is executed,
the corresponding NEW_xxx value is loaded to the counter. Multiple requests (more than
one flag is set at the same time) are processed in a single execution of the CTRL_HSC
instruction.
●
DIR = 1 is a request to load a NEW_DIR value, 0 = no change
●
CV = 1 is a request to load a NEW_CV value, 0 = no change
●
RV = 1 is a request to load a NEW_RV value, 0 = no change
●
PERIOD = 1 is a request to load a NEW_PERIOD value, 0 = no change
The CTRL_HSC instruction is usually placed in a hardware interrupt OB that is executed
when the counter hardware interrupt event is triggered. For example, if a CV=RV event
triggers the counter interrupt, then a hardware interrupt OB code block can execute a
CTRL_HSC instruction to change the reference value by loading a NEW_RV value.
The current count value is not available in the CTRL_HSC parameters. The Process Image
address that stores the current count value is assigned during the high-speed counter
hardware configuration. You may use program logic to directly read the count value and the
value returned to your program will be a correct count for the instant in which the counter
was read, but the counter will continue to count high-speed events. The actual count value
could change before your program completes a process using an old count value.
7.2
Pulse-width modulation (PWM)
Two pulse generators are available for controlling high-speed pulse output functions: Pulse
Width Modulation (PWM) and Pulse train output (PTO). Since the PWM output can be varied
from 0 to full scale, it provides a digital output that in many ways is the same as an analog
output. For example, the PWM output can be used to control the speed of a motor from stop
to full speed, or it can be used to control position of a valve from closed to fully opened. PTO
is used by the motion control instructions.
ཱ
ཱ
① Cycle time
② Pulse width time
Duty cycle can be expressed as a percentage of the
cycle time (0 to 100%), as thousandths (0 to 1000),
as ten thousandths (0 to 10000), or as S7 analog
format. The pulse width can vary from 0 (no pulse,
always off) to full scale (no pulse, always on).
You can assign each pulse generator to either PWM
or PTO, but not both at the same time.
The CTRL_PWM instruction provides a fixed cycle time output with a variable duty cycle.
The PWM output runs continuously after being started at the specified frequency (cycle
time). The pulse width is varied as required to effect the control.