0% found this document useful (0 votes)
38 views6 pages

PLC Counting Instructions

The document discusses PLC counting instructions including up counting, down counting, and combined up/down counting. It provides examples and tables of maximum/minimum counting values for different instruction types. Example applications described include tracking items on a conveyor, changing a traveling path when a preset count is reached, and tracking remaining items in a store.

Uploaded by

justerali2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views6 pages

PLC Counting Instructions

The document discusses PLC counting instructions including up counting, down counting, and combined up/down counting. It provides examples and tables of maximum/minimum counting values for different instruction types. Example applications described include tracking items on a conveyor, changing a traveling path when a preset count is reached, and tracking remaining items in a store.

Uploaded by

justerali2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PLC Counting Instructions

The PLC counting instructions are advanced software version or replacement of


electronic or mechanical counters. The counting instructions are subdivided into up
counting , down counting , and combined up down counting instructions. These key
instructions are widely used in industrial application . For example they may be used to keep
track of the number of water bottles coming out of the filling station, to control a gate for
redirecting the movement of items ( books, bottles, etc.) , to count the number of time an
event take place, measuring the linear distance an object moves, measuring the rotation
speed of motors, keeping track of the undesired items on a conveyor, etc.

UP Counting Counters

Up counters increase their current count output variable “ CV” each time their
trigger inputs experience a transition from logic zero to logic one. The instruction output
Boolean variable Q toggles from zero to one when CV reaches the preset count value “ PV”
and stay so unless reset by the reset input R. The upper counting level depends upon the
counting instruction type. Table 1 lists the upper limits for the various up counting
instructions . Figure 1 shows the instruction function block and timing chart.

Table 1: Maximum counting value of counting up instructions.

Instruction PV data type Maximum counting value


CTU_INT Integer 32767
CTU_DINT Double integer 2147483647
CTU_LINT Long integer 9223372036854775807
CTU_UINT Unsigned integer 65535
CTU_UDINT Unsigned double integer 4294967295
CTU_ULINT Unsigned long integer 18446744073709551615

CTU_XXXXX R
CU Q
CU

R
Q
CV
PV CV
PV

CV=0 CV=PV
CV=1 CV=Max Count

Figure 1: Up counting instruction timing chart


Example 1: In book packaging process it is required to change the traveling path of the

books each time preset number of books have been passed ( say 12 books).

assuming two paths, write PLC program to do that.

BooksSensors
BooksSensors C1.Q ResetC1
ResetC1
P
Switches
Switches Switches Switches
Switches
C1
Swi
BooksSensors CTU_INT
tch Swit
N
Switches
es
IN ches Q
Swit ResetC1
R
che
Switches
s
Req.Quantity PV CV

C1.Q Switches FlapCoil


FlapCoil

Switches Switches Switches


C1.Q FlapCoil

Switches Switches

Figure 2: Traveling Path Controller.


Down Counting Counter

Down counters decrease their current count output variable labeled CV , starting from
the preset value "PV" loaded by the load input "LD", each time their trigger inputs
experience transition from logic zero to logic one. The instruction output Boolean
variable Q toggles from zero to one the time CV reaches zero and stay one unless reset by
the load input LD . The minimum counting level depends upon the counting instruction
type. Table 2 lists the lower limits for the various down counting instructions . Figure 2
shows the instruction function block and details its timing chart.

Table 2: Minimum counting value of counting down instructions

Instruction PV data type Minimum counting value


CTD_INT Integer -32767
CTD_DINT Double integer -2147483647
CTD_LINT Long integer -9223372036854775807
CTD_UINT Unsigned integer -65535
CTD_UDINT Unsigned double integer -4294967295
CTD_ULINT Unsigned long integer -18446744073709551615
LD
CTD_XXXXX CD
CD Q

LD Q
PV CV
PV CV 0

CV=PV CV=0
CV=PV-1 CV=Mini Count

Figure 3: Down counting instruction timing chart

Example 2: Write ladder diagram to track the number of remaining items in a store
previously loaded with 100 items.

Enter 100 Items


BooksSensors ResetC1
Load
P
Switches
Switches C1 Switches
Switches
ItemLeaveSensor S
CTD_INT
Swit w
P
Switches IN ches
Q
i

Swit Load t
LD
che c
Switches
s 100 PV CV h

C1.Q e
StoreEmpty
Switches
s
Switches Switches

Figure 4: Tracking the remaining items in a store

UP/ Down Counting Counters

UP / Down counters can be considered as two counters (up counter and down counter)
sharing the same preset value input variable PV and current value output variable CV. The
up counting part has its own unshared terminals or variables represented by the triggering
input CU, reset input R, and the output QU. The down counter unshared variables are
the triggering input CD, the load input LD, and the output variable QD. The upper and
lower counting levels for these counters depend upon the instruction used type. Table 3 list
down these limits.
Table 3: MAXIMUM /Minimum counting values of up/down counting instructions

Instruction PV data type Max/Min counting value


CTUD_INT Integer +-32767
CTUD_DINT Double integer +-2147483647
CTUD_LINT Long integer +-9223372036854775807
CTUD_UINT Unsigned integer +-65535
CTUD_UDINT Unsigned double integer +-4294967295
CTUD_ULINT Unsigned long integer +-18446744073709551615

Example 3: Draw ladder diagram for Parking Garage Controller with N car capacity

Start
LT
Switches IN ENO
CarInside SpaceOK
Swit IN1
OUT
che Switches Switches
Capacity IN2 GarageFull
S
s
Switches w
Switches

EnterSensor ExitOK SpaceOK it


EnterOK
c
Switches Switches Switches
h
Switches
ExitSensor EnterOK es
ExitOK
P
Switches Switches
CUD1 Switches
S
EnterOK CTUD_INT
Switches w
P CU QU it
Switches
Swit
S
ExitOK CD c
QD
WN h
wche
0 R CV CarsInside e
it s Switches
0 S LD s
c

h wi
NS PV
e tc
wi
s he
S
tc
wi s
he
tc
Figure 5: Parking Garage Controller
s
he

s
Ring Counter

Ring counter CTR is an up counting instruction with inherent reset strobe facility. Here
the current value CV increases as the rung connected to CD experiences a transition from
zero to one and CV is less than PV. When CV equals PV the Q output becomes "1". The
next positive transition on CD ( after CV=PV) resets the Q output and forces CV to take a
value of one and new cycle starts. The ring counter supports only integer data types for its
CV and PV variables. Figure 6 displays the ladder symbol and the timing chart of the ring
counter.
RST
CTR1
CTR CD
CD Q

PV Q
PV CV
RST CV

CV=0 CV=PV CV=0


CV=1 CV=1
(a) (b)

Figure 6: Ring counter instruction (a): Symbol . (b): timing chart

Example 4: Y is one dimensional array. It consists of 10 word type elements. Write PLC
Program segment to continuously copy the contents of this array one after the other to the
PLC output terminals. Let the copy process time span equals to 30sec.

Start TMR_FLK CTR


EN Q CD Q
Switches
T#5S
Swit ON 10 PV
ET J
che T#5S
Switches OFF CV
0Swi RST
s
0
Switch RST tch
Swi
es es
tch
Start Swi

tch MOVE es
Switches EN ENO
es
Pattern[J] IN OUT Lamp
Swit

che s
s

Figure 6: Light Flashing System

You might also like