7 Counter
7 Counter
7 Counter
Counter Instructions
1
Counter Instructions
Counter Instructions
• Generic coil-formatted
up-counter instruction.
2
Counter Instructions
Counter Instructions
3
Counter Instructions
Counter Instructions
4
Up Counter
The up-counter count value will increment by 1 each time the counted
event occurs.
10
5
Up Counter: SLC 500 Count-Up Counter
Allen-Bradley counter takes three data table words: the control word,
preset word, and accumulated word.
11
Done (DN) Bit — true whenever the accumulated value is equal to or greater
than the preset value, for either the count-up or the count-down counter.
12
6
Up Counter: SLC 500 Count-Up Counter
Overflow (OV) Bit—is true whenever the counter counts past its maximum value,
which is 32,767. On the next count, the counter will wrap around to –32,768 and
will continue counting from there toward 0 on successive false-to-true transitions
of the count-up counter.
Underflow (UN) Bit—The underflow bit will go true when the counter counts below
–32,768. The counter will wrap around to +32,767 and continue counting down
toward 0 on successive false-to-true rung transitions of the count-down counter.
13
14
7
Up Counter: SLC 500 Count-Up Counter
Preset value (PRE) word specifies the value that the counter must
count to before it changes the state of the done bit.
The accumulated value (ACC) word is the current count based on the
number of times the rung goes from false to true.
• The accumulated value either increments with a false-to-true
transition of the count-up counter instruction or decrements with a
false-to-true transition of the count-down counter instruction.
• The accumulated value will continue to count past the preset value
instead of stopping at the preset like a timer does.
SLC 500: preset value (-32768 to 32767)
ControlLogix: preset value (-2.147.438.648 to 2.147.438.647)
15
16
8
Example: stop a motor from running
17
18
9
Example: Alarm monitor program
19
20
10
Down Counter
21
Down Counter
22
11
Down Counter
23
24
12
Example: count up/down program
25
26
13
Cascading counters: Counting Beyond the Maximum Count
27
28
14
Cascading counters: 24-hour clock program
29
30
15
31
16