0% found this document useful (0 votes)
7 views

Lecture8 Counter

Uploaded by

hocbai1211
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture8 Counter

Uploaded by

hocbai1211
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Lecture 8: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

- The pulses at CU are counted - The pulses at CD are counted


- When the counter reaches the PV value, Q is set - When the counter goes from the start PV value to
to 1 and the counting stops 0, Q is set to 1 and the counting stops
- An input to R clears Q to 0 - An input to LD clears Q to 0

6
Different Counter
Representations
 Count Down Counter:  Count Up Counter:

Note: RST is reset


7
Basic Counter
Program

- Each time there is a transition from 0 to 1 at input In 1, the counter is reset


- When there is an input to In 2 and a transition from 0 to 1, the counter starts counting
- If at any time during the counting there is an input to In 1, the counter will be reset, start all over again
8
Coil Formatted Up
Counter (i)
 A typical coil formatted up counter instruction:
 Increments its accumulated value by 1 each time the counter rung
makes a false-to-true transition
 When the accumulated count equals the preset count the counter
output is energized or set to 1
 The counter reset instruction must be used in conjunction with the
counter instruction
 Up counters are always reset to zero
 Down-counters may be reset to zero or to some preset value
 Some manufacturers include the reset function as a part of the
general counter instruction whereas

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

Allan Bradley’s Counter Up

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)

Parameters Data Type Description


CU, CD Bool Count up or count down, by one count
R (CTU,CTUD) Bool Reset count value to zero
LOAD (CTD,CTUD) Bool Load control for preset value
PV SINT,INT,DINT,USINT,UNIT,UDIN Preset count value
T
Q,QU Bool True if CV>=PV
QD Bool True if CV<=0
CV SINT,INT,DINT,USINT,UNIT,UDIN Current count value 12
Count Up Counters
(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
 If the current count value (CV) is equal to the preset value (PV), output Q is set
 When reset input (R) is TRUE, the accumulated value resets to 0
 Notes:
- Counter preset input can be defined as a tag name or a constant value, i.e. the tags are displayed
between double quotes.
- All counter-required variables are displayed using the standard systems label, start with the percent
(%) character
- Counter preset input can be designed as a tag name or a constant value

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

You might also like