Lecture8 Counter
Lecture8 Counter
1
Contents
Introduction
IEC Symbols for Counters
Different Counter Representations
Basic Counter Program
Coil Formatted
Block Formatted
Siemen’s Counters: Count Up (CU), Count Down (CD), Count Up and Down (CTUD)
2
Introduction (i)
Counters are provided as built-in elements in PLCs
Allow the number of occurrences of input signals to be counted
Be very useful in manufacturing and industrial control systems
Be similar to Timers except not operating on an internal clock but are dependent on external or program
sources for counting
PLC counter instructions are used to count parts in manufacturing plants or to count events in
industrial applications
A programmed counter can serve the same function as a mechanical counter
Mechanical counter:
- The actuating lever is moved over, the counter adds one number; the actuating lever then returns automatically to its
original position
- Resetting to zero is done with a pushbutton located on the side of the unit
Electronic counters:
3
Introduction (ii)
Electronic Counter
Mechanical Counter
Counter Application
Common counter application is for keeping track of the
number of items moving past a given point
4
Introduction (iii)
There are two basic types of counters: down-counter and up-counters
Some PLCs offer the facility for both down-and up-counting
Down-counters:
⁃ Count down from the preset value to zero, i.e. events are subtracted from the set value
⁃ Contacts change state when the counter reaches the zero value
Up-counters:
- Count from zero up to the preset value, i.e. events are added until the number reaches the preset value
- Contacts change state when the counter reaches the set value
Two representing methods of a counter in PLC’s programming: coil format and the block
format
5
IEC Symbols for
Counters
6
Different Counter
Representations
Count Down Counter: Count Up Counter:
9
Coil Formatted Up
Counter (ii)
Coil-formatted counter instruction with a separate
instruction for resetting the counter
When programmed, the counter reset coil (CTR) is given
the same reference address as the counter (CTU) that it is
to reset
The reset instruction is activated whenever the CTR rung
condition is true
10
Block Formatted
Counter (i)
The instruction block indicates the type of counter (up or
down), along with the counter’s preset value and
accumulated or current value
The counter has two input conditions associated with it,
namely, the count and reset
Notes:
All PLC counters operate or count on the leading edge of the
input signal
The counter will either increment or decrement whenever Allan Bradley’s Counter Up
the count input transfers an OFF state to an ON state
The counter will not operate on the trailing edge or on-to-
off transition of the input condition 11
Siemens’ Counter
Parameters
Siemens offer 3 counters (block formatted Counter):
- Count Up (CTU)
- Count Down (CTD)
- Count Up and Count Down Counter (CTUD)
13
Count up Counters
(CTU)
Counter block: Timing diagram, when PV=4:
14
Count up Counters
(CTU) Example
15
Count Down
Counters (CTD)
The count down counter’s main function is to decrement the current value (CV) each time the
input to the counter transitions from 0 to 1
If the current value is equal to or less than 0, the counter output Q is set
The value at the CV is set to the value of the PV parameter when the signal state at the LD
input changes to 1
As long as the LOAD (LD) input has signal state 1, the signal state at the CTD input has no
effect on the instruction
16
Count Down
Counters (CTD)
17
Count Up and Down
Counters (CTUD)
Main function of the count up and down instruction is to count up or down the
value at the current count value, tag name CV
If there is transitions from 0 to 1 at count up CU, the current count value of CV is
incremented
If there is transitions from 0 to 1 at count down CD, the current count value of
CV is decremented
The count value is set to zero when the signal state at the R input changes from 0
to 1
As long as R input has signal state 1, a change in the signal state of the CU, CD, and
LD (or LOAD) inputs has no effect on the CTUD instruction
The counter does not have overflow
When the maximum value for the assigned memory format is reached, it does not
18
Count Up and Down
Counters (CTUD)
When the signal at the LOAD changes from 0 to 1, CV is set to the
value of the PV
As long as LD is ON, CU and CD inputs have no effect
The output QD is used to indicate that the current count value is less than
or equal to 0 indicate and indicate a counter overflow situation
It is set to 1 when CV is less or equal to 0
LD does not affect the status of the QD output
Output QD is set once the current count value is equal to or larger than
the pre-assigned preset value (PV)
QU is reset once the CV falls below the PV
LD and R have no effect on QU
19
Count Up and Down
Counters (CTUD)
20
Summary (i)
Counters are provided as built-in elements in PLCs and a llow the number of occurrences of
input signals to be counted
PLC counter instructions are used to count parts in manufacturing plants or to count events in
industrial applications
A programmed counter can serve the same function as a mechanical counter
Down-counters:
⁃ Count down from the preset value top zero, i.e. events are subtracted from the set value
⁃ Contacts change state when the counter reaches the zero value
Up-counters:
- Count from zero up to the preset value, i.e. events are added until the number reaches the preset value
- Contacts change state when the counter reaches the set value
Two representing methods of a counter in PLC’s programming: coil format and the block format
21
Summary (ii)
CTU:
- The count up counter’s main function is to increment the current value (CV) each time the input to the
counter transitions from 0 to 1
CTD:
- The count down counter’s main function is to decrement the current value (CV) each time the input to
the counter transitions from 0 to 1
CTUD:
- Main function of the count up and down instruction is to count up or down the value at the current
count value, tag name CV
22