Siemens Simatic S7-200 System Manual page 207

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

Count Up Counter, Count Up/Down Counter
L
A
CU
D
R
PV
CU
CD
R
PV
S
CTU
T
L
CTUD
212
214
Understanding the S7-200 Counter Instructions
The Up Counter (CTU) counts up from the current value of that counter each time the
count-up input makes the transition from off to on. The counter is reset when the reset input
turns on, or when the Reset instruction is executed. The counter stops upon reaching the
maximum value (32,767).
The Up/Down Counter (CTUD) counts up each time the count-up input makes the transition
from off to on, and counts down each time the count-down input makes the transition from off
to on. The counter is reset when the reset input turns on, or when the Reset instruction is
executed. Upon reaching maximum value (32,767), the next rising edge at the count-up input
causes the current count to wrap around to the minimum value (-32,768). Likewise on
reaching the minimum value (-32,768), the next rising edge at the count-down input causes
the current count to wrap around to the maximum value (32,767).
When you reset a counter using the Reset instruction, both the counter bit and the counter
current value are reset.
The Up and Up/Down counters have a current value that maintains the current count. They
also have a preset value (PV) that is compared to the current value whenever the counter
instruction is executed. When the current value is greater than or equal to the preset value,
the counter bit (C-bit) turns on. Otherwise, the C-bit turns off.
Use the counter number to reference both the current value and the C-bit of that counter.
Note
Since there is one current value for each counter, do not assign the same number to more
than one counter. (Up Counters and Up/Down Counters access the same current value.)
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02
The Count Up instruction counts up to the maximum value on
Cxxx
the rising edges of the Count Up (CU) input. When the current
CTU
value (Cxxx) greater than or equal to the Preset Value (PV), the
counter bit (Cxxx) turns on. The counter is reset when the Reset
(R) input turns on.
In STL, the Reset input is the top of the stack value, while the
Count Up input is the value loaded in the second stack location.
Cxxx
The Count Up/Down instruction counts up on rising edges of
CTUD
the Count Up (CU) input. It counts down on the rising edges of
the Count Down (CD) input. When the current value (Cxxx) is
greater than or equal to the Preset Value (PV), the counter bit
(Cxxx) turns on. The counter is reset when the Reset (R) input
turns on.
In STL, the Reset input is the top of the stack value, the Count
Down input is the value loaded in the second stack location, and
the Count Up input is the value loaded in the third stack
Cxxx, PV
location.
Cxxx, PV
Operands:
215
216
Cxxx:
0 to 255
PV:
VW, T, C, IW, QW, MW, SMW, AC,
AIW, Constant, *VD, *AC, SW
Instruction Set
10-19

Advertisement

Table of Contents
loading

Table of Contents