PLC Chapter-8 Programming Counters
PLC Chapter-8 Programming Counters
PLC Chapter-8 Programming Counters
Chapter 8
3.1
Counter Instructions
MECH 1500
Programmed counters
serve the same Actuating
lever
function as
mechanical counters.
Electronic counters
can count up, count
down, or be
combined to count
up and down.
Up-counters are
always reset to zero. Reset
MECH 1500
Input
module
Count
1[ line Type of
{eceeee
JL counter Output
line ( —
Preset value
r
hs
L Reset Accumulated
line value
MECH 1500
| The up-counter is
—— Counter—up incremented by 1 each time
| 10 Counter Hn
EL value the rung containing the
a I} counter Is energized.
On
—
Accumulated = Preset = | Output
Off
—
Parts Counter—down
The down-counter | me
decrements by 1 each | J L
|
value
Up-Counter
MECH 1500
-CTU
—| COUNT-UP COUNTER Cu—
Counter p:
Preset : : ©N
Accumulated P
rn C5:1
Rung 4 ] [ (RES)—
PB2 (Reset)
MECH 1500
Accumulated
value
MECH 1500
Preset value
Counter Table
/CU J/CD /DN /OV JUN J/UA .PRE .ACC
C5:0 0 0 0 0 0 0 0 0
C5:1 0 0 0 0 0 0 0 0
C5:2 0 0 0 0 0 0 0 0
C5:3 0 8 © Bb 8 B 50 0
C5H:4 0 0 0 0 0 0 0 0
C5:5 0 0 0 0 0 0 0 0
we |
| C5:2
Rw
Rw
J
Ch3
we
we
ws
ws
C54
J
C55
Lon J
Los J
Lo
Lo
Overflow (OV)
Underflow (UN) bitis - true
bit is - true (1)
when the counter counts
whenever
below -32.768. The counter
the counter
will wrap around to +132,767
counts past its
and continue counting down
maximum
toward 0.
value, 32,767.
On the next
count, the Conor Tane fr
counter will » : EL 6) 2 i ay EAE Ce 4]
counting to 0.
MECH 1500
€5:0 0
Oooo Oo
O0DOoO0D Oo
0
oo
J C3: 1 0
O0O0
|C5:2 0
oo
|C5:3 0
ODOC
| C5:4 0
oo
=o
|C5:5 0
Address | C5:3 Table:
| C5: Counter w|
wm
MECH 1500
—CTU
— | COUNT-UP COUNTER CU)
Counter C5:0
Preset 10
Accumulated 0 —ON)
C5:0/CU
] [ Counter enable bit
C5:0/DN
] [ Counter done bit
C5:0/0V
] | Overflow status bit
o) 1L {RES)—
MECH 1500
1
i
— CTU
Count Tp CU ————
0d Counter Ca'0
=
Preset 10 CDN D—
=
Fe Aconm 1]
i=
iJ
[Tn]
=i
ali
——
Fu
i
]
= |
[i
=
Parts
L1
—CTU
COUNT-UP COUNTER cv
Counter C51
Preset 10 —0Y
Accumulated 0
—CTU
COUNT-UP COUNTER
Counter Cs:2
Preset 32767
Accumulated 0
Packages
—CTU
COUNT-UP COUNTER
Counter C5:3
Preset 300
Accumulated 0
MECH 1500
PRO-5W
C51/DN B3:0/1
ou =i = Ej). —
CLOSE BOX
C51
B30
|
CLOSE BOX
1A cad
pi | —LF ES) 1 |
Internal One-shot
The one-shot can be i relay contact output
B3:0/0 C5:1
ogo Ls
Tp.
—> if —
One PLC scan
MECH 1500
B3:0/0 —CTU
L1 rs [—osr}— COUNT-UP COUNTER
Counter C5:0
Preset 50
Accumulated 0
MECH 1500
Process
@ run 0202 Silo Si
001
@n oom
@ FULL 0204
2 Ib
®)| stop C
woz
J —
3
mn,
oe 151413121110 9 8 7 6 5 4 3 2 1 0 «|p
| B30F 0 0 0 0 0 0 0 0 © 0 0 0 @ 0 0 0 |
{BX1/ oO 0 0 0 0 0 0 0 0 OO OO OO 0 OO 0 0
Fa | BEF O90 0 0 0 0 80 0 0 0 0 0 0 0 0
bo Bx 0 0 0 0 0 0 0 © 0 0 © O O 0 0 0
IB34f 0 0 O O O O O ©O © 0 OO @ OO 0 0
PROX SENSOR < {B25/ oO 0 0 0 0 0 0 0 ©O OO OO OO OO OO 0 0 hd
E103 SE —
MOTOR Rado: [Bina w| Table |B3 Bina -|
0:2/00 cen y EER |
MECH 1500
14 ®
15 ®
|| EE pr
| 1X = | ai f Ta— 1
poi]
I: TON
aon 1 E Timer Cm Delay EN
EE Timer T4:1
Tire Base 0.1 Ho
Preset 10000
> — Leman |
Timer Table x iN
/EM ATT /DM PRE ALC .
002 —| 140 0 0 0 0 0 END
1] 1] 1] 10000 1]
T4:2 0 0 0 0 0
MECH 1500
T4:5 TON
1L
1L hig OM DELAY a
GEN )
DN © —{(DN
Time base 1.0 i; ),
Preset 1
Accumulated 0
i Es a
][ COUNT-UP COUNTER cu)—
OFF ON Counter C5:1 BN)
i Preset 1 Q
mi i= Accumulated i]
—0
‘tn
Le
RE
Fi
ho
=T
DN
=
C5:1 Fs
fl 1[
L JL
DM
ss C51
MECH 1500
—_=e
TON il
Timer On Delay —EN3—— ©
Timer T4:5
Time Base 0.1 {DH}
Preset 10
Aeomm a 1]
TON
Timer On Delay EN ——
Timer T4:6
Time Base 0.1 (DN)
Preset 10
Acomumn 1]
CTO
Count Up CUT
Counter Zh
Preset 1 HH DH —
Aomam 1]
22m
elTe
LIGHT
Za
{RES —
|
3.3
Down-Counter
MECH 1500
ppy Count
ubDC
PR: 003
AC: 000
| Generic up/down
li counter program.
Counter
accumulated
value
MECH 1500
Preset
Accumulated
Cc
Preset
Accumulated
MECH 1500
Pr = Eva) ET =r
i i | i |
CTU
aoo Count Tp CE
Commer 451
Preset 14 — Oil
doom 1]
| 1:1
o [I
ETi
| 1:15 CTD
5 aa - C Count Doan — CD)
So —T SAT Counter C51
| | Preset 15 DH —
[= gal 03 | Deomim 1]
* oH |-& [HE
o [IH |-& CATION
ooz 1 E
a o [HE |
sal 07 |
1/2
jo > [HE |e EE 003 JE
o [iE |e EE REBET
= Counter lable
[> © : AUD DM AW AUN PRE ACC
004 EHD
<o il © Kill CRD 0 0 0 0 0 0 0 (END
gl i2 oH ] 0 0 I I oo 15 0
| 1 | rE. [nl Nn m] m] m] m] In
MECH 1500
6)
COUNT-DOWN COUNTER /CU /CD /DN /OV JUN JUA .PRE .ACC
C5:0 0 0 0 0 0 0 0 0
Counter C5:0
(5:1 0 0 0 0 0 0 0 0
me
Preset 10 (5:2 0 0 0 0 0 0 0 0
Accumulated 0 5:3 0 0 0 0 0 0 0 0
C5:4 0 0 0 0 0 0 0 0
5:5 0 0 0 0 0 0 © 0
Up/down-counter program.
Ladder logic program Outputs
— CTU
COUNT-UP COUNTER
C52
Accumulated
— CTD
COUNT-DOWN COUNTER
Counter AoE
Preset 10
Accumulated 0
MECH 1500
1:11:10 CTU
=k int Up HF Lp,TE
PE1-Input A Conmter ch
Prasat 10 — DH —
Domum i]
I-11 CTD
oot - E Count Donen L— CD)
PBI-InpLt B
Counter ch
Preset 10 DN —
A oman |
CHCl 2:20
ooz Si A
aE for CRE od
ChH2ICD 22
ooz =) fl :
PLE
TY
CA2I0MN C2
ood HE
Pl FF EO fod
- CRES)—
1142 ch
004
MECH 1500
Photoelectric
sensor
Material
Photoelectric processing system
sensor
Out-feed
(finished parts)
—CTU
COUNT-UP COUNTER
COUNT-DOWN COUNTER
Counter C5:1
Preset 50
Accumulated 0
MECH 1500
1-1/0
noo —] E
IN-FEED COUNT
E11
001 1 E
OUT-FEED COUNT
002
1142 C51
JE CRES)—
Con va
003 UD MON OV JUN PRE ACC | “END ™~—
C50 0 0 0 0 0 1] 1] i=
C51 0 0 0 n 1} 50 0
8.4
Cascading Counters
MECH 1500
Depending on the
application, it may be
necessary to count events
that exceed the maximum
number allowable per
counter instruction. One
way of accomplishing this
count is by
interconnecting, or
cascading, two counters.
MECH 1500
—0
1 O PB2
losAl——
Eg
con
COUNT-UP SELES 60)—
Counter C5:0
Preset
Accumulated 0
MECH 1500
B3:0/0 CTI
—]
OSF. }—— Count Up Bi
Counter Cal
Preset 10 DH —
Lcoamn 1]
so o [HE
mi 18 lem
Ed RE 5:0
oo? HAE EE)
gl 02 a all 07 | BUTTD
— — [4
o [iE
13 © iE
[El (RES)
< [i | = olf 10 :
—CTU
COUNT-UP COUNTER
C51
Counter
Preset
0
Accumulated
— CTU
COUNT-UP COUNTER
C5:2
Counter
500
Preset
0
Accumulated
MECH 1500
soHE |e HE
so[HE |e BE
So | |
mem 111 C52
So IE 0: | 003 J E {RES
som |e m RESET-FB2
so5 le Ea C5:2/DN 0: 240
||
eal 11
I")
11]
004 == La
LIGHT
<> HA |e BE
joe | 00s [0 MCD ON OV JUN PRE ACC - CEND |
so a mm C5:0 0 0 0 0 0 0 0
wa — 0 0 0 0 0 5 0
>H [¢ EH EE 0 0 0 0 0 5 0
MECH 1500
Ladder logic program
RTO Seconds
T4:0DN __~1y
001 ] [ COUNT-UP COUNTER ~~ —(CU)—
Counter C5:0 ©N
Preset 60 ),
Accumulated 0
24-hour
: Hours
Tl —CTU =
clock 002 1 COUNT-UP COUNTER —(Cu)—
Counter C5:1 —(ON
program. Preset 24 )
Accumulated 0
T4:0/DN T4:0
003 i {1(RES)—
C5:0/DN C5:0
004 1 (RES)—
Is
0: T4:0/DN
[01 | 001 =N=
=
=
_ C5:0/DN 3 CTU
oo2 — F Count Up CU—
B=
Commter C51
Preset 24 | fy
[ 05 | Aecum 1]
TT
Hours: TT
{ 07 |
T4:0IDN T4:0
EB) | ooo 3 E (RES)
= Seconds
{10 | ie
ON/OFF Switch
iH C5 0/DN CED
3] 004 J E (RES)
Minutes
a
be
OMIOFF Switch
WATT TT 1 Ll
=
JL \ JS
Internal
B3:0/0
Internal 1L
B3:0/0 JL set
1C £ ™
JL LJ
Internal
B3:0/0 Trip
Internal
B3:0/0 Seconds
Monitoring the
— RTO
JE RETENTIVE TMERON [EN]
Timer T4:0 DOM
time of an
Time base 1.0 — )
Preset ty 60
event program.
T4:0/DN CTU
a _eTU Hours
T4aEN T4:0
1c {T
(RES ———
1 C5:0
I's
t (RES)——r
C5:1/DN Ch:1
1L
AAT TT Sis
— 1 Co Scans
Simulated
time of an
event T4: ODN
1 1
—_—T
=
Ldaank
os
Up
— -
I LEE
1
program.
C50DN =
aR
8.5
Incremental
Encoder-Counter
Applications
MECH 1500
The incremental
optical encoder
creates a series of
square waves as its
shaft is rotated.
Generated pulses
LLL
The encoder disk
interrupts the light as the
encoder shaft is rotated to
produce the square wave
output waveform.
MECH 1500
Wood
Programmable
controller
SE
(RES >)
Photoelectric
sensor
3.6
Combining Counter
and Timer Functions
MECH 1500
Inputs M2 M2 run time
L1
L[ TIMER ON DELAY
Tw
sige
T4:1 EY
ie MR 1.0
oD) M1 ( +|
ki:
Preset 2
Accumulated
0
rol
Em Eral E,
un
%O— |
M2
JL i
T4:1
1[
—: —~CTU ——
COUNT-UP COUNTER ~~ —
ag —(CU)
Eo C5:1
is OY
Accumulated =
MECH 1500
Ladder logic program
TonTIMER ON DELAY a0
5 min
—(EN——
Timer T40 (
Time base 1 oN)
Preset 300
Accumulated 0
1hr
—TON
TIMER ON DELAY —(EN—
Timer T4:1 (
Time base 1 oN)
Preset 3600
Accumulated 0
—CTU
COUNT-UP COUNTER ~~ —(CU—
Counter C50
Preset 6 ©N)
Accumulated 0
lock-out Resse.
JL
program ia =
he
—l
TY
Ny
MECH 1500
Total
C5:1
m(RES)m—
MECH 1500
Input LA
if a
—TON
TIMER ON DELAY —(EN)—
Output
DN Timer T4:0
Time base 1.0 —0N)
Preset 10000
Accumulated 0
ud we
+ 6)
I'L
C5:0 Light
1 £
J \ )—