Sei sulla pagina 1di 246

t6 PROGRAMMING ON.

OFF INPUTS TO PRODUCE ON_OFF OUTPUTS

RELAY LOGIC
Elementary Diagram Connection Diagram
L1 L2 L3
L1

Power
Contacts\ t
SW1 3
L1
SW1 3
T1
T
I2 T3

3 L2

PLC LOGIC
Screen Pattern Connecllon Diagram
ln Ut
Co m om
1 17
INOOl cRo17
2 18
3 P 19
sw1 4 L 20
5 c 21
6
7 23
8 24

FIGURE 5-8
Example 5-l: Simple One-Switch, One-Coil Control

EXAMPLE The second example is a start-stop-seal circuit. When the start button is depressed, the coil
5-2 energizes. When the button is released, the coil remains on. It is held on by a sealing con-
tact that is in parallel with the start button. The seal contact closes when the output coil
goes on. If the stop button is depressed, the coil goes off an{ stays off. Also, if the control
power goes off, the coil goes off. The advantage of this example over example 5-1 is that
when failed control power retums, Start must be depressed to reenergize the coi[. For
example 5-1, the coil would immediately restart, possibly posing a safety hazard to an
unsuspecting operator or repair person.
The relay logic and PLC logic diagrams for this example are shown in figure 5-9. A
major difference between relay and PLC connections is in the physical location of the seal
contact. In relay logic, the seal contact is attached physically to, and go€s on and off with,
the output coil. In the PLC control, the seal is generated intemalty in the PLC logic. In PLC
logic, the seal closes or opens as the output coil goes on or off.
Figure 5-9 also illustrates the LATCTVUNLATCH function used in many types of
PLCs..One input switch latches the output on. A different input switch latches the outPut
CONTACT AND COIL INPUT/OUTPUT PROGRAMMINO EXAMPLES 87

Belay Logic
L1
---1 12
Connectlon Olagram
Elementary Olagram
L1
-J- 3
Start Start 4
Stop _t_
3 --L 4 3 Aux
Ll 3 4 T.,
Slop
4 L2
M-Aux ----'
PLC Logic -----l
Screen Pattch Connectlon Dlsgram
lnput Output
cR017
IN tN001 m
Stop 1 1

2
cRo17
Start 3 3
J- 4 4
5
6 6
7 7
I 8

PLC Lrlch/Unlatch Logb

tN1
I 608

L ON

tN2
,>
608

OFF
Connectlon olagram
Same as PLc Logic

Oul 7
608
to l,

FIGURE 5-9'
Example 5-2: Standard Stan-Stop-seal Circuit

off. The latch/unlatch PLC coil may be an internal one. A cortact from its coil may have to
be used to control a coil that corresponds to an output terminal.
Note that if CR0l7 is associated with a motor starter coil with an overload relay and
contact, special preaautions arc needed. If the overload coil in series with the starter coil
opens up, the starter will open up, but it wilt not unseal CR0l7 in the PLC program. If the
overload then cools off and its contact recloses, the motor will reshn unexpectedly. Further
circuitry is necessary, as discussed in section 5-6. Also note that for a latch/unlatch system,
power must be applied to shut it off. This is another possibly unsafe situation which requires
fiuther circuitry.
E8 PROGRAMMING ON-OFF INPUTS TO PRODUCE ON OFF OUTPUTS

EXAMPLE The third example is a standard lbrward-reverse circuit. Each direction's coil has its own
5-3 start button. The single stop button stops either coil's o'peration. In this circuit you mu$
push Stop before changing direction. Interlocks are provided so that both outputs cannot be
energized at the same time. This particular circuit works for other control applications as
well. lt could be used for low-speed/high-speed or pan-up/part-down control systems.
Figure 5-10 shows the circuit. IN000l stops operation in either direction. IN0002 is for
forward, CR00l7, and IN0003 is for reverse, CR00l8.
Tlrcre are two notes in figure 5- l0 that should be explained. The note below the relay
logic elementary diagram concerns fail-safe operation. If the motor overloads. the
normally closed contact. OL, opens up: when the motor overheats, the circuit is shut down
for relay logic. If the motor cools off and the OL contact recloses, the motor won't restart
until the start button is activated. In the PLC circuit, the OL contact is in the power circuit.
When the OL contact opens. it does not affect the control circuit on the left. The CROl7 or
CR0l8 circuit remains sealed. When the motor cools offand the OL closes, the motor will
restart automatically, which can be dangerous. To prevent this situation, the OL contact can
b€ wired to the input module and the circuit programmed to ruir each logic iine through an
OL normally closed PLC contact.
The other note above the PLC screen pattern refers to the programming of the stop
button contacts. For our diagram, the stop button contacts used are normally closed.
lN00l is programmed as a normally open contact. When the power circuit is energized,
the PLC contact closes as shown. [n some programming schemes (not shown), the
stop button contact used is normally open, so the PLC contact is programmed as a nor-
mally closed cootact. In any case, refer to section 5-6 for how to make the circuit truly
fail-safe.
At this point we begin to see that the PLC connections are simpler than connections
N
for relay logic. Compare the two connection diagramsl the relay logic connections are quite
ol
complicated in compa son to the PLC connections. p(

EXAMPLE The fourth example, shown in figure 5-l l, is similar to example 5-3. The major difference
54 is that in this example you may go directly from one direction to another without frrst
depressing Stop. Another difference is the added directional pilot light indicators. The key
for input identification is shown on the diagram.
The quick reversal may be desirable in some operational applications; howeveq in
some cases it may not be a good system. If, for exampl€, we have a large flywheel as an
output device connected to an electric motor, applying instant reversal would cause undue
stress on the motor, the power distdbution system, and the mechanical parts and
mountinBs. A more advanced circuit with a time delay would be required.
The two notes about fail-safe and how to program the Stop button explained
previously also apply to figure 5-l l. Additionatly, there is a specific listing identifying the FIG
inputs, for clarity. Exa
CONTACT AND COIL INPUT/OUTPI]T PROGRAMMING EXAMPLES 89

Relay Logic

Elementary Diagram

For.
Connection Diagram
L2
sop 3l 4
R-2 oL L1 L2
L3

F-1
'J
Rev
___L 6
1

F-2
7 L1 Stop 7
TT
l1F T2F T3F 4

3
R-t
For.
I
L2
lnterlocks
3
!ts:
Relay circuit above is "fail

-'tt
unseals when OL (over- I
4 L1 L2 L3 3
tdrop€ns. The PLC ckcuit
l6 3 a
E is not "lail sa[e' since the R2
1&€s not unseal th€ circuit.
5
TT
T1R T2R T3R
T 6

7 L2

To Numbered Wire Arrows Above

rde: 1N001 is programmed


en. Will closg when control L1 1 2 3 4 5 6 7L2
Der is applied. Terminal Block
PLC Logic
Connectlon Dlagram
Screen Pattern
lnpul Oulput
VOL
Com Com
cR017
rNo01 tN002 cB18 1 17
F Stop 2 18
cRo17 3 19
stan-F
lnterlocks I 4 20

Starl-R 22
rN001 tN003 cR17
CRO18
I 6
7
R
cRo18 I 24

IIGURE 5-IO
Erample 5-3: Forward-Reverse Control
m PROGRAMMINC ON_OFF INPUTS TO PRODUCE ON_OFF OUTPUTS

Relay Loglc (Relersnce)

3 Wire Control - Reversing Starter


wilh Pilot Lights to lndicate
Direction Motor is Running
L1 Fwd. Fwd.
F
t2
1 Stop Rev. R
2 3 6

Note: lndustrial
circuits normally ..0<6
have master slop
buttons (not shown) R
F
,,4 --l- 7
Rev
Stop R ,-o<o.l
Note: This relay circuit
is "lail sale". ll unseals
Limit Switches if Used \ when OL (overload) op€ns.
The PLC circuit below is not
"lail sale'since the OL does
not unseal the circuit.
See Note PLC Loglc PLC Connecllon

+fr
1N001 1N002 tN004 cR018
v
cR017
For
lnputs
om
Outputs
Com

rN003
t
ICR 017

rN004 rN002 cR017 cR018


Stop F

Start F
2
3
17
18
19
-I
4Hlcn Rev.
4
5
6
P
L
20

22
LJ
01
Stop R c
7 c 23
cBol7 | c 19
I 24
Start R P
--l Red ---t_ 9
U
25
10 26
cRo18 c 20 11

-l Green 12
,3
28
29
lnput Llstlng 14 30
1N001 Stop Forward Note: 1N001 and 15 31
1N002 Starl Forward 1N003 proqrammed open, 16
1N003 Stop Reverse close when control
1N004 Start Reverse power is applied.

FIGURE 5-11
Example 5-4: Instant Forward*Reverse Change Circuit
CONTACT AND COIL INPUT/OUT PUT PROCRAMMING EXAMPLES
9t

In some cases you may wish to have the output on momentarily only at times. The
momentary
on is called a jog. Jogging is a momentary-ON control cap;bility with one pushbutton.
It is
often used for a final adjustment ofa machine,s position. For this reason, jogging is sometimes
called "inching."
At other times you might like the output on all the time, as in previous examples.
Two possible circuirs for start-stop-jog are shown in figure 5_12. The piC program
and the
PLC connection diagram are included also. Note that it is necessary to push Stop
before
going from run to jog in the circuit illustrated here.

Relay Logic (Feterence)


(a) (b)
Jogging Using a Selector Switch- Jogging Using a Control Retay
Jog with Start Button with Three Push Buttons
L1
Slart CB OL
Slop Start IV OL L2 1 Stop --.r_ 3
---J- 3
Bun
*+ M OR
Jog
__l_

lA2T
1
-f1 CR

I l.los I n,n

PLC Logic (B) PLC Cornection (B)


See Note
lnputs Outputs
tN001 tN002 cR 10 Com Com
Stop 17
(Logic) 1

c8017 2 18
Note: Not Start 3 19
lR01( an Output --L 4
P
20
Jog 21
6 L 22
rN001 tN003 cR17 --t_ 7 c 23
(M) 8 c 24
9 P 25
cR010 U
lnput Llstlng 10
]N I Stop 11
12
27
Note: lt is necessary to lN2 Run ,3
2A
push Stop before going from lN3 Jog 29
14 30
Run to Jog in the above circuit.
15
1N001 programmed open,
16
closes when control power
is applied.

URE 5-I2
5-5: Start-Stop-Jog Circuits
e2 PROGRAMMING ON -.oFF INPUTS TO PRODUCE
ON-OFF OUTPUTS

EXAMPLE The sixth example is an alarm system. There ar- e


forir hazard inputs to the alarm system that go
5-6 on as some operational malfu nction occurs. We
do not deline what the hazards are: for piC
operation illustration, we only use the fact that there
arc four The system operates as follows:
D Ifone input is on, nothing happens.
tr [fany two inputs are on, a red pilot light goes on.
a If any three inputs are on, an alarm siren sounds_
u If all four are on, the fire department is notined.
Since this example is somewhat more involyed
than the preyious ones, let us take time to
specify input and output numbers. The pLC program
nu_U"., fo. ti"';nputs and outputs
are assigned as follows:

Inputs outputs
A lN00t Red Pilot Light cRol7
B INOO2 Alarm (Siren) CROI8
C INOO3 Fire Department Notify cRol9
D [NO(M

PLC Logic
PLC Connoc on (B)
1N001 tN002 cR017 Red lnputs
HI
1N001 tN0o3
Pilot
Light
To AI Com
Outputs
Com
1 17
B 2 18
3 19
D 4 P 20
tN002 tN003 5 21
L
6 c 22 Siren
1N002 tN0o4 7 c
I P 24
IN 13 ll 9 U 25 Fi.e Dept
10 26
lN00r tN002 tN0o3 cB0l8 11 27
12 28
Sirsn 13 29
tN001 rN002 rN004
14 30
1N001
I 15
r N 003 rN004 16 32
rN002 1N003 1N004

1N001 tN002 tN0o3 CRO19


1N004 Fire
Dept.
Alarm
FIGURE 5-I3
Example 5-6: Alarm System

E
A LOOK AI FAIL-SAFE CIRCUITS

A PLC logic diagram to accomplish the circuit'requirements is shown in ligure 5- 13.


One final note for this example: Connecting the PLC terminal to the output alarms is very
simple; if you had a relay switch system, the connectioos would be very involved and
complicated.

A LOOKAT FAIL.SAFE CIRCUITS


Some PLC circuits are programmed to be tumed offby applying a signal voltage. For example,
the LAICH/UNLATCH function requires an unlatch signal to tum the coil or output off. Ifyou
lose control power, pushing the stop button has no effect and the coil remains on, since control
power is needed for system turn-off.
Emergency stop switches or pushbuttons that are independent of the PLC on-off
circuits should be included. Figure 5-14 shows a circuit that could be used as a true fail-sal'e
system. Tuming the master run-stop switch off in the fail-safe circuit on the right deenergizes
all coils.

oo22 CR-FS
rN0004 Gd
i I L Latch
nun

o Stop
rN0005 0022 CR,FS
*t U Unlatch

oo22 "Hot"
---l Output Lights

Valves
OF
Coils
cR0027
tN0007 tN0008
Output Starters

cR0027 on
1N0001 rN0002 CR.FS
sw007

sw008 CR.FS
CR.FS

I
Nol Fall Sale Fail Ssfe
Both require conlrol power Circuitry in addition to the PLC circuitry
available to turn ofl is used. Depressing stop switch orloss
the output 0027. ol conlrol power turns outpuls off.

FIGURE 5-I4
Safety Fail-Safe Circuit

I
94 PROG nAlr,,lNtt t',lC ON-OFF INPUTS TO PRODUCE ON-OFF OI,TPI-ITS

wish to turn off all


Of course, in the system, fail-safe should be defined You may not
is Suppose that a device is spring
coils when the emergency switch or pushbutton Pushed
retum. If you expect the emergency switch to stop the machine where it is' it won't: it
analysis is needed'
,pring, Uu.f, foi,-e fail-safe operation, a complete control system

5-1 INDUSTRIAL PROCESS EXAMPLE


chaPter The Foblem
The next example is more inYolved than the Previous ones in this
involves a semiautomatic drill press operation as shown in figure 5-15'
A
The initial position of the dritl press spinclle is at the toP' as shown' Part
to be
down after two start buttons are
dritled is placed under the spindle. The drill is then to come
that both hands are out of the
depressed. (Two pushbuttons are recommended to assure
aritt ,pirat" rotates as it is brought downward' Downward spindle force is
;;y.i il;
fumisl"a Uy u pr"rmatic air cylinder pushiog againstan upward retum sPring; pneumatic
down
ui, it .rppfied through an electiicat solenoid' When the spindte is completely
"oitror
and the drill bit'goes through the pan to be drilled, a down sensor
is actuated' The solenoid
a""n".gi;"d, and the drili returns up by means of the retum-u! spring' When
the
i. it
"n
,pinaf" ir .ornit","ly back up, the system is to be reset to the off condition lf no part is in

piace initially, the drill spindle cannot descend'


' In addition to the operation described, a safety shield is included
For extra safety' a
The shield retums up at the same
screen shield comes down before the drill can start down'
is by its own sepa-
time as the drill by its own spring return. The shield's descent Powered
rate pneumatic solenoid
When the stop button is Pushed at any time, the drill and shield
return up Note that
to stop the spindle where it
this could be a safety hazard. More circuitry would be needed
is when the stop button is depressed.

Projection Molded to
FIGURE 5-I5 Motor Frame
Drill Press Operation Layout \
LSDD --"---+ E
Safety
Shield

Parl
LSPP
LSSD

Base
PLI
Master
System A o .i-- Starts
Control
o o r- Stops
System Start
t€ft \8,,,' Hight
Syst€m Stop
INDUSTRIAL PROCESS EXAMPLE 95

There are a number of procedural steps to go through to arrive at a solution. Previous


examples have not been complicated, and we have performed their procedural steps
informally. The steps recommended for a problem of this type are:

l. Define the process operation and list the step-by-step sequence of operation.
2. Define and list the input and output devices and- sensors required for proper
operation.
3. Assign corresponding PLC numbers to the input and output devices.
4. Draw up the PLC scheme. Note that margin notes are helpful.
5. Enter the program into the PLC.
6. Optional step: Check the program sequence by using the FORCE mode. (The
FORCE mode is explained in detail in chapter 26.)
7. Wire the PLC system to a simulator and check its operation.
8. Check the actual process operation. Try various out-of-sequence operations to
check for hidden safety defects or sequencing problems. For example, what
happens if the power fails when the spindle is halfway down?
9l Make modifications as required.

Step one is to list the sequence.


l. Push system start switch.
2. Put part in place to actuate LSPP (Pan in place limit switch.)
3. Push the two start buttons simultaneously.
4. Safety shield comes down, actuating LSSD. (Shield down limit switch.l
5. Drill starts rotating and descends.
6. Drill at bottom actuates LSDD. (Drill down limit switch.)
7. System shuts down. Drill and shield retum up by springs.
8. System is reset.

Note that pressing Stop at any time stops the sequence and resets the spindle and
safety shield to the top.

Step two is to list the input and output devices.


D System start switch
tr System stop switch-stops everything
tr System pilot light
D Shield and drill start-left-hand switch
n Shield and drill start-right-hand switch
n Shield and drill stop-left-hand switch
o Shield and drill sto5right-hand switch
tr Position indicator-pan in place
D Position ifldicator-shield down
D Position indicator--{ril I down

Step three is to assign input and output numbers to all components. This includes
switches and sensors,
I

96 PROGRAMMINC ON-OFF INPUTS TO PRODUCE ON-OFF OUTPUTS

Inputs Outputs

INOOI System start OUT0I7 System pilot light


INOO2 System stop OUTol8 Shield down solenoid
INOO3 LSPP-part in place OUT0l9 Drill rotate motor
INOO4 Left stan OUT020 Air solenoid to drill down cylinder
INOO5 Right start
tN006 Left stop
INOOT Right stop
INOO8 LSSD-shield down
INOO9 LSDD---drill down

Step four is to sketch the PLC system.


Step five is to load the sketch into the CPU. The tadder diagram formulated is shown
in figure 5-16.
A sequence by line for the ladder diagram in figure 5-16 is
D Line A. Push System Start. CROl7 goes on.
tr Line B. CROl7 seals on. PLI goes on.
u Line C. Put part in place. IN0O3/LSPP closes. CR0l7 contact is closed and
INO09/LSDD is closed. Pushing the two start buttons, 1N004 and 1N005 causes
CROl8, the shield air solenoid, to go on-lowering the shield.
I Line D. CR0l8 seals thrcugh CR0l8 and IN0O8/LSSD as the shield goes into
place. The two start buttons must be held in the depressed position until the shield
is down.

cRo17
tN002 1N006 1N007 1N001
Sysl€m On &
cRo17 Pilot Light
B
cR018
c8017 1N003 tN005 tN009
c Shietd Down
cRor8 1N008
Nota: Again, stop buttons are
D
cR019 programmed open, but close as
c8018 tN008
F1 E Drill Motor
Rotation
soon as conlrol power is applied.

cR020
cRo19
F Drill Down

FIGURE 5-16
Drill Press PLC Control Circuit

l
I

I
TROUBLESHOOTING PROBLEMS

Note: These commons


are difterent - do not mixl

Com Com
Slarl -r1
o+ 1 17 PL
System 2 2 18
Stop 3 t9
4 20 SD SOL
P
Start -L4 5 21
L
6 22
Lett
7
c 23
Stop
8
c 24
RGT MOTO
P
9 25
U
Start 10 26 MD SOL
Right 11 27
Stop 12 2A
13 29
14 30
15 31
9 16 32
O+
LSDD

LSPP LSSD

FIGURE 5-T7
Input and Output Module Wiring for Drill Press

D Line E. CR0l9 goes on through CR018 and INoo8/LSSD, starting drill motor
rotation.
E Line F. Drill gocs down, CR020, by another air solenoid, and dritls the ho1e. When
the drill reaches the bottom of the hole, INOO9/LSDD is actuated, opening the
circuit on Line C.
r Reset/Off. CR0l8 is tumed off by the opening of the NC contact, causing the shield
to go back up. CROl8 going off, in tum tums off the drill motor, CR0l9, on Line E
and the drill down air solenoid, CR020. The system is reset and the part is removed.

Step six is an optional FORCE analysis.


Step seven is to wirc the system to a simulator. A wiring scheme appears in figure 5-17.
Note the connection diagram's simplicity for the PLC--flly five outPut wires and nine input
wires.
Step eight, circuit operation, and step nine, modifications, would follow after an
analysis of the dritl press's actual operation.

TROUBLESHOOTING PROBLEMS
The PLC has b€€n programm€d lo operate as sbown i[ the figues rcf€rred to. Howeve!, the circuit
has the malfunctioos [oted on t]re following page. Whar misgograrDming or other factor or factors
could cause the malfunction?
98 PROORAMMING ON_OFF INPUTS TO PRODUCE ON-OFF OUTPUTS

TS 5- I Refer to the figure 5-9 (example 5-2) PLC circuit.


l. The output does not go on when IN00l is energized.
2. The output does not seal on when IN00l is released.
3. Th€ circuit cannot be turned off.

TS 5-2 Refer to the figure 5-10 (example 5-3) PLC circuit.


l. When IN0O2 or IN003 is energized, nothing happens.
2. You can energize the forward output but not the reverse output.
3. When Stop, IN00l, is energized, the reverse output does not shut off.
TS 5-3 Refer to 6gure 5-l I (example 5 4).
L The output pilot lights rcmaio on even if the coils are off.
2. You can go directly from fon/aad to rcverse, but not from reverse to forward.
3. One or both forward and reverse are momentary only.

TS 5-4 Refer to the figure 5-12 (example 5-5) PLC circuit.


l. When Jog is depressed, the coil CRl0 seals on.
2. when Start is depressed, the CR l0 coil does not seal on.
TS 5-5 Refer to figure 5- 13 (example 5-6). State how the system would malfunction if one or morc
of the inputs were erroneously programmed normally clos€d instead of normally open.

EXERCISES
Construct PLC ladder diagrams for the problems listed. A sequence could be written frst, if neces-
sary. As an option, show the ioput and output modules along with the device-to-terminal eleat cal
connections.
In the laboratory, you may load the PLC CPU with your program. Connect the PLC to a
simulator. Check out the proper operation of the circuit by running the program sequence.
l. Draw figures similar to figures 5-5, 5-6, aod 5-7 for the following operation.
a. Switch ll
or switch 12turnsonrelay l.
b. Switch 13 and switch 14 tums on relay 2.
c. Switch 15 or limit switch 3l and relay I tum on relay 3.
2. A fan is to be staned and stopped from any one of three locations. Each location has a start and a
stop button (refer to example 5-2). Note that normally closed stops should be in series and
normally open starts in parallel.
3. A two-way hydraulic cylinder has two solenoids curolling it. Energizing one solenoid causes the
cylinder ro extend and energizing the other solenoid causes it to retract. A limit switch at each end
indicates full retraction or full extension. Use two start-stop three-wire controls, one for each di-
rcction. Construct a two-directional control system, including interlocks, to control the solenoid.
Refer to example 5-3.
4, A milling machine (M) and its lubrication pump (L) both have three-wire stan-stop control sys-
tems.A three-wirc system is shown in figure 5-9 (three control wires from PB station to starter).
L must be running before M can be started. Funhermore, ifL stops, M must also stop.
5. Two separate start-stop-jog contol stations are r€quir€d for a pump motor. Refer to exarnple 5-5.
6. There are thrce machines, each with its own stan-sbp buttons. Only one may run at a time.
Construct a circuit with apbropriate interlocking.
7. Repeat exercise 6, except that any two may run at one time. Also, any one may run by itseli

I
9
;
*I
* EXERCISES 9t)

Stamper

l Epo for Exercise 9


-IE5-18 Up

f Dn
O LSUP
O LSDN
Lioht fo-l Posl Pos3
d,, l'o'l Pos2
srop lo I

LS1 Conveyor LS2 LS3

Conveyor
Motor

8. A temperature control system consists of four thermostats. The system operates thre€ heating
uflits. Themostats arc set at 55, 60, 65, and 70"F. Below 55"F, three heaters are to be on. A tem-
perature between 55 and 60"F causes two heaters to be on. For 60 to 65'F, one heater is to be on
Above 70"F, there is a sattty shutoff for all thre€ heaters in case one stays on by mistake. A rnas-
ter switch turns the system on and off.
9. Create a PLC system in a marmet similar to the example in section 5-7 for the problem in figure 5- 18.
When a pafi is placed on the conveyor at position l, it automatically moves to position 2. Upon
reaching position 2, it stops and is stamped. After stamping, it automatically moves to Position 3 lt
stops at 3, where the part is .emoved manually from the conveyor Assume that only one part is on the
conveyor at a time. Add limit switches, interlock, pushbuttons, and other devices as required. Ifyou
bcome stuck at the middle station, you may add a manual restafi switch for this point on the
conveyor.

Extro credit'. Rielrjlove the middle restart and operate automatically.


Relation of Digital Gate
Logic to ContactlCoil Logic

OUTLINE
6-l Introduction o 6-2 Digital Logic Cates o 6-3 Boolean Algebra PLC Programming
tr 6-4 Conversio Examples

OBJECTIVES
At the end of this chapter, you will be able to
u List the seven basic digital gate types, draw their symbols, and describe their function.
tr Show the relation of switch contact logic (relay/PLc ladder logic) to digital logic for each gate
type.
D Create digital systems and Plc/relay logic diagmms from process word descriptions
D Convert from any one of the three programming systems to any other for ( I ) process operation
word description, (2) relay logic diagramVPlC logic diagrams, and (3) digital gate diagrams.
D Write Boolean expressions.

10r
l|l2 RELATION OF DICITAL GATE LOCIC TO CONTACT/COIL LOCIC

6-l INTRODUCTION
Large programnrable logic controller (PLC) programming systems of the screen/monitor
type do not require the use of digital gate logic principles. The programming is normally
done by typing in lines. connection nodes, contacts. and coils or functions. However, most
srnaller progranrmers rvith smaller lighr emining diode (LED) displays have keyboard keys
wirh digital logic norations.
These srnaller progranrrners can have digital gate logic keys such as AND, OR, NOT,
and others. This chapter shows how to Ielate these Iogic terms to the relay and large-screen
PLC logic. Once the logic terms are understood, PLC programming using them can be eas-
ily accomplished.
Other symbols that appear on some PLC keyboards are a dot. +, -, 0, and =. These
are Boolean algebra symbols. Boolean algebra is a shonhand way of writing digital gate
diagrams. Since this type of programming format is not found often, Boolean principles are
discussed only briefly.
There is another reason fbr studying digital programming. Some computer-trained
persons understand PLC programming best using digiral logic. This chapter should help
these people to program PLCs properly.
This chapter compares word descriptions, relay ladder diagrams/PLC ladder dia-
grams, and digital gate diagrams. The relay ladder diagrams and PLC ladder diagrams in-
volve coil/contact programming. More important, in this chapter we show how to translate
tiom one of the three systems to another. The use of a Boolean system and its digital rela-
tion is also reviewed briefly. A person who knows one system but must program in another
will be able to do so by mastering this chapter's principles. You may be interested in delv-
ing deeper into digital gates and Boolean equivalents. Many digital logic texrs cover rhem
in detail.
By necessity, rhe chapter has a high ratio of illuskations to text to fully explain the
principles involved.

G2 DIGITAL LOGIC GATES


We discuss digital logic gates from a PLC logic standpoint, but we do not cover the details
of their electronic intemal workings or their electrical operation. Figure 6-l shows the
seven basic types of logic gates.
All gates have one output. The outputs are either on (l ) or off (0), depending on the
logic status of their inputs, on (l) or off (0). A gate-on condition is typicat when *5 volts
DC comes from the output terminal. Off is typically 0 volts output.
The NOT gate always has one input. The EXCLUSM OR and EXCLUSIVE NOR
gates usually have two inputs but can have more. The other four types can have two to eight
inputs and sometimes more. An input on is typically when +5 volts DC is applied to an
input terminal. Off is typically 0 volts applied to an input terminal.
There is internal electronic circuitry that causes the gates to function properly. There
are usually four gates of one kind in the digital integrated circuit. In addirion to input and
output terminals, each chip needs two terminals for power, one for +5 volts, the other for
ground.

b-
DIGTTAL LOGIC CATES r03

FIGURE Gl lNl ------r------r tN1


tN2 Out
tN2 ----.1 Out
Seven Basic Digital Logic Gates IN3 -----r-----l tN3
AND Gate OR Gate

tN1
out Out
rr.r
-)o-- tN2
NOT Gate Exclusive OR Gate

lNl tN1
lN2 Out rN2 Out
tN3 tN3
NAND Gate NOB Gate

tN1
Out
tN2
Exclusive NOB Gate

The AND gate and its programming equivalents are shown in figure 6-2 For the
AND gate output to be on (l), all inputs must be on (1). The relay programming and PLC
programming equivalents are also shown in the figure. For the four-input situation, input 1,
input 2, input 3, and inPut 4 must be on for output 12 to be on. Otherwise, output l2 is off'
For AND gate programming with a digital PLC keyboard, the sequence of key oper-
ation is l, and,2, and,3, and,4, =, 12.
The OR gate operation is shown in figure G3. For an OR gate output to be on I ),
(

any one or more of the inputs must be on (l). For the outPut to be off (0)' all inPuts must be
off (0). The same operational voltages and principles as for AND gates apply to OR gates'
Again, the equivalent relay and PLC programming diagrams are shown in the figure'
The wo;d description of this operation is, "For outPut l7 to be on (l), any one or more of
inputs 1,2, and 3 must be on (l); otherwise, outPut 17 is off(0)."

Oulput
SW1 SW2 Belay
tNl lN2
lN1
tN2
Out10+
+
H.'9\ .7.

2 lnput AND 2 Switch Equivalent 2 lnput Equivalent

Oulput
tN1 +
swr sw2 sw3 sw4 Relay
lNr lN2 rN3 lN4 ,, \
tN2
tN3
tN4
Oul 12 + -'IHHHF{1,
4 lnputAND 4 Switch Equival€nt 4lnpul Equivalent
Gales Beley Laddor PLC Loglc

FIGURE G2
AND Gate and Relay and PLC Equivalents

:
104 RELATION OF DIGITAL CATE LOGIC TO CONTACT/COI LOGIC

tN1
tN2
tN3
Oul 17 +
+ SW1

sw2

sw3
L;
tN1

tN2

tN3
I
Gate Relay Ladder PLC Logic

FIGURE 6-3
OR Gate and Relay and PLC Equivalents

To input an OR keyboard program for figure 6-3 we would use the sequence l, or, 2,
or, 3, = 17.
The NOT gate is shown in figure 6-4 along with relay and PLC equivalents. It
reverses the input logic status, on or off, from the input to the CPU. The output will then be
the reyerse of the input, off or on. A NCI key input, inserted at the proper point in the pro-
gram sequence, caries out the reversal.
The EXCLUSIVE OR gate symbol is included in figure 6-1. Its output is on (1)
when one, and only one, of its two inputs is on (l). If both inputs are on, the output is off.
Thus this gate's output is on ifthe inputs are different. T\e EXCLUSIVE OR gate is seldom
used in PLCs, so we do not discuss it beyond showing its basic symbol.
The EXCLUSM NOR gate symbol is also included in figure 6-1. Its output is on
( I ) when both of its inputs are on or off (0). If ary of its inputs are on, its output is off. In

other words, this is gate's output is on if the inputs are the s4rz€. Like the EXCLUSM OR
gate, the EXCLUSM NOR gate is seldom used in PLCs. Only its basic symbol is shown.
The NAND and NOR gates are the two final basic gates. Both are a combination of
two other basic gates. Tho NAND gate, shown in figure 6-5, is the combination of an AND
and a NOT gate. The relay and PLC logic for the NAND gate require a logic relay, as
shown. The NAND keyboard program is l, nand, 2, nand, 3 , nand,4, :,27.
The NOR gat€, shown in frgure 6{,
is made up of an OR gate and a NOT gate.
Again, a logic relay is required for relay or PLC logic. The NOR keyboard program would
be l, nor,2, not 3,nor,4,=,62,

Logic Any Relay


+ sw22 Belay

Logic

lN22 --1 N_. Oul 63 - Output


l-'- LR Relay CR62
HF--4x Out

Gate Relay Ladder PLC Loglc

FIGIIRE 6-4
NOT Gate and Relay and PLC Equivalents
DIGITAL LOGIC GATES 105

Logic
tN1 I sw1 sw2 sw3 sw4 Rela)
IN2
tN3
Oul27 l_.,- "_-.-"_r.-"_-.-, -rG\-
tN4 Outpul
NAND Gate
Relay
tN1 LB
lN2
tN3
Oul27
tN4
4 Switch and uivalent
NAND Equivalent

Any Relay
tNl lN2 3
HH.
lN lN4
Logic

cR21
t-------) 27 I-l out
4 lnput PLC Equivalent

FIGTIRE G5
NAND Gate and Relay and Prc Equivalents

Out 62
sw1
Logic Relay
NOR Gate SW2
{LR}-
tN1
tN2
rN3 ->
NOR Equivalent
Our 62

I
SW3

t y_
Output Relay

-__________ ^^ \_.]
C

'' \-/
3 Switch Relay Equivalent

Relay
N1
Logic
N2

tN3

CR112
----*t (oz)----l o,r
3lnput PLC Equivalenl

FIGURE 6-6
NOR Gate and Relay and PLC Equivalents
106 RELAIION OF DIGITAL GATE LOGIC TO CONTACT/COIL LOGIC

Example of Meaning-
Symbol Dellnition Usage wo.d Description

and C.D.E CandDandE

+ ol 11 +12 11 ot 12

not M Nol M

o Change
L is true {on) it
results in F.G=L both F and G are lrue {on)

FIGURE 6_7
Boolean Algebra Symbol Notation

G3 BOOLEAN ALGEBRA PLC PROGRAMMING


Sometimes you may have to program a PLC in the Boolean algebra system. which is
shonhand method of writing gate diagrams. Complex gate diagrams can be analyzed
ily when they are written in Boolean form. The analysis is covered in digital logic texts.
This section covers only the PLC programming aspects of Boolean algebra.
The symbols used in the Boolean algebra system are illustrated in figure 6-7. Exam-
ples ofusage and the meaning ofthe Boolean expression in words are also given. Figure G8
shows some typical gates and how they would be represented in Boolean form.

FIGURE Gt
Boolean Algebra F4uivalents for B X AND A.B.C=X
c
Digital Cates
F
G Y OR F+G+H+l=Y
H
I

R z Nor a=z

S 106 NAND S.T=106


T

11
14 N NOR 11 +14+17=N
CONVERSION EXAMPLES l07

CONVERSION EXAMPLES
The l0 chapter examples that follow illustrate conversion liom one PLC programrning
system to another'l'he Boolean expressions are included for reference in each example as
optional information. The len examples are divided into three groups as follows:
I Four examples 6- I through H, of how to convert a \A ord description into ladder
.
and gate diagrams.
2. Three examples, 6-5 through 6-7, of conversion fiom a ladder diagram to a gate
diagram.
3. Three examples, 6-8 through G 10, of conversion from a gate diagram to a ladder
diagram.

Ladder diagrams will be included for relay logic and PLC logic.

PT,E The {irst example is shown in figure 6-9. Output 122 is to be on only when either inputs 7
andSareonorifinputslTandl8areon.Outputl22canbeonwhenallfourinputsareon.

\ \\IPLE The second example is a conveyor control problem. Conveyor C is to run when any one of
four inputs is on. It is to stop when any one of four other inputs is on. The ladder relay and
PLC control diagrams are shown in figure Gl0.
An explanation of the gate diagram is in order. The four starts are inputted to an OR
gate, OR L When any one ofthe four is depressed, the OR I gate output go€s on. When thc
start is released, the output goes off. The stop buttons are connected to another OR gate.
OR 2. OR 2 goes on when any one or more stop buttons are depressed. The OR 2 output is
inverted by the NOT gate and sent to the AND 4 gate.
With no stop button depressed, the stop OR 2 gate is off(or low). Due to the NOT in,
version, the stop input to rhe AND gate is on (or high) when no stop buttons are depressed.
With no stops depressed, output C can go on if OR I is also on. Any time that both OR I
and OR 2 outputs are high, the inputs to AND 4 are high and output C is on.

?-----f---\ SW7
i---[P]n
oB3 122
SW8

l-r't"--t""-- Oulput HH
tN7 tN8
,+ Output

sw17 sw18 lN17 lN18


AND 2 Relay HH
Gate Relay Ladder PLC Ladder

17+q+(7.18l,=122
Boolean (Bsl.)

IIGURE G9
E\ample 6-l: Word Description Conversion
108 RELAIION OF DIGITAL GATE LOGIC TO CONTACT/COIL LOGIC

___l-
I -------O
__J-
Stad Stan
Buttons ___t- oB1 AND4 c
(STR)
___l-
4 -------a Stop

11 -------o 11
NOT
Stop 12 ------4 12
Buttons oR2 +Or
(SIP) 3 Altsrnately: 13
+ Stop
14 Buttons 14
-=o
Arrangement
Gate Loglc

Stops Starts
2 3 4 ---L1l
)- 12

---L 13

)-- 14
Assign valid
Relsy Loglc PLC number
to ou_tput
rN1 tN2 tN3
frHHH+'
tN4 tN11

tN12 +
I

tN13

tN 14
I

PLC Logic

(sTR1 + STR2 + STRS + STR4) .(STP11 + STP12 + STP13 + STP14) = C


Boolean (Ref.)

FIGURE 6-10
Example 6-2: Word Description Conversion
CONVERSION EXAMPLES 109

Seal
Starts I

---L11
-------o
)- 12 Stops
------o
AND o
2

Gate Logic

Stops Starts
1 2 ----L11

)_12
l------.-.ol-
lo-rl
Belsy Loglc

Assign Valid
tN1 tN2 lN11 Output
Number
tN12

PLC Loglc

(sTR1r + STR12 r O).STP1 . STP2 = D


Boolean (Rol .)

FIGURE 6-11
Example 6-3: Word Description Conve6ion

L\.{MPLE The third exampte shown in figure 6-1 I is a motor control circuit with two start and two stop
tl buttons. W}en a start button is depressed, the motor runs. By sealing, it continues to run
when the start button is released. Either stop button stoPs the motor when depressed. This
example differs from the previous one in that the system seals on when the start is released.

EXAMPLE This example is a more complex system. Its solutions are shown in figure 6-12. A process
a4 fan is to run only when all of the following conditions are met.
110 RELAIION OF DIGITAL CATE LOGIC TO CONTACT/COIL LOCIC

NOTl

AND5 P

2
\-----...-\ l
)oR2
------------2
3 ,-..'
5 AND3
-
7
8 oB4
I
Gate Logic
2 7

f--/r l 3 !E_re_l_,+_l_cl
Felay Loglc

tN1 lN2 lN5 tN6 tN7


P Oulpul
tN3 INB
I

tN9

PLC Logic

(1)J(2+3) . (5.6) . (7+8+9): P

Boolean (Bef.)

FIGURE GT2
Example 6-4: word Description Conversion

l. Input I is off.
2. Input 2 is on or input 3 is on, or both 2 and 3 are on
3. tnputs 5 and 6 are both on.
4. One or more of inputs 7, 8 or 9 is on.

EXAMPLE Examples 6-5 through 6-7 involve converting PLC ladder diagrams to gate diagrams.
G5 Conversion to Boolean is an added option. This example, shown in figure 6-13, is a fun-
damental conversion. Se es contacts are converted to AND gates. Parallel contacts are
converted to OR gates. Then, the combinatioDs are treated in the same manner, series
combinatioos to AND and parallel combinations to OR.
111
ebNvensloN gxet\4Pl-rs

tN61 lN62
61
ANDl
tN63
63
oR3 Out 15
64
tN64
65
AND2
lN65 lN66 66

civen PLC Ladder Diagram Equivalent Gate Diagram

(61 '62) + (63) + (64) + (6s ' 66) = 15

Equlvalent Boolean Expresslon (Ret )

FIGURE 6-13
Example 6-5: Ladder Diagram-to-Gate Conversion

Figure 6-14 illustrates the sixth examPle. It is more involved than example
6-5 and
gates for the gate diagram. It also requires an input inversion' Since contact
re{uires more
l0'i, nor-ullyitosed in the PLC ladder diagram, its state must be invened The inversion
the
i, a""omptirlea ut the input of logic gate OR 22' By convention' the bubble Performs
same function as a NOT gate.

many gates
:\{\IPLE The seventh example shown in ligure 6-15 is a more advanced circuit requiring
of the equivalent gate diagram follows the principles
and two inversioni. The construction
of the previous two examPIes.

r_f-tH,u)_l 1

2
AND19

!-re-_l+--l I
5
7
AND2O oR23 15

t-f--7l-e_.]
I !P-r
civen PLc Ladder Diagram
I
10
11
oR22
AND21

Equlvalenl Gate Diagram

(1 '2) + (5'7) r
' (10 - 11)l = 15
I{8)
Equivalent Boolean Eryte$ion (Rel')

FIGURE GI4
Example 65: Ladder Diagram-to-Gate ConveNion
|2 RELATION OF DIGITAL GAIE LOGIC TO CONTACT/COIL LOGIC

r--rt-- U
rre-l
EF---, Y

!r-l Given PLC Ladder Oiagram


P
o
R

U
z
X
S
T
Y
Equlvslent Gate Diagram
{(P + Q-+ R)
.(U+V).W.x]*15*t1.V=Z
Equivalent Boolean Expresslon (Ret.)

FIGURE 6_15
Example 6-7: Ladder Diagram-to-Gate Conversion

EXAMPLE Examples 6{
through 6-10 show conversions of given digital gate diagrams into ladder
ffi diagrams. The ladder diagrams are drawn for PLC logic only. As in previous examples, the
Boolean equivalent is given for reference.
The example in figure 6-16 is a fundamental gate-to-ladder diagram conversion.
Two differcnt AND gates feed one OR gate. If either or both of the feeder gates are on, the
OR gate is on and output R will be on.

01
03 ANDl 101 103 1

R
oR3 B 111 113
111
AND2
113

Glven Gale Diagram Fesulling PLC Ladder Dlagram

(101 .103.105)+ (111 . 113)= R

Equlvalent Boolsan Expresslon (Rel.)

NGURE 6-16
Example 6-8: Gate-to-kdder Diagram Conversion
CONVERSION EXAMPLES ll3

l-n P--i f-*"@-l


tril
I

rE F"l
B
c
D
E
oB1

oR2 AND4
M
Pr !tr
Resulting PLC Ladder Diagram
F

AND3
H (A+ B+C)'(D+ E+F)'G' H=M
Given Gate Diagram Equivalent Boolean Algebra Expresslon (Bel.)

FIGURE 6-T7
Example 6 9: Cate-to-Ladder Diagram Conversion

\lPLE This example shown in figure 6-17 has two OR respective gates and one AND gate all
feeding an AND gate. Each OR gate is converted to Parallel cootacts in the ladder diagram.
The AND gate is convened to series contacts or to series groups ofcontacts. The only new
concept introduced is the bubble on the H input. The bubble means the input is inverted. It
is the same as if a NOT gate were in the line between the H and the input point of ANI)
gate 3.

EX,{MPLE The example in figure 6-18 is another gate-toladder diagram conversion- A new feature
G10 introduced is an input being fed to two different places, which is shown in the resulting
PLC tadder diagram. Two different contacts are needed in the ladder diagram for it to be
equivalent to the one gate input number

Logic
L L
M
N
tV
o
R S
N

^B (1)
Given Gate Dlagram Nole: Musl be two
separate contacls
for R input.
B(2) Logic 1
s
(L+M+N) + (Q.R). R=S
Equlvalent Boolean Expresslon (Bol.) Besulting PLC Ladder Oiagram

FIGURE 6-18
Example 6-10: Gate{o-Ladder Diagram Conversion -
l14 RELATION OF DIGITAL GAIE LOCIC TO CONTACT/COIL LOCTC

EXERCISES
For exercises I through 4, conven the word description to:
a. Gate symbols.
b. PLC/Relay logic ladder diagrams.
1. Switch 8 and switch I I, plus either switch 22 or switch 34, must be on for output 67 to be on.
2. For output ? to be on, input 6 must be offand either input 8 or input 9 must be on. In addition,
one of inputs l, 2. or 3 must be on.
J. For output H to be on, input A musl be on and both inputs C and D must be off. In addition,
one or more of inputs E, F, and G must be off.
4. Four pushbutton stations control a fan. Each station has a start and stop button. Two door
interlocks must be closed before the fan may run. Pushing any start button will make the fan
run, and the fan is sealed on when the smn bunon is released. Pushing any stop button tums
the fan off and also prevents the fan from starting or running.

FIGURE 6-19 41
42
Diagram for Exercise 5 43
162
51
52

FIGURE G2O
Diagram for Exercise 6 a-),
^_____5-
H

F --a -

FIGURE 6-21
Diagram for Exercise 7 22-4-
51
----l-
s1
32--) -
41
EXERCISES ll5

FIGURE 6-22
Diagram for Exercise 8 f-f+_r 42 51
a2

!r,r L-r fE
5B

FIGURE 6-23 11 24 25
Diagram for Exercise 9

13

21

22

FIGURE G24 c E
Diagram for Exercise l0 +--r Fz--r P---r
F

E H

5-7. For exerciscs 5 through 7, conven the gate diagrams given in frgures 6-19' 6-20, and 6-21'
respectively, to PLC ladder diagr.ms,
E-10. For exerciscs 8 throuSh 10, convcn lh€ PLC ladder diagrams given in figures 6-22, 6-23, and
6-24, respectively, to gatc di!8rams.
ll. (optionat) Conven the diagrams of exercises I thrcugh l0 to Boolean algebra erpressions.
Creating Ladder Diagrams
from Process Control
Descriptions

OUTLINE
7-1 Introduction B 7-2 Laddq Diagrams and Sequence Listings o 7-3 Large-Process Ladder
Diagram Construction D 7-4 Flowcharting as a Programming Method

OBJECTIVES
At the end of this chaptet you will be able to
o Create basic ladder diagrams from a sequence of operational stePs.
D List the major steps in creating a PLC program for an industrial situation
o Describe the content of each of these steps.
tr Flowchart a process.
ll8 CREATING LADDER DIAGRAMS FROM PROCESS CONTROL DESCRIPTIONS

7-l INTRODUCTION
Planning without action is a waste of time and money, and action without planning
chaos. The purpose ofthis chapter is to outline some ofthe planning needed to create
workable, safe PLC programs-without chaos.
You may want to omit this chapter for now if you work with preprogrammed PLC
programs. You should include this chapter if you have to create your own programs, mod-
ify programs, or if you doubt the validity of the program you have.
This chapter is written in relay logic. The principles are readily convened to PLC
programs as described in chapter 5 for contacts and coils.

7-2 LADDER DIAGRAMS AND SEQUENCE LISTINGS


Ladder diagrams are the most commonly used diagrams fot nonelechonic control circuits.
They are sometimes called elementary diagrams ot line diagrams. Sometimes they are
considered a subtype of schematic diagrams. The term lqdder diagrams is used in this
book. Why are these diagrams called ladder diagrams? They look like a ladder in a way.
You stan at the top of the ladder and generally work your way down.
Two types of ladder diagrams are used in control systems: the control lqdder dia-
gram and the power ladder diagram.'fhis section concentrates on conhol ladder diagrams,
with only a fundamental explanation of the power ladder diagram.
Figure 7-l shows two basic control ladder diagrams. The first one (a) is for a single
switch that turns a relay output, CR5, on and off. The second (b) is a single-function dia-
gram with parallel lines for control and parallel liDes for output. Either or both of two
switches turn the output and a pilot light on.

FTGURE 7-1 L1 L2
Basic Control Ladder Diagrams

I sw.
L)/.'c 3
Output

(a)

L1 L2
CBu
SW,
3
Output

I .r,-
l-- -d o
I

---t

(b)

E
LADDER DIACRAMS AND SEQUENCE LISTINCS ll9

L1 SWr cB7 L2
nclion Control Laddcr Line 10
3 Output 1

SWz

2
CRa
cR/-1 SW:
11 12
3 Output 2
PL.

4 | (c H

At this point, we should define the term ,rode. A node is a connection point for two or
more devices such as switches, coils, pilot lights, and other electrical devices. In figure 7-1,
a node is denoted "3" and in 6gure 7-2, the nodes are "10", "l 1," and "12." These numhrs
are used for identifying connecting wiring points. You may arbitrarily use any numkring,
or lettering. system you choose. Precautions: (l) do not duplicate node numbers or letters
in a given program, (2) do not assign numbers or letters to different parts of a single node,
and (3) a node goes to all points commonly connected.
The control ladder diagram ofligure 7-2 has two active functional lines. Some of the
common practices for the format of control ladder diagrams are illustrated by this figure.
Those practices are as follows:

r: All coils, pilot lights. and other outputs arc onthe right.
r An input line can feed more than one output. If it does, the outputs are connected
in parallel.
.r Switches, contacts, and other devices are inserted in the ladder line starting on the
left.
rl Switches, contacts, and other devices may b€ multiple contacts in series, parallel,
or series-parallel.
u Lines are numbered consecutively downward on the left.
tr Every connection node is given a unique identification number.
c Outputs can be identified by function on the right, in notes.
- A cross-identification system may be included on the right. The contacts associ-
ated with the line's coil or output are identified by line location. In figure 7-2, the
J to the right of line 1 indicates that a normally open contact ofrelay CR7 (the coil
on line l) is located on line 3. For a normally closed contact, the number would
have an asterisk (*) next to it or a bar over it. Figure 7-5 uses the same system on
two different lines.
D Relay contacts are identified by the relay coil numb€r plus a consecutive sequence
number. For example, we have included contact CR?-1. Ifother relay CR7 contacts
were used, the next would b€ CR7-2, and so on.
120 CREMINC LADDER DIAGRAMS FROM PROCESS CONTROL DESCRIPTIONS

FIGURE 7-3 L1 L2
Incorrect Control Ladder Diagram
cR-1 SW
CRZ CRE
for Figure 7-2 swr 11 12 13
2

The control ladder diagram in 6gure 7-2 has an operating sequence as follows:

Sta i g ht -Th rou gh S e que nc e

All switches are open to start; both coils are off.


Close SW,, SW,, or both; CR7 is energized.
On line 3, CRll closes, enabling line 3 (CR8 is still ofa)
Closing SW. energizes CR, and pilot light PL,.
Opening both SWr and SW, turns eyerything off.

Alternative Possible Sequence

Initially tuming on SWj causes nothing to energize.


Opening SWl when everything is on would turn offCR, and PL, only.
(Other sequence possibilities exist.)

Figure 7 3 is an incorrect ladder diagram that contains the same components used in
figure 7-2. Will this circuit work? No. First of all, if power could get to point 13, the out-
puts would not work. Each would have l/3 control voltage across it. Relays would not pull
in, and the light would glow dimly or not at all. But the outputs will never go on anyway.
Ifall switches are closed, no power gets through contact CR7-1, It cannot close until CR7 is
energized, which is impossible.
The operation ofthe power ladder diagram in 6gure 7-4 is straightforward. When rhe
power contactor coil is energized, the power contacts close and power is applied to the
motor or the load device. Note that the prower ladder diagram wiring is shown by thicker
lines, to differentiate its wire from control circuit lines.
Additional sequence requirern€nts may call for the construction of additional control
ladder lines. The following functional modifications can be added to the ladder diagram of
figure 7-2.

SWa must be on for CR7 to go on.


CR7 must be on for CRs to go on.
CRe is tumed on by CR7, CRs, and SWr.
LADDER DIAGRAMS AND LISTINGS l:l

74 Power lo control diagram


l-.dder Diagram
t M OL
T1
Lt

OL 3
r2
h Phass
Motor
OL
q-l T3

The extended ladder diagram is shown in figure 7-5. Note that there is a dotted line
between the two Sw3 contacts. The doned line indicates a common single switch with two
contacts. (lf SWr were on the left, only one contact would be needed to run lines 3, 4,
and 5.)
An added sequence of operation can be determined from an added ladder line.
Such an added ladder line is shown in figure 7-6. The added sequence based on this
additional line would be as follows: CR7 or CR3 or both, plus LS12 and CRe, tum on relay
output CRro.

L1 L2
Line
swr CR,
10 SWl
1 + 11
3, 5 Output 1

I
swz

cR7-1 cRe
13
12
+ 5 Output 2

. PL,
4 I

-GH
,f-:i-i_,-;:,+" Output 3

FIGURE 7-5
Extended Contsol l,adder Diagram for Figure 7-2
CREATING LADDER DIAGRAMS FROM PROCESS CONTROL DESCRIPTIONS

L1 12

cR-3 cBe-l cRro


17 LSrz
6 Fl9-, Outpul 4

I cRs-2 I Nole: References


? f-- F------l on righl of Figure
7-5 lines must be
revised to include
components on
lines 6 and 7.

FIGURE 7-6
Added Line for Control Ladder Diagram of Figure 7-5

7:3 LARGE-PROCESS LADDER DIAGRAM CONSTRUCTION


Some of the steps in planning a program for a large process are:

l. Deline the process to be controlled.


2. Make a sketch of the process operution.
3. Create a written step sequence listing for the process.
4. Add sensors on the sketch as needed to carry out the control sequence.
5. Add manual controls as needed for process setup or operational checkitrg.
6. Consider the safety of the operating personnel and make additions and adjust-
ments as needed.
7. Add master stop switches as required for safe shutdown.
8. Create the ladder logic diagram that will be used as a basis for the PLC program.
9. Consider the "what if's" where the process sequence may go astray.
Some othel steps needed in program planning that we will not cover are tlouble-
shooting ofprocess malfunctions, parts list of senson, relays, and so on, and wiring diagrams,
including terminals, conduit runs, and so on.
To illustrate the nine steps ofthe planning sequence, we use a fundamental indusrial
control problem. We then go through the creative process to illustrate each of the steps of
the planning process.

Step I
Define the problem.
We wish to set up a system for spray-painting parts. A part is to be placed on a mandrel.
(A mandrel is a shaft or bar whose end is inserted into a workpiece to hold it during an opera-
tion.) When the pan is in place, two pushbuttons arc pressed and the mandrel rises. After the
part rises to the top and is in the hood, it is to have spray paint applied for a period of 6 sec-
onds. At the end ofthe 6 seconds, the mandrel retums to the original position. The psinted part
is then removed from the mandrel by hand. ftVe assume for our illustation that the pafl dries
very quickly.)

I
l-eobEn otecnlv coNSTRUcrloN t23
LARGE-PROCESS

Perhaps a word or two on pneumatic power would be in order before


we proceed'
since we will be employing a pneumatic cylinder in our spray Process system ln a pneu-
is air' With a
matic system, powei is'transfened by gas under pressure The gas of choice
of the type usetl here, an electrically activated air valve allows
linear pneumaiic actuator,
pneumatic cylinder, forcing the latter upward'.When the vaiue is
air in to press against a
open, down cories the cylinder, the result of gravity and downward spring
action ln more
pneumatic iystems, a four-way spool value is used to permit air to be forced
complicated
to either side of a cylindir or piston. Ihus both forward and backward motion is accu-
robot control ln
rately controlled. Such pneumatic systems are employed extensively in
more pneumatic robots are used in manufacturing worldwide than any other
type'
fact,

Step 2
Make a sketch ofthe process (figure 7 7)

Step 3
List the sequence of operational stePs in as much detail as possible The sequence steps
be added'
should be dtuble or triple spaced so that any omitted steps discovered later may
The following is a step sequence for this process.

l.Tum on the paint pump and pneumatic air supply'


2. Turn the system on. This requires pushbuttons other than the system buttons'
3. Put the pan on the mandrel. A sensor indicates that the part is in place'
4. Push thi Master Stan button and the two system start buttons Having to Push
two system start buttons (with both hands) reduces the possibility of the opera-
tor's hands being injured by the rising mandrel'
5. The mandrel is iaiserl by a pneumatic cylinder energized by the opening of an
electrically actuated air valve when the system start buttons are pressed (The

Paint Hood

Paint Valve Paint Reservoir


'f ean Raised and Pump
Part Placed I lnto Hood
Here ---\ o \-
o g1s1 s66 glep gy11q6
-t
tt
tl
tt
tl
Pneumatic Valve to Raiso Part by Pneumatic Cylinder;
Spring Belurns Down when Otl

TIGURE 7-7
Sketch of the SPraY Process System
t24 CREAIING LADDER DIAGRAMS FROM PROCESS CONTROL DESCRIPTIONS

mandrel will return by Bravity and downward spring action when the valve is
reopened.) When the mandrel rises, the pa -in-place sensor at the bottom
becomes deenergized. (Note: The part-in-place sensor does not rise with the
mandrel.)
6. When the pan reaches the top and is under the hood, it is held against a stop by
air pressure. A sensor has indicated that the part has reached the top.
7. A timer starts and runs for 6 seconds.
8. During the timing period of6 seconds, paint is applied by the sprayer
9. At the end of 6 seconds, painting stops and the mandrel, with the part on it,
lowers.
10. The up sensor is deenergized when the mandrcl with the pan on it descends.
I 1 . The pan arrives at the bottom, reenergizing the part-in-place sensor.
12. The part is removed from the mandrel.
13. The system resets so that we may start at step 3 again.

Step 4
Add sensors as required. Once we list the sequence, we find that sensors are needed in
the machine to indicate process status. We need a sensor (a limit switch placement) to
show that the part has been placed on the mandrel initially. We also need a sensor (limit
switch up) to indicate when the mandrel is fully extended upward. Among other possible
sensors that a process such as this might need is one to make sure the paint sprayer has
paint and one to make sure the inserter's hand is out of the way. Depending on the
process and the detail of control, other sensors could be required as well. Figure 7-8
includes .he two basic sensors, LSP (Limit Switch Part) and LSU (Limit Switch Up), and
their locations. The figure also shows the enclosures needed, along with the tocations of
start and stop buttons.

LSU
Limit swilch or LSP
other sensor that Limit switch or other sensor that
indicates when the---\ indicates part is in place.
mandrel is fully up

Control Start t61 ---D.- Start


Belay Stop lal Stop
Slart and
Stop Jimer Two RUN pushbutton
Cabin€t stations for hand salety.

System Slarl and Slop

FIGURE 7.8
Sensor, Enclosures, and Pushbutton Locations

I
LARGE- PROCESS LADDER DIAGRAM CONSTRUCTION l::5

Step 5
Add manual controls as needed. We may need a manual pushbutton to raise the mandrel to
the top for setup purposes. The manual up position is needed when we set the spray-gun
pr"ssure fo. optimrm paint coverage. We include pushbunon up (PBU) on our ladder dia-
gram to accomplish this manual control.

Step 6
Consider the safety of the machine operator. One basic way to keep hands out of a process is
to have two start buttons. Then both hands must be away from the work to depress both
buttons (which works until the operator ligures out how to use one knee and one hand) Other
considerations, which we do not cover in detail here, might be op€rating a fan to disperse
fumes during spraying, or perhaps a photocell proximity-personnel-system-stoP device'

Step 7
Add emergency and master stop switches as needed for operator safety. This may seem to
be part of step 6 because both st€ps deal with operator safety lt is a continuation of ttte
safity issue, but emergency stop switches are so important that they need sPecial consider-
ation as an additional steP.

Step 8
Create the ladder logic diagram. The diagram created is to include the steps and consider -
ations of the first seven steps. This is shown in 6gure l-9 for our spraying example'

Step 9
Determine the "what ifs," or potential problem areas. After the ladder diagram is com-
pleted, all possible situations and emergencies should be listed. In this example, some of
them might be:
D what if no part is in place when the start buttons are pushed?
D What if thc power fails during the cycle when the Part is rising, during painting, or
at any other time?
o What if the sprayer runs out of paint?
tr what if the same part is left in for a double coat?
tr What if the master stop button is pushed? Does the stop button really stop the
entire process, or can the mandrel move and create a safety problem after the stop
button is depressed (it can)?

All of of questions should be considered in the final sequence and ladder


these types
diagram. Review of the ladder diagram in ligure 7-9 covers some of these contingent
situations but not all of them. Further modifications would be needed for a more complete
consideration of contingencies.
Prcgram
Step L2
Number
L,! Emerggncy
Llne Re, Function
Slop Control
Voltage
lnterlocks
l1
iraster Right Leti
Master 6;ilji'-r closed when on
a Stop Stop Slop
___.L
Starl Pump- Pressure
3,4 F---o-r-!--il!----{rry oTJ CB1 B, C System
Master Relay

cR1-1
B Seal

Parl on Mandrel Bioht Lett


cn1-2 LSP futart --rrstart ca2 C D. E, G Up Relay
4,5
Enable
I cR2-l cB3-1 I
Seal (CB2-1)
D

=--1r Shutofi (CR3-1)

I cR2-2
E Solenoid Up Air
6,7 to Cylinder
Enable
Manual Up
_-J_ F Manual Up

Part in Hood
LSU
cR2-3
7,8 TR1 GJ Paint
On 0 sec
Enable
To 6 sec

&
TR2 HK Time to Lower
Olf 0 sec
To 7 sec
On at 7 sec

TR1.1
J Painl Spray
9, 10, 11
l" on 0-6 sec

TR2.1
cR3 K c Shut Otl
Open LSP at 7 sec
Line C Note: On Reference Line: Lower
Normally Open - Letl€r shows wher€ coil contacts are on another ling Bgset
Normally Closed - Lsttor with bar shows same
FIGURE 7-9
Ladder Logic Diagram
FLOWCHARTING AS A PROGRAMMING METHOD 127

--l FLOWCHARTING AS A PROGRAMMING METHOD


As mentioned earlier, one of the steps in planning a large-process ladder diagram is to
create a wdtten step-sequence listing for the process. Prior to doing so, however, you
may wish to develop a flowchan, or flow diagram, which is a pictorial rePresentation of
program logic. Such a flowchan can make application program development much eas-
ier. The flowchart shows the points of decision, relevant oPerations, and the sequence in
which they shoutd take place to solve a problem. Such a chart lets you think in a graphic
manner.
Most flowcharts use four basic symbols: ova[, diamofld, rectangle, and parallelo-
gram. In addition, connection rows EIre used to connect the various symbols (see figure
7-10).
The oval symbol indicates either the beginning or end of the program. We place
"start" in the oyal to begin a program, "end" to finish it.Tlrc diamond indicates a point of
decision. With it, we ask a question, one that can usually be answered by "yes" or "no:' The
rectangle is the process block; some type of computational processing or operation is
taking place. The pa ralklogram i'Ildical€s inPut/output. It is used to input information into
the system or to take it out.
A possible flowchart for the spray process system is shown in figure 7-l l. Once the
flowchart is created, the written step-sequence listing of the process should go more
smoothly. Why not give flowcharting a try?

FIGURE 7-IO
Oval
Flowchart Symbols

Diamond

Rectangle

Parallelogram

Connecting arrows
I

-l-
Has
(.*) NO part
reached
top?

Operalor
turns on paint
pump and
pneumatic
air su
Part is
spray painted
for 6 seconds

Operator
turns _---_______l_
system on I

irandrel

[---T-l-r
wjth part
is lowered

Operator
puts part
on mandrel ./ts\
tt
J.I
I

7/mandrel \ No I

with part >- --l


\descendingr.,,'

YES
{}."o
placee
rn
_! Has I
m andrel with NO
part afiived
bottom
YES

Operator
ushes master
slart and lwo
syslem starl
buttons Operator
removes part
hom mandrel

Mandrel
flses

Syslem
reslarts

FIGURE 7-1I
Flowchart for Spray Process System
EXERCISES 129

CISES
Solve the lbllowing problems using the nine-step planning sequence:
l. Make J laJder JiaerJnr for the following sequence:
When SWr is closecl. CR, goes on.
Atier CR, g()es on. SW, can turn CRt on.
When CR, goes on. PLl goes otI.
2. Make up a sequence listing lbr the ladder diagram in 6gure 7-12.
3. Make a llowchart for the ladder diagram in figure 7-12.
4. A part is placed on a conveyor. The part automatically moves down the conveyor' In the middle of
the conveyor, rhe part goes lhrough a 2-foot-long painting section. The sprayer paints for the time
the pan is under the booth. during which time the conveyor does not stop. When the part reaches
the end of the conveyor. the conveyor slops and the part is removed. Assume that only one part
can be on the conveyor at one time. (Hinr: Use one limit switch at the front of the booth and
anolher at the end-) See 6gure 7-13.
5. Same as exercise 4 excepl that the part stops in the middle of the conveyor and is stamped' not
painted, and then continues to the end ofthe conveyor'

7-12 swr SWz


CR 2
Diagram from Which to o-
a Sequence
sws

cR12-1 LS
/
CR,

CB,
il
r
cR13-1
t_--] t--- ------{
CRr2-2 CRi4-1 SWr CB

IIGURE 7-13 Spray Boolh (*1)


Dagram for Exercises 4 and 5 or
Stamper Enclosure (#2)
/{
Start Here Stops Here
Basic PLC Functions

8 Register Basics
9 PLC Timer Functions
10 PLC Counter Functions
Register Basics

OUTLINE
8-1 Introduction tr 8-2 General Chamcteristics of Registers D 8-3 Module Addressing
o 8-4 Holding Registers tr 8-5 lnput RegisteN: Single aod Group o 8-6 Output Registers: Single
and Group

OBJECTIVES
At the end of this chapter, you will be able to
u List the five common typ€s of PLC registers.
r Describe the function of each of the five register types.
cl Describe how each of the five common types of PLC registers is used in PLC operations

133
134 REGISTER BASICS

8-1 INTRODUCTION
So far, we have examined the complete PLC system and peeked inside to see how it oper-
ates. We haye explored general programming procedures and, more specifically, the plo-
gramming of on-off inputs and on--off outputs. Furthermore, we have looked at auxiliary
commands and functions, and then have created a ladder diagram for a process problem. It
is now time to move on to timers and counters, two core f[nctions available with a[ pLCs.
But before we do so, it is best to preface our study with an intoduction to registers; mem-
ory locations that provide temporary storage ofdata, instructions, information, and, what is
particulady relevant, numerical values associated with timers and counters. Keep in mind,
though, that this chapter is meant to provide only an introduction to the subject. Further
analysis will take place as the book progresses, especially when we encounter data move-
ment systems, the utitizing of digital bits, and the SEQUENCER functior in chapters 16,
18, and 19, respectively.

u2 GENERAL CHARACTERISTICS OF REGISTERS


Within the PLC CPU, registers are found in two locations. The microprocessor has inrer-
ral registers, most of which are not directly accessible by the user. These registers (4, 8, 16,
or 32 bits wide, depending on the microprocessor) help the control and arithmetic and logic
units within the processor to ciury out their tasks. Accumulator registers, data registers, in-
dex registers, condition code registers, scratch pad registers, and instruction registers-all
work to temporarily store data, which in turn is used to facilitate the carrying out of prG.
grammed functions.
In addition to these internal registers, the CPU's RAM also contains slots that are
designated to hold yariable information. These locations, or addresses. become external
registers. Throughout this chapter and text we assume these registers are 16 bits wide.
There can be a mere handful of such r€gisters or hundreds, depending on the size of the
CPU and complexity of the user program.
Each bit location in a register contains, of course, either a I or a 0. you can observe
register contents on a VDT by calling up the register on a keyboard. In addition, on many
models you can print the register contents on a typed printout. Various numbering systems
are possible for reading register contcnts or printing them out. In chapter 13 we describe a
variety of PLC numbering systems. Depending on your PLC capabilities, you may choose
to p nt register yalues based on one or more different numbering systems. For example,
one model allows you to choose between l-Decimal, 2-Binary, 3-Hex, or 4-ASCII.
Other possibilities are Octal and special codes unique to the system being used. Still other
PLCs are conflned to displaying or printing in only one numbering system, usually the dec-
imal system.
Registers are usually designated using prefrxes followed by numbers, as is the case
in this chapter HR256 represents holding register 256; OG2 represents output group regis-
ter number 2. In other systems, a certain numerical series of addresses may be assigned to
a specific task or function. One model of PLC has register addresses 901 through 930
assigned to timers and counters only. It is important to determine the functions for the
addresses of your PLC registers from its operational manual.

L
HOLDIl'\C REGISTERS r35

In this chapter we look at the function of five key registers. We see how the holding
register, input registers (single and group), and outPut registers (single and group) operate
to temporarily store data for microprocessor manipulation.

MODULE ADDRESSING
Before we move on to reBister basics. this is, perhaps, a good time to revisit a.topic briefly
discussed in chapter l, PLC input and output modules. Specifically, we want to examine
module I/O addressing.
You will recall that I/O modules, along with the processor module and power supply,
sit in a chassis, a physical hardware assembly. The VO modules are actually placed in an
I/O rack. Each [/O module in turn consists of l/O groups made up of a set of terminals. The
terminals are used for making field-uiring connections. In sum, we have a PLC with VO
modules, consisting of groups of terminals.
The location of an input or output terminal, within a module group. within a rack.
will determine a device address. Each input and output device must have an address.
As an example of an t/O terminal addressing scheme, let's look at what Allen-
Bradley does with its PLC 5. The addressing format is shown in figure 8-la.
The scheme consists of a five-level hierarchy staning at the top with a lile type and
descending to a terminal number. Specifically:
! A nle type designates an input or output module (I input; O output).
: A file No. specifies which particular VO module, input or output.
-
.r A rack No. determines which rack the module sits in.
x A group is a set of terminals u ithin a rack. Typically, there would be 8 groups in
a rack (0-7).
c The terminal No. is the bit address for a particular terminal, input or output.

In figure 8- lb, we show two examples of the addressing format. In Example No. l,
rve have an input module (file type), with a file No. 2, in rack 3, group 6, having a terminal
bit address of 28.
In Example No. 2, we have an output module (file type), with a file No. 0, in rack 4,
group 3, having a terminal bit address of 5.
Of course, this Allen-Bradley addressing scheme is only one of many types. Nonethe-
less, it is indicati.re of VO module addressing methods used tkoughout the industry.

8J HOLDING REGISTERS
A holding, or working, register (HR) "holds" the contents of a calculation, arithmetic or
logic. Conceptually, it is in the "middle" of the CPU, as shown in figure 8-2.
Because in many PLCs, particularly smaller ones. the holding register is not directly
accessible to inputs or outputs, input and output registers (single or group) interface the
holding register contents to the outside wodd. Signal data from a sPecific input device is first
"deposited," in the form of 0s and ls, in an input register. It may then be manipulated by the
136 RECISTER BASICS

File delimiter

Bit delimiter

01 02 /00

Terminal number

Group (0'7)

Rack No.

File No.

File type (l-input; O-output)

(a)

Examole No.1

12 | 36128

Examole No-1

00 : 43/05

(b)

FIGURE 8-1
Allen-Bradley Addressing Fomat

FICURE 8-2 lnput Working Oulput


PLC Registers registers or registers
Specitic holding
Specific
inputs registers
outputs

a-12 100-1000 8-12


typically lypically typically

E
INPI;T REGISTERS: SINGT-E AT'*D CROUP 137

OVEBFLOW
ENABLE INDICATOB
INPUT
OPERAND 1
i
HB 0075
DATA
INPUT OPERAND 2

DATA HB 0076
INPUT L----------.1
DESTINATION
OUTPUT
SUM
HR 0077

FIGURE 8-3
Registers in Arithmetic Operations

microprocessor and the results s€nt to a holding register Conversely' before the contents of the
holding register can affect the outPut device, they are uansfened to an output register' The
output register's 0s and Is "drive" outPut interface devices such as optoisolators'
To illustrate holding register use, we can look briefly at their function in arithmetic,
timer, and counter operations. Keep in mind, though, that not only are these operations coY-
ered in greater detail in later chapters, but holding registe$ are used in numerous othet
functions coyered in future chapters.
In arithmetic operations, a holding register mrght contain the first operand; another
holding register, the second op€rand; and a final holding register, the destination of the
mathematical manipulation (see figure 8-3).
In the timer function, the Preset time value would be placed in a constant or
designated register. The holding register is the register in which the count takes place
tsee figure 8-4at.
The counter function is similar (see figure 8-4b). The preset count value is also placed
in a constant or designated register The holding register, of course, is the register in which
the count takes place.
How many hotding registers arc there? In small PLCs there may be as few as 16' In
large machines there are hundreds ofholding rcgisters, all aocessible for programming use'
manipulation, and visual analysis.

t-5 INPUT REGISTERS: SINGLEAND GROUP


The input register has basically the same characteristics as the holding register, except that
it is readily accessible to the inPut module's terminals or PJrts. The number of input regis-
ters in a-PLC is normally one-tenth that of holding registers.
138 REGISTER BASICS

FIGURE 8-4 PBESET IS WHERE THE


Holding Registers in Timers and TII,4ING VALUE IS SET,
Counters IT MAY BE A CONSIANT
OR A DESIGNATED REGIST

PRESET TS 017
014

REG,
HR 101

REG, tS THE DESIGNATED


(HOLDING) REGISTEB IN
WHICH THE COUNT TAKES
PLACE,
(a) TIMEB

,.-- PRESET IS WHERE THE


COUNT VALUE IS SET.
IT MAY BE A CONSTANT
OR A DESIGNATED REGISTE'

PRESET DC 107
o21

REG,
HR 102

REG, IS THE DESIGNATEO


(HOLDING) REGISTER IN
WHICH THE COUNT TAKES
PLACE,
(b) couNTER

The input group register (lG) is somewhat like the input register. lt differs in
each one of the individual 16 bits is directly accessible from one input pon. One
group register receives data from 16 consecutive input ports (terminals). Figure 8-5
trates how this IG system works. The advantage of the IG system is that only one
is required to service 16 inputs. Without the IG system, you would need 16 registers
service 16 inputs. Without the input group system, you would use up more
memory sPace to run your programs.
The input module port (terminal) corresponds to a single input group regisrer
Each IG register status confols one bit's status. When a port is enabled, or on, it
I in the corresponding bit stot. If the pon is oft-it produces a 0 in the corresponding bit

b
OUTPUT REGISTERS: SINGLE AND GROUP 139

ON 1

OFF 2
OFF 3
ON 4
ON 5
Similar
I ot'l 6
N oFF 7 I rJ' tr
P oFF 8
0 1 0 0 1 0 0 1 1 1 0 0 1
UON E
a
1 1 1

T oFF 10
Input Group Register lG 0001
OFF 11

TON 12
EON 13
RON 14
M OFF 15
toN 16
N OFF 17
AON 1B
L OFF 19
SON 20
ON 21
Srmilar
ooN 22
N OFF 23
OFF 24 4
l 0 0 0 0 0 0
o OFF .E 1 1 1 1 1 1 1 1 1

RoN 26
lnput Group Begister lG 0002
ON 27
O OFF 2A

6 OFF 29
FON 30
31
ON
ory 32
33

+
33-48 lG 0003
4H4 + lG 0004
elc.

FIGURE 8-5
Input Group Register Scheme

It is necessary to know how your PLC groups the input numbers that conespond to
each input group register. A typical scheme is shown in figure 8-{

H OUTPUT REGISTERS: SINGLEAND GROUP


Like the input register, the output register has the same basic characteristics as the holding
register. Th€ output register differs from the holding register, however, in that it is readily
accessible to the output module's terminals and ports. The number of output registers is
normally equal to the number of input registers.
140 RECISTER BASICS

lnput Group 8 Bit Syslem- 16 Bit System-


Regisler lnputs lnputs
Number Controlled Conkolled

1 l-€ 1-16
2 9-16 17-32
3 17-24 33-48
4 25-32 49-64
5 33-40 65-40
6 4148 81-96
7 49-56 97-112
etc. etc. elc.

FIGURE E-6
Input Group/lnput Port NumberinS Scheme

The output group register (OG) is organized in a manner similar to the input
register. It differs from the IG in a manner similar to the difference between input regi
and output registers. Figure 8-7 shows how the OG register functions. One OG register
control 16 outputs. If a t is in a bit position, it will tum that bit's coresponding output

Oulput Stalus
for HR 276
Values

16-bit wide I
HRs 17 ON
18 OFF
275 1001 0000 1000 1100 19 ON
Command given to
transler contents 20 ON
276 r011 1010 0100 1101 of HR 276 to 21 OFF
OG 2 moves OFF
contents 23 ON
277 0100 0011 1111 0001
to Oulput Group OFF
24
oG2 25 OFF
1011 1010 0100 1101 26 ON
27 OFF
17 28 ON
2S ON

OG1 would be 1-16 30 ON


OG3 would be 3H8 OFF
elc. ON
I
Outputs

FIGURE 8-7
Output Group Register Scheme

L
EXERCISES 141

A 0 will tum its corresponding output off. The grouping scheme for output group registe$
is similar to the input group register system. The grouping scheme is shown in figure 8-7.
The output group register is panicularly useful in sequencer operation, as discussed in
chapter 19.

CISES
l. List the five major types of registers. Use a block diagam to show wherc each type fits into the
PLC scheme of operation.
2, What woilld the input group registcr look like for the thrce input module status anrangements
shown in figure 8-8? What would the number of each IG register b€? what would the register
contents be in binary?
3. What would be the status of the corEsponding outputs for the four output and input group regis-
ters shown in figure 8-9? What are the correspording output numb€rs for the four OG and IG
Egisters shown?

FIGURE 8-8 A E c
Diagram for Exercise 2 lnput lnput lnput
No. Status No. Strtus No. Slatus
49 ON 105 0N 209 OFF
50 ON 106 oFF 210 ON
51 OFF 107 0N 211 OFF
52 ON 108 oFF 212 ON
53 OFF 109 0N 213 ON
54 OFF 110 oFF 214 OFF
55 ON 111 oFF 215 ON
56 ON 112 0N 216 OFF
57 ON 217 ON
58 OFF (8 Bit PLC) 218 ON
ON 219 OFF
60 OFF 220 OFF
61 0N 221 OFF
62 0N 222 ON
63 OFF 223 ON
64 0N 224 OFF

FIGURE 8-9 0011 1100 1010 oG 0007


A 0111
Diagam for Exercise 3

B 1010 0110 oG 0006

c 0101 1111 0000 0110 tG 0011

D 1100 1011 1011 1000 oG 0021


Ia
a

PLC Timer Functions

OUTLINE
9-l Introduction B 9-2 PLC Timer Functions o 9-3 Examples of Timer Function Industrial
Applicatioos tr 9-4 Industrial hocess Timing Application

OBJECTIVES
At the end of this chapter, you will be able to
D Describe PLC retentive and delay timer functions.
o List and describe eight major timing functions that arc commonly used in circuits and
processes.
D Apply PLC functions and PLC circuitry to process control for each of these eight major timing
functions.
o Apply PLC timen in multiple timing problems that combine two or more of the basic timing
functioos.
o Apply PLC timers for the control of industlial processes.

1rl.l
I

144 PLC TIMER FUNCTIONS

9-l INTRODUCTION
The most commonly used process control device after coils and
contacts is the timer
mos comm on m n s functi on s T ME D ELAY. o N h ch s
the basic fluncti on There
also rla ny orh er tl m n con fi ura ti on S. al o f hi ch can be de
n ved from one or more of
bas lc TI M E D E LAY-O N fun cti on s. PLCs h ll ve the ()
ne bas c fu NC tio n mer capa b ty
multi ple s. Th ts ch apte u strate the bas c PLC TI M E D ELA Y-O N f'u nc
tro n a nd
I
other deri ved m n 1u nc o ns Tvp c al f the de ved fu nc o n
s are T M E D E LAY- o
n erval pul se mln c an d m u p e p u lse tl n'l ng o f
more tha n one proces operatt on
i\4 PLC ha ve o DC m er fun cll on the re e n T ME D ELAY-O N fu nc ron
have o add on al me fu nc ons T ME o N D ELAY, and TI \.,1
E o FF D ELAY,
operat on be ex P la ned
N rm il v o n v o ne o f o ty pe s o f the basr c P LC lml
ng fu nc t() nal b locks IS tn
PLC The tl IN ng b oc k fu nc ns are used th an ou 5 contact
arTangemen and n m
p CS to accoln p sh an ou s ri m ng tilsks Ty pr cal
nd ustn al tr m ng tas k NC ude ml n
c
he t1 te rval firr
I
ld n par n tr n and h ea treati n Ti mers can al so p redeterm
c ne the
terv al be e n two operat o n wi th a PLC ou CA n u ze as
v manv tl mer b ocks AS
n eed, h n he PLC me mory IN tati on S
h at d oes he PLC I]]er fu nc o n rep ace Detai
ed desc TI ptr on s of tradi tl o na
dus tri al me rs n1 a v be fb u nd n C o n tro s texts nc ud n8
those sted n rh c bi bl ography.
s v m bo tbr c onven tr o na m ers are n n aP pe nd lx C PLC ti mer f'u n c o NS can repl
i
an v o he c nd u fl al m trs Wheth the indu S tri al m et IS motor dri ven RC ti nre con-
an ()r das h pot c an be eas v rn u ated b a PLC
v
The d al so id state e lec IIOn c IN er one rec h no io gr S tep a bove he three ty pes
f
o nd US 1n al 1r me s u s1 sted These di al tl m n devi ces
c I are a lso di scus ed ln vanouS
c o n tro tex ts The P LC tr m ng fluncti on mo versat e and fle x b Ie than et the r the n-
d u s tri al or he di ta e le c tron c mers
One major advantage ofthe pLC timer is that its time
._ may be a programmable vari-
able time as well as a fixed time. The variable time interval
may Ue in accordance with a
changing register value. Another advantage of the pLC
timer is that its timer accuracy, re_
peatability, and reliabiliry are extremely high because it
is based on solid-state technoiogy.

9-2 PLC TIMER FUNCTIONS


A single-input timer called a nonretentive riflel. is used in some pLCs. An example is
shown in figure 9- l. Energizing IN00l causes the timer
to run for 4 seconds. At the end of
.1 seconds the output goes
on. When the input is deenergirea, th" outprt goes off
and the
timer resers to 0. If rhe inpur IN00l is tumid off durinithe riming
iniervat lfor example,
after 2.7 seconds), the timer resets to 0. In this case, tlJortprt
*o"uiJ rot have rumed on.
There are operational disadvantages of the single-inpui
type timer that are oyercome
by the multiple-input rimer Figure 9_2 shows ttrrie tyies
oi fo.rnui. tbr pLC timers.

FIGURE 9-I rN001 TSO17


SingleJnput Timer

4 sec.

L
t/)
f-

Eo
95 g;
*r t P6
0- Eui I
Eed
o Grr

oa
z 4
=

E E
cc
Lll

!9
o E '-, i;v
e EEi
e6E;
; a(! a
".9-q
Y'@
a E'E X' N
F E eT
6",E.!
ccyS
o
N
a
F
zt
q:E
-t
e,
AF
EE
I

,E
i(
o
F

OE o=
*r E
E
lt
oo.!3 -9
E oo
l!3E
!! L
z z z
4
tr
d
l5
E
cr
cc cf,
o eg
ti
-9 -9
E
UJ irJ tr EE

l{s
I
z.
tJJ

F
zo
I
:g

z
o
CE
ul
F
t!
>o)
tu !:6 E
o
F i!EEE3 E
(I (EFFI!<
I 'L
.c .g
o l
E
tt 'E

J o _r! F
o
F E 1 o-
IE EE E tr
g CE
at o o! .: F
E Q6;
t! I';
XEE E
E{ q;
z+ztLztLzLztLzL
"i;'.S
f J.l 9o o6obobobobob
e;Pg t

CE;; .9
ID @ s
I @
.ER:
c96; .9 ,g
E
ic
; e:5 o ILI o- F o
= 9c! <E
F6
E E E
t! F E F F ovo I

oI.i
&
)
It

t4
Iz
L!
zo
,; .E .9;
9La 3-P
+;P c
o o Ea i=
HEEB
.< ::f
e88.8
3
IJJ
o
zo E BE;5
(I q
E
.E
E
EHiEH
.q @<)-oE
LIJ ,E
E E E 5Pd6c,
E F F F t! Q ?o d-
d,
_9
:*6?;o;
.E
o E
.9

E
€:iHff
t ==v;io
F59do'
t,
J t! 8E;rE
2
o B EE 8EE
F qt B
.c
a! o SEET s
E
e iJ a o
r! h B^9€
a PeU?3
=dE aEc:5
!i 9L eb
EE8 aoY 39
€-IxEP
- l;o E=aEeE

= k; EE
o o; x i[
I :.q o.EE I
P F ri
EE E B 5 &
p
=E-€3 rr

147
t
zul zo
l. 9
o
6
t
9ee
^ :85
Et-c
3€E:
o o e=.i9E' ^
--oooi
>3 !1 E P

.< E!5ioo:
E Q q! ]
IJ gErXi
o
IL
P(EEB
q-E+o-
o
cc
Ll,l
E
.9
.E iiIeE
o
F tr
E
t- tr (!
E ,s
,-E
p
t3**eE
o-- q--
=o :9
.9
_9 E d,. =;
.9
o E
E
gEIEi
1'
i= €
t;;eS
] d4-QEi
TL
o
F B
E3:;H
I EE; qE
E q,P! iTEEA
uJ ofE E;EE;
6F c e
!F(,)@-
.11 96
E
r35 E&
clr; ! E -, Ps b,;
or2 E = b 3
cE6 c s E ag i;
-is3E;E
A E P3 gE
o:oq :E:E;E
+ -e .r 3
5e;;::
E 3-9 4 dP

o
:€E!Ec
9 ,
F
6 =oXE.ga
: e,.!
I

F F 8.9.e
E 6 X'6 E !
i::
ic5$HE

l,l8

E
PI-C TIMER FUNCTIONS l,t9

Figure 9-2a and b illustrate t\!'o common types. Figurc 9-lc shtlws an occa'ionallv ttsed
type where the enilble and reset are ditlerent inputs filr use in sotne spccirrl crrscs.
The block tbrmut in figure 9-2a incltrdes the Enable/Rcsct linc. rrhich allous the
timer to run when energized. When deenergized. the timer is kePt 11 0 or |e\el k) 0. l'hc up-
per line causes the tirner to run when the timer is enablcd. \\'hcn crtahlt'Ll lh. lirlrer runs as
Iong as the run input is energized. If Rutt is deenergizecl w lrilc tht' tirncl i' r unnitlg. the titn-
ing stops where it ir and does not reset to 0. Note thul li)r ligurc 9-la il both lN(X)l (Run )
and IN002. (Enable/Reset) open and close at the sanrc tirlle. lhc tirricr Itrrrclion\ in thc sanle
manner as the tinler in hgure 9-1.
Fortbnnat(a)inligureg-2.suppi)sethatlN002isckrscdanLl lN(X)l isturrledon Al-
ter 6 seconds, lN0{)I is opened. Thc tirner retains a count ol 6. Tinling has not teitched lhe
preset value ol I4 seconds. and the timer output is still oll. Thc lilllcr doc\ llol rcscl tlnlcs\
IN002 is opened. Suppose that sometime liller lN(X)l is rcclosc'd. Alict li tnore \econds ol'
IN00l being closed. the timer coil will cnergize. \incc 6 - tl : l'1.
Format (b) in tigure 9 2 is an alternate. IN7 is lirr tirrring l{'l-l I " RN. INti enitbles
RT3l = RS. Whcn the timergoeson.itsoutput-ll(illtr'rnll)ttrrnsotrlptrl 7lion. Insonle
PLC fbrmats, the register count is not displayable. AIso. irr 'oorc P[-C lirrrltats. the preset
timc value is lixed lirr the lunctionchosen lilt cxatnplc.5 'tcrlnd tittler. I0 secotld titlcr.
ancl so on.
Figure 9-2c illu\lrutes a special casc \!llen lhc cnable itnd le\cl uc tu,' \cplrxte in-
puts rather than u conrtnon single irtput. This conligurlli(rll c n hc tl\cd ti)r speciitl progrilnl
requirenrenls when the arrangenrent is arailable. The contisuration ancl tinling diagrant tbr
an Allen-Bratllev PLC is illustrated in iigtrrc 9 ]d.
Two other tintcr lirnctions lre included in sonte P[-Cs: TINIE DELAY-ON and TIME
DELAY-OFF-. Their lirnctions rre shown in tigtrrc 9-1e ancl l.
An added help in dehning tinrer c(nlact \tatus is shoun in hgur.c 9-3. There are
three slates in a tirring cycle: ( l) the initial or resct strtc. (2) the state during timinS. and
(3) the state a,jer tirning is cornplete. A \Ystcnr ot X lirr.on and O lirr off is normrlly used.
The exanrples illLrstrate this convention. In sontc slsletns a I is uscd instead ofan x to
indicatc contnct closed.

TIGURE 9-3 KEY:O Otl X-On


Sequcncing Chart
Resel During Timed
Status Timing Out Convention
Open Open Closed o ox
Open Closed Open o X o
Closed Open Closed x o X

Etc....

X Contact Closed
-
O Contact Open
-
150 PLC TIMER FUNCTIONS

9:3 EXAMPLES OF TIMER FUNCTION INDUSTRIAL


APPLICATIONS
Some commonly used timer functions are:

Example 9 I On delay. Output B comes on at a specific set time after output A


turned on. When A is turned off. B also goes off.
Example 9-2 OfT delay. Both A and B have been turned on at the same time. B
are in operation. When A is turned off, B remains on for a specilic
time period befbre going off.
Example 9-3 Limited on time. A and B go on at the same time. B goes off
specinc set time period, but A remains on.
Example 9-4 Repeat cycling. An output pulses on and quickly off at a constant
preset time interval.
Example 9-5 One-shot operation. Output B goes on for a specified time after output
A is turned on. Output B will run for its specified time interval even if
A is tumed off during the B timing interval.
'Example
9-6 Altemate on and off of two outputs. An example of this timing appli-
cation is two alternately flashing signal lights. The time on for each of
the two lights may be the same, or the two times could be set to
different intervals.
Example 9 7 Multiple on delay. Two different events start at different nme intervals
after an initial \taning time reference poinl.
Example 9-8 Multiple offdelay. Two different functions remain on for two different
time intervals after a process is turned off.
Example 9-9 Interval time within a cycle. We may require that an output come on
7.5 seconds after system startup, remain on for 4.5 seconds, and then
go off and stay off. The interval would then be repeated only after the
system is shut off and then turned back on.

There are other timing examples we could illustrate as well; however, these nine
examples are representative of PLC timing capabilities.
Now we give examples ofeach of the nine listed timing systems. In most cases, each
example is illustrated in terms of an industrial problem. Each example includes a diagram
showlng time versus output on--off status. The time-status diagrams include the X and O
designations for reference.

EXAMPLE The first example is th€ simplest form of time delay. For a grinding operation on a metal
9-l part, the coolent flow on the part must be on for an interval before the grinding process
starts. When the process circuit is turned on, the coolent motor (CM) is tumed ON. Eight
seconds later the grinding process (GM) starts. Both rolay logic and PLC programs for this
process are shown in figure 9-4. In subsequent examples, only the PLC diagrams will be
shown.
EXAMPLES OF TIMER FUNCTION INDUSTRIAL APPLICAIIONS l5l

Relay Logic
Elementary Diagram Connection Diagram

8 Sec. L2
LI L2
SW1

IDR L1

CM :*2* .L
L1
2 *
LR
c GM
GM 2 TDB
TDR 1
2
t--<

PLC Loglc
Screen Pattern Connection Diagram

cR0017
lnput Output
1N001
Com Com

-v*
A (CM) 1 17
2 P 18 t- CM
3 L 19
TS 4 c 20
cR0018 21
cR0017 22
6
B (GM) 7 23
8 Sec.
I 24 GM
cR0017

Count
HROOl I

Timing Diagram

LT1-CR0017 On o x X
ofi 8
sec

On o o x
LT2-CR0018
off I
I

sw1 tN00 sw1-tN00r


On olf

FIGURE 9.4
Example 9-l: TIME DELAY-ON
PLC TIMER FUNCTIONS

The sequence for this example is as follows:

l. When the switch I (IN 001) is closed, CM goes ON.


2. Eight seconds later GM goes ON.
3. When the grinding is completed, opening switch I tums CM and GM off.

EXAMPLE The second example is an off-delay circuit. A motor and its lubrication pump motor arc
9-2 both running. Lubrication for main motor bearings is required during motor coast_down.
After the-main moror is shut off, the lubricating pump remains on for a time corresponding
to coa$t-down time. In this example. a lubricating pump remains on for 20 seconds
after the
main system is shut down. Figure 9-5 shows the required program.

1N001 CROl7
sysrem on Motor

l___l TS
tN001 cR018
llme timed out Preset Logic
when motor 20 Normally timed out -
is otf tN001
Reset to O when motor
starts
Times to 20 when motor
Reg is turned of,
Otf/Unseal HR161 t

1N001 CRO18 cR019


Syslem on Fl Lubrlcallng Pump
CRO19
Lubricating
Pump Scale

nmlng Oiagrsm

Output 17 On o x o
oft
Logic 18 On
orf x o x
I _lzosec. ll-
Output 19 On o x o
oft tN001 tN001
On oft
FIGURE 9-5
Example 9-2: TIME DELAY-OFF

>
EXAMPLES OF TIMER FUNCTION INDUSTRIAL APPLICATIONS 153

tPI_u The third example involves two parts. The frrst Part is for a single time interval; the second
is a multiple time interval example.
Example 9-3-l is for a wood sawing operation. The sawing operation takes 4.6
seconds. After the sawing takes place, a blower to blow away the sawdust is to keep run-
ning untit the operation is tumed off. Figure 9-6 shows a program for this where both the
saw, Output A, and the blower, Output B, go on at the same time. The saw, OutPut B, goes
off after 4.6 seconds. The blower, Output A, continues to run till the system is turned offby
IN001 and IN002.
Example 9-3-2 is for a package dual stamping operation. FiSure 9-7 shows a pro-
gram for this where stamping times of 8 and [4 seconds are required. when the package
arrives in place, IN001 is actuated and stops the conveyer (circuitry not shown).The end is
stamped for 8 seconds, output M, and the top for 14 seconds, output N. Turning off IN00l
and IN002 releases the package to continue along the conveyer.

CRO2O
1N001 I
9 3 l: One Output. Time
Oulput A
On at Start
TT
tN001 cR021
Run Presel Logic
046 Time is
rN002 4.6 sec.
Enable H
Reg
HRO53

TT
cR021 cR022

H
1N001

Output B

Timing Diagram

ln l/Output A On o x o
ofi
On
LogidTT ofl o x
e 4.6 sec. +r
On o
otf
o x
CR2ZOutput B I

tN001 lN00l
On ofi
t54 PLC TIMER FUNCTIONS

flGUnE 9-7 cR0016


tN001
Example 9-3_2: Two Outputs, Trme Output
Ioterlals On at Start L
TS
rN001 cRo17
Run Preset Logic
008
tN002
Enable

Beg
HBO53

tN001 cR017 cR018

) Oulput

rN001 cR019
Presel
Bun Logic
014
tN003
Enable

Reg
HBO54

tN001 cFr019 CR2O

--4 Outpul
N

Timing Dlagram

L
On o
of,
o ixoi
On l;:81 I

off
o x o
On + 14 Sec. ----r
N
ofl tN001
tN001
On ofi

EXAMPLE The fourth example is a pulsed timer. In a paper mill, as finished paper comes out of a Paper
94 machine to the dnished roll, a rotl number is to be printed on one edge at intervals
lt is
determined that the number should be printed once every l2 seconds' The PLC circuit
shown in Figure 9-8 will produce the required pulses to actuate the high-sPeed
print head'
The timer Tb13 is set at 12 seconds. When the paper machine is tumed on, IN005 closes'
With the timer input IN005 on, the timer runs for 12 seconds' After 12 seconds, the timer
EXAMPLES OF TIMER FUNCTION INDUSTRIAL APPLIC ATIOn-S 155

T'IGURE 9-8 T013


tN005
Example 9-4: Pulse Repetitive Timer
Presel
12

Reg
T013
oR11
-).{-

Timing Oiagram

o 2 sec 24 sec
I .I

IN

Scan
Ime
Output
T0r 3 o I
X
o
x
o

Soes on, its output actuates the print head. The timer then after one scao immediately shuts
itself off through the opening of a T0l3 normally closed contacr in the timer enable line.
Once T013 goes off it resets the enable contact to closed and the l2 second timing cycle is
repeated. When a paper roll is competed and the machine is shut down, IN005 is shut off.

MPLE The fifth example shown in Figure 9-9 is a,,one-shot" system. An alarm is to sound for
17 seconds after a machine is started to alert personnel in the area that the machine has
been started. The alarm goes on when the machine is started. The alarm says on for
17 seconds, eyen if the input is tumed off during the l7_second timing pe;iod. The
machine could be coasting down. IN00l I must be opened to reset the system.

f,XAMPLE The sixth example is an altemating two output system shown in Figure 9_10. For example
,4 you have a waming light system on a machine to indicate it is running.
A single tight on or
a single flashing light is not deemed sufficient. you want two alte;ating lights. Outputs
CRll and CRl2 control the two red lights. As shown, the two lights altemate every l/Zor
5 tenths of a second for the timer in tenths timers. To change the times to other equal or
none4ual times, reset the C.V. values in the timer functions. IN00l is the master on/off
control-
156 PLC TIMER FUNCTIONS

cR0030
tN001 rs31
l-f--.1
c80030 I
I

Syslem
-+ cR0030
Presel
0017
TS0031

Resel

tN0011 Actual
HR0107

cR0030 TS0031 cR0040


Oulput
(Alarm)

Tlming Diagram
lnpul-On
tN001 Or+ I

Or
ofl
tN0011 otf-Timer Resets-c80030 ofi
--]
cRoo3o I

*17sec..-l I tNool1 otl-Resets rmer

c80031

Oulput
(Alarm) ---l
tN001
On

FIGURE 9-9
Example 9-5: One-Shot Timer Operation

EXAMPLE The seventh example is for a time delay on for two outputs with respect to the start of a
9-7 sequence. There are two ways to accomplish a time detay on, both of which are shown in
figure 9-11. In the diagram on the left, both time intervals start at the same tim€ and one
delays 7 seconds, the other 12 seconds. The diagram on the right accomplishes the same
thing, but chains the timers. The second time delay is accomplished by adding 5 seconds to
the first 7 seconds, for a resulting time delay of 12 seconds. Multiple time delay on can be
accomptished by appropriately adding more timers.
An industrial example ofthis process would be that a metal bar is held in a fixture and
shaped by three hydraulic Press operations. Close IN00l to start. Hydraulic Press A,
CR017, presses in and stays in the pressed position. After 5 seconds, a second hydmulic

E
EXAMPLES OF TIMER FUNCTION INDUSTRIAL APPLICATIONS 151

9-10 TT259
9-6: Altemate Flasher
tN001 TT260
Enable J c.v=s

1N001 TT260
-1 HB3

1N001 TT259 TT260

JH c.v. = 5

tN001 TT259
JH HR4

lN00r TT259 CB11

--tH LightA

tN001 TT259 cR12


-1 Light B

Tlming Dlagram
.5 Sec. 1.0 sec .5 Sec.
lt
Logic TT259
On

ofi
I
lr-
I

On
Logic TT260
orf
it

On
udn A cBlr
o x o
ol'
On
Light B CR12 X o x
off

press actuator B, CR0l8, presses in from another direction and holds position. Finally, a
third press actuator C, CRO19, comes in from a third direction and holds position. Opening
IN00l release all three presses so the part may be removed. For three or more time delays,
contiflue to use more cascaded additional timer functions.
158 PLC TIMER FUNCTIONS

Output 018 energires atter 7 sec. and 019 atter 12 sec. (5 more) atter 1N001 is energized

tN001

1N001
Preset
cR017

TS
CRO18
HH 1N001

f--1 Preset
c
TS
18

007 007
I rNoo2 I - tN002
l--_-lr------l Reg
Ol
Beg
HR1O1 HB1O1

TS TS
rN001 C 19 cR018 cR019
t___Jt_J Presel Preset
012 005
tN002 rN002
Reg Beg
HR102 HR102

nmlng Ohgrum
1N002 is the enable/reset input.

On
CBO17 r- Reset by 1N001
ofi
On
o
cR018 o +5 s€cs.--. x
o,tf
Both reset by 1N002
On
cR019 o <- 12 secs. + x o
otf I I

rN001 N001
On otf
tN002
otf
FIGURE 9-11
Example 9-7: Dual On Delay-Ttvo Schemes

EXAMPLE Dual time delay off is illustrated in figure 9-12. We use an actual application for
9-E illustration. When the lights are tumed off in a buitding, an exit door light is to remain
on for an additional 42 seconds. In addition, the parking lot lights are to remain on for
an additional 3 minutes after the door light goes out. The three outputs are identified in
the figure. For more delay off outputs, an additional repeat€d two lines of logic are
added as required.
EXAMPLES OFTIMER FUNCTION INDUSTRIAL APPLICATIONS 159

cR017
tN001
Lights-1N001 is closed
during plant operation
rS
CRO18
tN001
Preset Doo. Logic-Normally On
045 (Timed Out)

tN001
Reg
HRO75

L*oo, "q'
"^,r-
f=r-tH) Door Light

CRO19
TS
CRO2O
tN001
Preset Parking Lot
0225 Logic-Normally On
(Timed Out)
tN001

l---+- Beg
HRO76

CR021
1N001 cB20
r------1 t--'r-l Parking Lot Laghts

cR021

Timing Diagrsm

Plant Lights CR0017 O x o

Door Light O x 45 sec

Parking Lo( Ught O X + 225 sec o


I

tN001 INOO
Closed Opened

FIGURE 9-I2
Example 9-8: Dual Off Delay
160 PLC TIMER FUNCTIONS

FIGURE 9-I3 cR017


tN001
Example 9-9: Embedded Interval
System
Timing
TT
tN001
cR018

Preset Logic
087

tN001
Reg 87 tenths is
HRO11 equal to 8.7 sec.
TS
cR019
tN001
Preset Logic
016

tN001
Beg
HRO12 I

rN001 cR018 cR019 cR020


Vacuum
Pump

Timing Oiagram

On
System
o + 16 sec. + X o
{rNo01) off

Vacuum On a7 *7.3
sec, sec
Pump oft
o o x o o
001 N00

,IXANTPLE The ninth example illushates a timed interval. The timed interval starts a specified time
9-9 after a process is tumed on and continues for a specified time. An examPle would be a
process where a vacuum pump is required to be on for an interval during the process.
Figure 9-13 show a program where the vacuum pump, CR020, goes on after 8.7 seconds
and runs for 7.3 seconds (16-8.7 seconds). The overall system, CRO17, continues to run
after the time interval is completed.

94 INDUSTRIAL PROCESS TIMING APPLICATION


The following problem requires the use of multiple timing programming as weli as
contact/coil logic. It consists of a single, operational, heat-treating machine. The station
caries out a surface-hardening process on a steel ring. Hardening is accomplished by
INDUSTRIAL PROCESS TIMING APPLICAIION l6l

heating the steel riog to a high temperature, then immediately quenching it (cooling it very
rapidty). The metallurgical result is a relatively hard surface on the steel ring.
The heating is done by a noncontact induction heating process. A high curent in the
circular coil around the outside of the part induces high circulating curents in the part. The
part therefore heats up very rapidly. The coil has cooling water circulated through its outer
half to keep the heating ring from overheating or even melting. The quench is then done by
spraying cotd water on the part. The quench water is PumPed into the inner half of the in-
duction coil. Spraying the part with cold water through the many holes in the inside of the
coil results in fast cooling, which produces a case-hardened surface.
A mechanical layout of the process statiol is shown in figure 9-14. The processing
sequence of this operation is as follows:

l. The master pushbutton is deFessed, tuming the system on.


2. The part is placed on the mandrel.
3. Both left and right start-up buttons are depressed.
4. At this point, or at any other time, Pushing any stop button stops all processing
action.

Holes on HeaVOuench
inner face Part Position
lor quench spray LSU Hollow
Ouench -Heating coit
Water t/ Cross Section
Cooling
Waler o c
-t

Up/Down Mandrel
/-
LSP P
I <- Part

LeL Right

Oup oup
Syslem
Oon
p. ODn

Oon Pneumatic
o off Cylinder
Up
Gravity/SpringL
Return
I
L

FIGURE 9-14
Heat/Quench Station Layout
162 PLC TIMER FUNCTIONS

5. The part is raised from bottom to top by pneumatic air action. A solenoid
supplies this air to a pneumatic elevating cylinder. The lowerlimit switch
b€ actuated before the part will rise. Lowerlimit switch actuation indicates
there is a part on the mandrel and that the mandrel is down. Note that the
switch opens as the part leaves the bottom position.
6. The mandrel makes contact with a limit switch at the top of the travel.
7. Heat comes on for [0 seconds and goes off.
8, Quench comes on for 8 seconds and goes off.
9. The part retums down by gravity and spring action. The upperlimit switch
comes inactivated when the mandrel starts down.
10. The pan and mandrel reach the bottom. The down-limit switch is again
I L The system should reset.
12. The pan is removed.

Some optional features not included in this program are:

o If you assume the heat generator and both water pumps are on, interlocks could
added to insure they are running throughout the process.
- The same ring part could be processed two or more tim€s. We could require
ring to be removed after step 12 before resetting takes place.
o Is proper temperature reached? A thermocouple sensor could be incorporated to
monitor temperature.
J Manual controls for setup could be added. These are Up, Heat, and Quench.
! Safety features could be added, such as a safety shield that lowers during heat.
Where does the process restart after intemrpted power is restored?
D Other features as required.

The next step is to assign PLC register or address numbers to the various inputs and
outputs.

Inputs Outputs

0001 Master Shop m19 Solenoid Valve-Up


m02 Master Stan 0021 Heat On Contactor Coil
0003 I-€ft Stop-Up 0f.23 Quench Spray Water Solenoid
0004 l€ft Stan-Down
0005 Right Stop-Up Options
0006 Right Stan-Down 0017 System On Pilot Light
0007 Limit Switch Down mr8 Machine Onrup Pilot Light
0008 Limit Switch Up

A ladder diagram to carry out the process is then developed, as shown in figure 9-15.
The next step is to draw the connection diagram for the PLC. There are eight input
connections and five output cornections, thre€ to process actuators and two to pilot lights.
The connection diagram is illustrated in figure 9-16.
The final two developmental steps ar€ to program the PLC for the proccss and make
modifications as required.
INDUSTRIAL PROCESS TIMINC APPLICATION l6J

Sequenc€ cRo17
tN001 1N002
Start (lN0O2) Ssals Syslem On
System On
cR017 Optional
lnterlocks
cRo18
cR017 tN003 tN005 1N004 1N006 1N007
- ,
ace (1N007) Closes Run
>Jstr Up (1N004 & 5)
cR18
qun (C8018) On

cR18
4-+- cR2.1

cRo19
Up Solenoid On Up

TS
rN008 cR020
HaatTime Preset HeatTime
10 sec. 10 sec.
cR18
Reg.
HRO37

tN008 cR20 cR18 cR021

H€at Hfl4 Heat

TS
cao22
cn20
Ouench Tims Preset Quench Time
8 s€c. I sec.
cR18

HRO3O
c8023
cR20 cB22
ouencrr f---.1 f----l Quench

TS
ca22 c8024
Reset Preset /1_1 Ofl-Down
1 sec,
cR18

HR04O

IIGURE 9-15
Heat/Quench Machine Program
t64 PLC TIMER FUNCTIONS

Com Com
o-+2 1

2
17
18
17
Master
Hl 3 19
SloP 18 Run
4 20
Start 21
o----------+ 4 6 19
Loft
H3 7 23
Stop I 24
Start I 25 21
o.+6 10 26
Rioht 27
b o."*5 11
12
Stop 13 29
14 30
LSU t5
8 16 32

LSD
o+7
FIGURE 9-16
Connection Diagram for PLC Module, Inputs, and Outputs

TROUBLESHOOTING QUESTIONS
The PLC has been programmed to operate as shown in the figures referred to. Howevet the dlrcuit
has the malfunction(s) noted. What misprogramming or other factor or factors could cause the mal-
function?
TS 9-l Refer to the figure 9-4 (example 9-l) PLC circuit.
l.
The timer times out in less than I second.
2. The timer will not reset when you deenergize IN0OI.
TS 9-2 Refer to figure 9-5 (example 9-2).
l.
The lubricating pump does not starl when the motor stalts.
2. Thc lubricating pump goes off at the same time as the motor.
3. The lubricating pump never goes off.
TS 9-3 Refer 10 figure 9-7 (example 9-3-2).
l.
Both outputs go on after 8 seconds.
2. The timers will not reset.
3. Both outputs go on and stay on.
4. Neither output will So on.
TS 9-4 Refer to figure 9-8 (example 9-4). The pulse circuit works once aod stops,
TS 9-5 Refer to figure 9-9 (exampte 9-5). The output goes off after 17 seconds, then comes back on
immediately for l7.morc seconds, and repeats this pattern.
TS 9-6 Refer to figure 9-10 (examplc 9-6). Each light ffashes once and tfte system stops.

L
EXERCISES t65

TS 9-7 Refer to figure 9-11 (example 9-7).


l.
The second output, CR0l9, does not go on.
2. Only the first timer resets.

ES
Write a PLC program for these exercises, ins€rt them into a PLC, and test the programs for correct
operation.

1. A timer is to tum on a fan switch 8.6 seconds after a wall switch is tumed on. If the wall switch
is tumed offduring rhe 8.6 second time interval, the timer is to reset to zero seconds, so that whcn
the wall switch is again turned on, the delay is the full 8.6 secolds.
2. when a switch is tumed on, C go€s on immediately and D goes on 9 secoods later. Opening the
switch tums both C and D off.
3. E and F are tumed on by a switch. when the switch is tumed off, E goes off immediately. F re-
mains on for another 7 seconds and then goes off.
4. G and H both go on when all input is energized. G turns ofl after 4 seconds. H continues running
until the input is deenergized. Tuming input off at any time tums both outPuts off.
5. Two pulsers stan at the same time, Pulse output J is to pulse €very 12 seconds. Pulse output K is
to pulse €very 4 seconds.
6. When L is tuned on, M is togoon II seconds later. M goes on after ll seconds, no matter how
long L is tumed on.
7. A. Two lights are to flash on and off at different intervals. One is on 5 seconds and off 5 seconds.
The other is on 8 seconds and off 8 seconds. B. Two lights arc to flash altemately, one for 5 sec-
onds, one for 8 seconds.
8. There are four outputs: R, S, T, and U. R starts immediately when an input is energized. S starts
4 seconds later T stans 5 seconds later than S. U goes on 1.9 seconds after S. one swirch nrms
all outputs off.
9, Repeat exercise 7 for tuming off delay oo. S goes ofr4 s€aonds after R. T goes off6 seconds after
R. U go€s off 2.5 seconds after S.
10. An output pulse, Y is to go on 3.5 seconds after an input, w, is tumed on. The v time-on ioter-
val is to last 7.5 seconds only. V is to go on again 3 se4onds later for 5.3 seconds.
ll. There are three mixing devices on a proccssing line: A, B, and C. After the process b€gios, mixer
A is to start after 7 seconds elapse. Next, mixer B is to staft 3.6 se{onds after A. Mixer C is to
stafi 5 seconds after B. All then remain on until a master Enable swirch is tumed off.
12. when a start button is depressed, M goes on. Five seconds later, N goes on. when Stop is pushed,
both M and N go off. In addition, 6 seconds after M and N go off, fan F, which had Feviously
been off goes on. F rcmains on until the start button is again depressed, at which time it goes off.
13. A wood saw, W, a fan, F, and a lubrication pump, P, all go on when a start button is pushed. A stoP
button stops tIrc saw only. The fai is to run an additional5 s€conds to blow the chips away. The lube
pump is to run for 8 seconds after shutdown of W. Additionally, if tlle saw has run more than one
minute, ttre fan should stay on indefinitely. The far may thcn be turncd ofrby pushing a separare far
rcset button. If the saw has run less than one minute, th€ pump strcnld go off when thr saw is tuned
off. The 8-s€cond time delay offdoes nor take plc for a nrnning tirE of less ttlan 1 minule.
l6e PLC TIMER FUNCTIONS

14. An output K is tumed by closing a momentary pushbutton switch IN0O7. Another output, I-
to go on 8 seconds after K goes on. L is then to .emain on for an interval of 19 seconds and
shut off.
Additionally, at times, L is to be turned off and back on, during the lg-second
time. This is accomplished by closing another momentary pushbutton switch, IN008, be
IN00? is activated to tum on output K. The optional imbedded off time during the L 19-
interyal starts 4 seconds after l9-second interval has started and continues for 6 scconds.
The entire system is reset by a momentary pushbutton switch IN006.
To make sure that IN0O8 can not be activated unless IN007 has been activated, add
interlock.

h
PLC Counter Functions

OUTLINE
10-l Introduction ir l0-2 PLC Counters tr 10-3 Examples of Counter Function Industrial
Application

OBJECTTVES
At the end of this chapter you will b€ able to
tr Describe the PLC counter functions.
tr List some of the major counting functions used in circuits and processes.
o Apply the PLC counter function and associated circuitry to process contlol.
o Apply combinations of counters and trmen to process control.

167
PLC Counter Functions

OUTLINE
10-l Introduction tr 10-2 PLC Counters tr 10-3 Examples of Counter Function lndustrial
Application

OBJECTTVES
At the end of this chapter you will be able to
: Describe rhe PLC counter functions.
D List some of the major counting functions used in circuils and ptocesses.
o Apply the PLC counter function and associated circuitry to process contol.
o Apply combinations of counters and timen to Process coDtrol.

161
16E PLC COUNTER FUNCTIONS

10-1 INTRODUCTION
PLC counters have programming formats which are similar to timer formats. One counter
input fumishes count pulses which the PLC function analyzes. Another input usually carries
out Enable/Reset. Altematively, there can be separate inputs for Enabte and Reset, depending
on the application requirements. Conventional counters replaced by the PLC counter function
include mechanical, electrical, and ele{tronic ty,pes. Typical examples of these counters can
be found in various manufacturers' manuals and are described in yarious other texts.
Most PLCs contain both up and down counters which function similarly. Some
PLCs also include a combination up/down counter in one function. Others contain special
high-speed counters for high-frequency counting capability. The up counter counts from
0 up to a preset count, where some indicating action takes place. The down counter starts
f.om the preset number and counts down to 0, where the indicating action takes place.

t0-2 PLC COUNTERS


Figure l0-lshows four configurations of typical PLC counter functions. Figure lO-lal is
the basic PLC counter function, which is the same for up and down counters except for the
designation of UC or DC. Figure lo-lal is one format, the block format, and is the one we
use in the chapter The count at which the counter output is to go on is entered into the preset
space. The count can be a constant as shown, 21, or can b€ a register which has a varying
value from the process. For the up counter, the count starts at 0 and increments by I each
time IN00 I is pulsed on. When the preset value is reached, the output, CR I 7 in our example,
goes on. As the count goes on beyond the prcset value, the output stays on. Opening IN002
at any time resets the counter to 0. The down counter operates in a similar manner. The count
starts at the preset value and increments down by one each time the input IN001 goes on.
When the count reaches 0, the output go€s on.
Figure l0-la2 shows a coil format found in some PLC models. The counter output ;
is intemal logic. The counter, 32 in our example, counts to 2l and tums on. To actuate an fE
f
output, a program line uses d contact from the count logic, 32, to actuate the output, 74.
Some PLCs contain an additional up/down counter such as that shown in figure l0-lb.
There are three inputs: one for up counts, one for down counts, and an enable/reset input.
The up/down counter can be used as a single function when the process uses an up and a
down counter in tandem. The preset can be set to a value as shown or can be set at the
maximum count if you only wish to observe the net count in the designated register,
HRl02. One precaution when using this function is to know whether the function will
accept negative numbers in case the net count goes negative.
Some PLCs contain a high-speed countet as shown in figure I 0- I c. Refer to the PLC
operating manuals for the frequencies at which their high-speed counter operates. A
number of auxiliary functions work with these counters. Again, see the PLC manuals for
the system setup.
In some applications, you may wish to stop the count for a time without it resetting
to 0 and start counting again later where the count left off. This is accomplished as shown
in figure lO-ld. The Enable and Reset inputs are seiarate for this counter function.
FF.
ON
E bE
ol e
oo
I E.E
o
U8 PE
t?5 ccI! ET
&I IT I 5E
E;
o0 s5
ao
c ]E
o lll
3
N o
o q
OJ o
e t! !
z 2 z A
f
z c.
tt
T=T T
l!6
EOE
B€
ofitr 3

,i=ofi E

E
E 93 (! a .qr - E
8.28
o:t .., g
iiE=E E6 p= t.
E id= E

B;gEA P'5; H
3:eE OF.
dE.9 6€ o p -o
F, I I ['5'
I o
c
o
c
,o
o o=l
l
C'
E I , (! t c)
tt
o AI
llJ io o-

6 6 o!
o-
E o E tte
Es
IL
&EI tto
o o .9
o -
f
6 ol4
oE-9
I
a6
=o
o al zo
(\t

z
a
G

8 Iz EEE z (\t
z 4
cr
9
-9
-o

IJJ
-r.
tr o TE
o
!
.cl
-9
6 o c.9
uJ
OQ
IJJ
o frA
170 PLC COUNTER FUNCTIONS

Example CTU Ladder Dlagram

l:012 CTU

COUNT UP CUF
10 Each time the input goes false to l.ue, Counter :0
10-:
lhe processor increments the counter by 1
Preset 4 DN)
Acrum 0

Tells when the counl is reached (ACC > or = PRE) O:020


f
L
DN 01

C5:0 Tells when lhe counter overflows +32, O:021

OV 02

l:017 Resel lhe counler C5:0


f
L
RES )--
12

Example CTU Timing Diagram


Counter preset : 4 counls
EXA
Flung condition that
ON lo-l
conkols counter OFF

ON
Count-up enable bit
OFF
I
I

ON I
I

Rung condition I

lhat controls OFF


I
reset instructaon
I
I
ON Corm
Done bil I
OFF
ON
Output instruction
I
bl
on rung controlled OFF
by counter
I
I
3
lal
I
I 2
Counter
I 1 0
accumulated value 0

e Allen-Bradley Counter Formal nct


Etr
FIGURE l(lf (continued)
EXAMPLES OF COUNTER FUNCTION INDUSTRIAL APPLICAIION t7l

Figue l0-1e illustrates the Allen-Bradley up-counter function along with a functional
timing diagram. The Alten-Bradley down-counter function is similar.

l0-3 EXAMPLES OF COUNTER FUNCTION


INDUSTRIAL APPLICATIONS
We show six examples ofthe use of the PLC counter' The first is for a basic application for
counting events. The second and third examples use more than one counter for process
control counts. The fourth through sixth examples use the counter function in conjunction
with the timer function, which was described in chapter 9.
Example l0-t
Suaight counting in a process. The counter output goes on after the
set count is received by repetitive pulses to the counter input.
Example 10-2 Two counters used with a common register to give the sum of two
counts.
Example lG-3 Two counters used with a common register to give the difference
between two counts.
Example tG4 A process where a timed interval is started when a count reaches a
preset value.
Example l0-5 A process where a count of events is to start after a fixed time
interval.
Example lG{ A process where a rate is determined by dividing a count by a time
interval.

EXAMPLE Figure 10-2 itlusrates the fundamental use ofa PLC counter After a cenain number of counts
r(Fl occurs, the output goes on. The output can be usod to energize an indicator The outPut status
could also be utilized in the ladder diagram logic in the form of a contact. The counter function
is shown for either an up counter ot a down counter They both perform the same function in
this illustration. Either counter will function if is enabte line is energized. After the count input
receives 18 pulses, dre CR (Contol Relay) Function output will energize.

UC DC
cR021 cF.022
tN004 tN008
Count Presst Count Preset
018 018
tN006 tN0
Enabl€ Reg Enable Beg
HBO37 HR046

LJp Counter Oown Counter

FIGURE 1(L2
Example lG-l : Basic PLC Counter Operation
t72 PLC COUNTER FTJNCTIONS

EXAMPLE Figure lG-3 illustrates the use of a combination of two counters. SupPose that we wanted
t0-2 an output iodicator to go on when six of part C and eight of part D are on a conveyor. This
circuit would monitor the proPer counts. IN002 and IN003 are proximity devices that pulse
on when a part goes by them. Note that the circuit would not indicate more than six or eight
parts; it would only indicate when there ale enough pads.
To repeat the process, turn IN001 off to reset the system. Then reclose IN001.

EXAMPLE The third example, shown in figure lH, concems keeping track of the net number of parts
r0-3 on a conveyor. The number of parts going on the conveyor is counted by one proximity
device's count. The number leaving the conveyor is counted by a second proximity device's

FIGURE 1O-3 To
1N002
Example 0-2: Dual-Counter
I

Application o
o Conveyor
To
tN003
cR017
tN001
System Master Relay
UC
tN002
cRo18
Part C Preset Logic-6 Count
006 (c)
tN001
le
Reg
HR075
EF
5c
UC
cRo19
Parl D
tN003
Preset Logic-g Count
(D)
l$
008
1N001

Reg
HRO76

I c8020

Pilot Light lndicator-


will be on when
at least 6 of Part A
and 8 of Part B
have ontered the
conveyor.
-9
o
E
886 ag 8
.E; 6 Eq9
o I '! **E
o
58E
i. @
o.= E m
l-
o
E
o CE
o 5Ea aa q
-q otE I
z- o
o
E
(ECC 3 o
o. I o
g I
=E cro z (
a
N I
I Iz Iz i (L I*
= =
.o
o
t:
z.E
I
oo
oc
l]
S,3 2
I
o-
t
o

3sB
ES:
o g9
E I c
E: fd E,q 6 :oo
5 9-
E
a o 5
a EE; oo
E c o
!HE G
- :
o
<t N 6 z
o o^
]E
E
o o
8F 6
t,E
o €
a
q.
cDo oo E
$e CE IE I tE lc o
- o- - o
E
f (J
6
Y ..i

Iz zI I 8
z z8
ld,.

=
fr q)

1?3
174 PLC COUNTER FUNCTIONS

count. Each proximity device feeds information into its own counter function. The total net
count is kept in a holding register common to both counters.
A program using two counters, one up and one down, for this application is shown in
figure 1O-4a. An accurate initial count is needed. When startilg the operation, the number
of parts on the conveyor must be determined. This count number is programmed into the
common registe( HRl0l. It is normally necessary to put this count number in the down
counler as the prcset number. Then, any parts going onto the conyeyor pulse, the up counter.
The counter's register (which is common to both counters) will have its value increased by
one for each entering pan. Similarly, the parts leaving decrcase the common register's
count through the down countEr. The number value in register HRlol represents the num-
ber of parts on the conveyor We are assuming that no parls fall ofl the conveyor and none
are added along the way.
The up counter preset value is irrelevant in this application. It does not matter
whether the counter outputs are on or olT. The output on--off logic is not used. We have
arbitrarily set the up counter's prcset values to the maximum.
Ifthe PLC you are using has an up/down counter, the program shown in figure 10-4b
may be used. The operation is the same as for figure lG-4a.

EXAMPLE This example is for a timed process that occurs after a certain process count is rcached. EX-{.
l0-4 After a count of l5 from a sensor, a paint spray is to run for 25 seconds. Figure l0-5 shows lo-5
a program that accomplishes the count and time operatiol.

uc001
tN007 IXA
Count Count
15
Counter-Goas on
after a @unl
l}6
tN008 of 15.
Enabl€/a€s€t Beg
HROSI

TSOO2
uc001
Time Time fimer-Starts timing
25 atler UCoOI go€s
uc001 on. limgs for
Enable/Beset 25 sgconds.
R€g
HRO52

cR087
uc001 Ts002
Logic Spray-On lor 25
s€conds aftgr a
count ol 1 5 is reach€d

FIGURE 1(L5
Example l0-4: Count and Time Plogram
F,XAMPLES OF COUNTER FUNCTION INDUSTRIAL APPLICATION 175

Starts '--
lrmrng \ rs0008
tN001
Presel Comes on t hour
3600 (3600 seconds) after
rN003 1N001 closes.
Enable/Beset Reg
oR0007
Pulses
lor
DC0009
Counting tN002 TS0008
Presel Comes on a,ler
150 150 counts as
tN003 inpuled by 1N002
starting alter
Enable/Resel Beg
t hour.
oR0009

FIGI]RE I(H
Example l0-5: Delay ollhe Stan ofthe Counting Proccss

f[L\IPLE The fifth example, shown in figure l0-6, is for a deiayed counting period. In this process
DS we do not wish to start counting until I hour atier the process stans. A timer output contact
in the timer run line closes after the time period. The closure then enables the counter to
start counting input pulses. ,After a count of 150. the output comes on.

EL{}TPLE Hou' rnany parts per rninute are going past a certain process point? This cxample addresses
a-5 this problem. Figure l0-? is a ladder diagram scheme for obtaining the product part flow

TS0072
tN0027
Stan Tlme Preset Closing 1N0027
60 stans timing
tN0060 and counting.
Beg Atter 60 seconds
Enable/Reset
H80105 counting stops.
Pulses to
be Counted
uc0081
tN0027 TS0072 1N0061
Start Count Preset
9999 HR0106 contains the
1N0060 counl for 60 seconds-
the rate per minule.
Enable/Reset
To reset-open 1N0060
HR0106
8nd reset HR0106
to rc000".

FIGURE 1O-7
Example l(H: Rate-per-Time-Period Program
t-
176 PLC COUNTER FUNCTIONS

rate. The timer and counter are enabled at the same time. The counter is pulsed for each pan
going past its sensor, which is connected to IN0027. The counting begins and the timer
starts timing through its 60-second time interval at the same time.
At the end of60 seconds, the timer's count ladder line is opened by a normally closed
timer-output-related contact. Pulses continue but do not affect the PLC counter. The num-
ber of parts for the past minute are now recorded in counter register HR0l06. The part
count for the minute can be recorded manually or by a computer technique and will remain
in HR0l06 until IN0060 is opened and the counter and timer are reset. After IN0060 is
reclosed, the process starts over

TROUBLESHOOTTNG QUESTTONS
The PLC has been programmed to operate as shown in the figures refered to. However, the circuit has
the malfunction noted. What misprogramming or other factor or factors could cause the malfunction?
TS l0-l Refer to figure t0-2 (example 10-l). The countercounts to 1 and resets as the input goes on
and then off.
TS l0-2 Refer to figure 10-3 (example 10-2).
l. The pilot light never go€s on, even whcn the designated count is reached.
2. The pilot light never goes out.
TS I0-3 Refer to 6gure l0-4 (example l0-3).
l. As the process progrcsses, the counr displayed in HRl0l does not change.
2. The count displayed in HRlol goes negative.
TS 1G4 Refer to figure lG-5 (example lH).
l The spray goes on when the cootrol circuit is tumed on.
2. The spray does not go off after the 2s-second interval.
3. The spray never goes on.
TS 10 5 Refer ro 6gure 10-6 (examplc lG-5).
l. The count starts after 6 minutes, not I hour.
2. The counter does not count.

EXERCISES
Design, construct, and test PLC circuits for the following processes:

tr ore: For all chapter l0 exercises, assume that the input count pulses for each exercise come
frcm a singleextemal source and are inputted into a single ilput registef which is used in the
program.

1. An indicating light is to go on when a count rEaches 23. The light is then to go off when a count
of 31 is reached.
2. A machine, M, is to be tumed on either wheo count A goes up to I I or when count B goes up to
16. One stop button or switch Esets the enthe proc€ss.
3. A fan, R is to be tumed on wheD couot L goes ftom 7 down to 0 ard when either count M goes
up to 14 or count N has not gone all the way ftom 14 down to O. OIle switch or stop button resets
the entirE process.
L.Xt.:RCtSt-.S t17

4. A solenoid. S. is to Bo on $ he n count C g()cs rlp t(t J:, lrrd whcn e(tunl D g(Es dowlr lrorx ]7 x,
o. and $hen soun( E g(Es up k) L. I"urlhernx)rc, il'rollnt I- g$ts dou n l(rrn l7 to 0 ut irny lin)e'
the sr)lcnoid is to b! kcpt lirlnr (tpcrntirlg. Onl \top htllltnl rcrcl\ thc alltirc p()cess. in(llding lhc
vrlenoid's being otl.
t. Rcpeat erercise 4 excepl thll whcn ! g(Es fr)[l | 7 down to (t, lhe cntirc ptrcss is to trc rc*-l hy
a st{n-stop-s9itl systcu.
6. A boltling pro(ess lirr ll lnrltlss oPLl,,tcs as li)lktws;
B()ltles are sounlcd until all l1 art itt prt.itirnl lilr lillin!.
When in prshion in the cilrtor. ths lJ t\{llcr urc filled simultanc()ully lirr 6..1 rc,;ondr,
Alier lillilrg. thctg is a pnur( ()l'-l,t \er(nrd\ h)I ti]am (r rubridc,
l!
The caps rre then put.rn .rrld g(urldd ar thcy are inrt;rllcd,
A rolenoid thell pushcr lhe conrplctcd c;rrlon ol on (, il eonrcycr, The syritem il resel lirr a
lf
ne$ grup ( t(, he rcsta ed nunuully | (|l I : txlltlet t y a litnil s$ i{ch that indisatsr thul the sitrlon
ir oul of Ihe "till" p()sitiol irlrd on lhc conveyor,
7. A \ttating and hnnding sy$telr (S ) rcquiles a *pacer to he inscrtcd ( l) in il strck of panels lller
l-l shccls.re slllckgd. Atter 14 rnore (:tt tolol), thc rtrl
is to ht'tranded (B). Add sensors anr.l
rirunrcd output devicer. ar requirc'd.
t. Rclcr to r.'rcrcisc 7 rnd tldd thc litlkrying additi('nal $teps to the p(ress, Al'tcr hrnding iti clnr'
plcled. lhcrc is u !-seconrl rlcloy tir the bander to pull h.&k. Then. an idcltitication spray color
dor (1,) ir ttl he aIrplied k) the {ack, Spruy tinre is 4 s€conds.
9, Tra,o Icedcrcon\e)orr (Fl alrd F2) lbed a pan onto one nrnin conveyor ( M ]. A proxilnity devicc
ir al lhe end ofeirrh ler'rler conveyor, The proxilnity .levicc outpulr are ltd ar pulres kt cou[[er$.
Each counler lhcn showr ths count of p;rrtr being Put onto the mlin conveyor. ln addition. an'
(rther pnrxinlity dcvice at llrc st ol'lhc convslor pulscs in resgrnse to parts leuviog and theo
iends the pulses to oft)thcr courll!'f-
Dcvck)p a progranr to havc r single rsgitter thrxtring thB numher counter of Pqrt$ on the con-
veyor. Asrume th:rt the rcgister is initially'iel to lhe salne counl as the count (tfparts on the conveyor'
lO lht systcm rhown in ligure l0{1.
Pft)gram all autornatic conlrol li)r
when the on burlur ir purhed. a stacler (S) (tans sucking plyw(Ed shcets I posilion A
Stack height is eontr-olled h1' a P[.C counter tuncti()n. nol a ht'ight s€tt|'or. When I2 parts al ; ltacked.
lh9 c()nvcyor tCV ) gocs or and m()ter lh!' stiuk h) pr)\iti(tn B. r\ senrol is used to s()p th! jonveyor
t B, Al B. paint 1P) is lpplied lirr 1 2.5 seconds Atier ptlinling ir conlplc(e. the conveyor is resta(ed
rnanually. Thc conleyor lhen m()ves parls to poriti(tn C. Al posili()n C lhe 5tlck $ops autonatically
and lhe stack is rcntoved tnanudlly. The slop but()n slops the process any time it is depressed.
A\sunlg that only onc stack is on the conveyor at a lime. Add lintil switches and other-devicer' as
required-

Pooition B

Posilion A J Position C
On

oll
E Conveyor

FIGURE I(L8
Diagram lirr Exercise l0
I

178 PLC COIJNTER FUNCTIONS

11. A process has four inputs which arc connected to four PIrC counters:

I
A IN02l Up Counter
B IN022 Down Counter (prcset at 20)
C IN023 UP Counter
D IN024 Down Counter (pres€t at 25)

When A reaches 7 or B reaches 0, Output L is to go on.


When C reaches 6 and D reaches 0, Output M is to go on.
When both L and M are on, Output N is to 8o on.
Process master ON is INol l. Process master RESET is IN0l2.
fntermediate Functions

11 PLC Arithmetic Functions


t2 PLC Number Comparison Functions
13 Numbering Systems and PLC
Number Conversion Functions

__H
PLC Arithmetic Functions

OUTLINE
1l-l Introduction tr 1l-2 PLC Addition and Subtraction o ll-3 The PLC Repetitive Clock
tr 1l-4 PLC Multiplication, Division, and Squarc Root o ll-5 PLC Trigonometric and Log
Functions o ll-5 other PLC Arithmetic Functions

OBJECTIVES
At the end of this chapter, you will be able to
o Add and subtract numbcrs using thc PLC ADD and SUBTRACT functions.
o Explain and demonstrate how the PLC handles overflow and negative numbers for the ADD and
SUBTRACT functions.
E Explain the programming, operation, and utilization of the repetitive clock.
D Multiply and divide numbers using tbc PLC MULTIPLY and PLC DMDE functions.
o Find square roots by using the PLC SQUARE ROOT function.
o Describ€ the various FLC trigonometric and log fuoctions.
o Describe other major Pl,C arithmetic functions.
D Apply arithmetic functions to process control operations.

I&

ru
I82 Pt_(' ARtl Hi\tlrf t( t-t-rNC't-loNs

ll-t INTRODUCTION
l\'lost P[-Cs hare busic urithrnetic functions. Arilhnlctic linctions are sometimes designated
ls nlath lunctions. These basic tunctions-ADD. SLIBTRACT. MULTIPLY, DIVIDE, and
SQR(square root) insections ll 2and llJ.A program lbr performing these
are coveretl
Ilnetions (and others). conlinuously. the Repetitive Clock. is covered in section ll-3.
Corrliarrdrrrlr' is dclined as opcrating quickly in one or two scirn times between updates.
Lar-ser-capability PLCs have an extended number of udvanced arithmetic tunctions.
Section I I 5 illustrates the trigonometric and logarithmic functions tirund in most
arlvanced PLCs. Various other major advunced lunclions are covered in section I l-6.

tt-2 PLC ADDITION AND SUBTRACTION


Figure ll I shows ttre PLC ADD tunction. For ligure ll
la. it adds only when the enable
line changes tiom oll to on. The addition will not take place continuously just because Enable
is on. When enabled, the numerical value in the operand-2 register is added to the numerical
value i.n the operand-l register The resulting value then appears in the specified destination
register In nrany PLCs. operand 2 can be a number or the value in a designated register.
Figure ll
lb shows another tbrmal that operates similarly. The two numbers to be
added are entered in locatbns 30 dnd 3 I . The result of the addition then appears in locatitx
32 when the input l2l is energized. Figure Il-lc
shows another tbrnrat lbund on some
PLCs. You can add more than two numbers using one function. Otherwise you would have
to add two numbers and then add the third number to the result. requiring two lines of

FIGURE II_I 1N0065 A00078


PLC ADD Functbn Enable
Operand 1
(May be
180062
multiple contacts)
Operand 2
May be a constant HR0041

Destination
oR0013

a Block Format

121 030 031 032

05
tH"H"l<. a7 92 179

b Coil Format

121 030 031 032 033

05
f-["H"HGH.
62 12 47 121

c Multiple-Coil Format
l8.r
PLC ADDITIoN ANI) SUBTRACTI()N

progmm. Throughout the ensuing e\amples in lhis chaPtcr' $ c usc lhc b[)cl li)rtlral li)r the
ADD function and lilr the other lunctions shown.
When docs the output coil cotne on l ln sotrre PLCs its stutus is il'rclcvlnt' ln olher
P[,C systents. the coil's energizution indicates tcgislcr overllow o[ ncgilli\c rlluc' For
(('Llnlin!
overflriw. the coil tuly comes tln whcn the rcsulting xulnhel excecd\ lhc rcsi\lcl
capability: olhcrwise. it rettrains otf. For cxanlple. assunrc the dccinlill rcgi\lcl lilllit is
9999. lf youadd 6-1-1 plus 56ll. the sum. which cquals l2l l. is within lhe rcgi\lct linlil and

the coil will not conle on. The sum. l2ll. u'ill uppear in the dcstinalion rcgistcr" On thc'

other hand. the sum of tt973 plus lt6-j2 is 17.605. which cxcecds 9999' \o thc coil u ill corlre
(XX)'
on. In this casc. lhc dcstinalion register will read 7605. thc execss orel l0
Note that we are using decimal numbcrs throughout this chaplcr' Thc itrithnlctic
functions llso work lirr binury nuntbers and other numbering systcnls Yr)u tttitv chrxrse
ln\
numbering system, depending on the requirements ol your paniculxr P[-C nlodel. The only
precaution is to use the samc numbering systenr throughout thc urithtrletic function'
To tind out which registcr typcs. HR. OR. und so ()n. cutl be uscd its opcrunds con-
sult the manutlcturer's tr]anual lirr your PLC.
Figure ll-2 illustrntcs the ADD ftnction lilr two ex lllplcs Onc exurttple is tiu a
result less than 9999. and thc other is lirr a result greater than 9999

Befgre Enable Belore Enable

HR0075 H80075
0462 9642
orf HR0076 otf
HR0076
0327 3471

HR0077 I HR0077 I
Previous Value AD0030 Previous Value
AD0030
Enable Enable
Operand 1 Operand 1

HR0075 HR0075

Operand 2 Opeand 2
HR0076 HR0076
1
Destination

I
Destinalaon
ofi H80077
H80077

After Enable After Enable


On
HR0075 HROO7s (as long as
0462 9642 enable is on)

HR0076 HR0076
0327 3471

HR0077 .--- Sum HBOO77 - {13,113-10,000)


0789 3113 "
a Sum Under b Sum Over
10.000 10,000

FIGURE T I-2
Two Addition Examples
tE4 PLC ARITHMETIC FUNCT'ONS

A sample industrial problem for the ADD function is shown in figurc ll-3. TVo
conveyors feed a main conveyor. For soine reason we cannot 8et to the main conveyor to
make a count. The main conveyor count is dercrmined from the count of pans entering
from the otber two conveyors. The count on each feeder-conveyor is determined by a
counter (not shown). The counters on each feeder-convcyor are input-pulsed by a proximity
detector once for each part leaving the conveyors. The count of total pans entering the main
conveyor is then determined by adding the two feeder conveyol counts using the ADD
function, For illu$ration, we monitor the total count every 30 seconds. The input of the
ADD function is pulscd on and immediately offby pulsing the ADD function enable. The
count could be prjnted out as shown in figure I l-3 every 30 s€conds.
Note that this addition method is an alternatc solution to a similar problem in chap'
ter l0 using counters and a common registeL
The PLC format for SUBTRACT is the same as for ADD, and the function operation
is similar. For subtraction, operand 2 is subtracled from operand l. The resuh is found in
the destinatior register Figure I l-4 shows the SUBTRACT function'
For subtraction, we discuss the block formats only. As with additior, the SUBTRACT
function operates only when the enable line goes on. In some PLCs the direct answer will
appear. tn other PLCS, the coil status is significant for complete answer description. The coil
on-off operation for subtraction differ from lhat of addition. When the result is positive, the
coil is off and the result is found in the destination register. When the result is negative,
the coil is on and the resulting negative number value is found in the destination register'

Feeder Conveyor
A
Part Countor for Convslror A
Value Placed in HF0041

L,iain Convsyor

Pan Counl6rtor Convsyor B


Value Plac€d in HB0(N2
Feeder Conveyor
B

Printer

A00067
Prints
Enabl€ Op€rand 1 Tolal Every
Pulsed On Every HR004r 30 Seconds
30 Second8 (HR0043)
Operand 2
H80042

Dsslination
HFoojli}

FIGURE TI-3
Using the ADD Function for a Conv€yor Pan Count

F
PI-C ADDITION AND SUI-}]'R,\CTION llr5

rlctrR!: I l-.1 c80062 s80063


PLC SUBTRA('T tirnctirrn Enable
(May be Operand 1

HR0046
multiPle contacts)
Operand 2
May be a conslanl HR0051
Destination
HR0051

a Block Format

121 030 031


l

I 05
H"l-{"H 47 16

b Coil Format

Belore Enable Belorc Enable

HR0132 HRo132
8642 4621

HR0133 H80133
6218 ofl 7307 ofi
HR0134 HR0134
Any Previous Value Any Previous Value I
s80023 s80028
Enable Enable
Operand 1 Operand 1

HR0132 HR0132

Operand 2 Ope.and 2
H80133 HRo133

Oestinalion Destination
HR0134 H80134

After Enable Atter Enable

HR0132 HR0132
a642 ofi 4621 On

HRo133 HR0133
6218 7307

HR0134 HR0134
2424 2686

a Difference-Posilive b Ditterence-Negative

FIGURE II-5
Turr Subtraction Exunrples
1t6 PLC ARITHMETIC FUNCTIONS

Figure 1l-5 shows the function operation for both a positive and a negative answer.
The coil is off for a positive result and on for a negative result.
A possible industrial problem for subtraction is shown in figure I l-6. It is similar to the
addition example. In this example, the output count and only one input count are available.
One ofthe conveyor inputs is not accessible for some reason. To obtain the input A count value,
subtract the input B count value from the output count. The result is the A conveyor count. The
count is again determined by a 3O-second counting interval. The count is taken for 30 seconds,
used, and then reset to zero. Again, initializing is needed periodically for accurate operation.
Initialization figures the initial number ofparts on conveyor B into the counting results.
One useful function of the ADD and SUBTRACT functions is to set a range. For
example, there is an inspection system with a periodically changing base dimension and
periodically changing tolerances. The PLC can easily and quickly reset the dimensions
and tolerances. The preset dimensional values are transmitted to two specified pLC out_
puts. These output values are used to set the positions of an automatic gauging system.
In the example, the base dimension, or set point, is set at 6.250 inches. The altowable
tolerances chosen for this illustration are +0.025 and
-0.035 inch. Figure I l-7 shows the
range in graphic form.
Figure ll-8 illustrates how the settings can be accomplished by programming a
PLC. For three etemally fixed values, a PLC is not needed. Our system is valuable when
the dimensions are varying quickly as production varies. The set point is entered into

Fe€der Conveyor

A Conveyor Parts Counter

o Value Placed in HR0251

tr --------' Main Conveyor

Main Conveyor Countor


Value Placed in H80252
Feader Conveyer
B

Prinler

sB0123
Prints
Enable Operand 1
Pulsed Every Conveyor B
HRO252
Counts Evsry
30 S€conds
Operand 2 30 Seconds
HF0251

Destination
HR0255

rIGURE 11{
Using the SIJBTRACT Function for a Conveyor Count
PLC ADDITION AND SUBTRACTION 1t7

- 6275
/ taooot

1 1
H R0002 25

Sst
HR0001
I J
6250
Point

HR0003 -35

I
HR0005
6215
i/ots: Numb€rs are in mils (0.001 inch)
1 mil = 0.001 inch

FIGURE 1T-7
Graphic Representation of Dimensions

HR0001. HR0002 receives the upper tolerance value, and HR0003 receives the lower
tolerance value. When the circuit in figure I l-8 is enabled, the upper and lower limits are
calculated. They appear in HR0004 and HR0005, respectively.
To revise dimensions or toldrances, the mathematical values in HR000l, HR0002,
and HR0003 are changed. When PLC functions are reenabled, the new values appear

AO0124
cR0127 HR0001 HR0002 HR0004
Operand 1 Set Point + Upper Tolerance = Upp€r Umit
HR0001 6250 25 6275

Operand 2
HR0002
Enables
Oestination
HRoooll

sBor23
cRo127 HR0m1 HR0@3 HR0005
Operand 1 - Lower Tbleranca = Lower Limil
Sol Point
HH0001 6250 35 6215

Owrand2
HR0003

Destination
HR0005

FIGURE 11{
Pl,c Operation with Sct Points and Tolerances
I88 Pt.c ARTTH\,[: r r( l,r'N(-fl()Ns

I l(;t Ru l t-9 cR0043


cR0043 IIGU
Rcp.liti\L'( ltt(k ( ircuil
YUU

'^r cR0043
l-=* To circuil to be
continuously pulsed.
l

intntctliittcll'(on thc nc\l \citn) t thc P[,C oulpu(. Conrplring lhc aclu l dinre'nsions with
tltr' tt1t1tr antl lorr cl linrits u c hlr c scl is discusscd in chaptcr I 1. u hich coverr corrrparrsolr
lirnclious. i\{or ing rlilli'lcnt dinrcnsionlll nUnrbcrs into thc sel poiIt lld tolcr llcc lcgister\
is rliseusrctl in ehlptcl 16. which corcrs thc I\IOV E tirnctions.

I r-3 THE PI,C RT]PI.]TITIVE CI,OCK


Thc ADD Lrnrl SLIBTRACT llnctions discusscd so lirr in lhis ch plcr do n()t usually operate
coItiIr()u\lv. Thc\ rrnly pcrlirlrll thc addilion (n \uht|.itctiotr opcrali(m oncs r!hen the l'unc-
lion is c'nabletl. Il Enublc r!'tnains (u. nothing elsc h pl)cns. cvcn th(,uglr the operand\
changc. Whcn Enlhlc is oll. nothing hirppcn\. cithcr'. Thc[clirlc. il rcpctitive (,0-otfcnablc
is ncetlcd lirl continuolrs opclllion.
Figurc I l-9 showr il rclL.*liti\c cl()ck itrrtnltcnlcot. A coil lurns itsellofiand on at ir
very tusl riltc. nhoul two tintcs thc scilD-tinrc r tc. ll this ir uscd irs an elable. the op€rution
ol rtn urithntrtic lirnction is csscntiillly cotllinuous-il v()u crnsidel elcly nrillisecond o[ so
lr) htt cortlinu(nl\
Thc scqucrrcc li)r thL'rcpcriri\c clock is this: On lhc lirst scan. lhe rclity coil is
turncd on lhrough ils uwn contact. Whcn thc coil gocs on. it opels its owt enablirrg con-
tirct. $hich is nornrirlly closed. At lhc cnd ol the lirst sciln. lhe CR{l(}-13 NC contacr is
updilted and opencd. On lhe next scar. thc coil is lurncd off. Updatc ill thc L'nd ol the
second scan recloses lhc sclf'-enabliug contuct. The pn)ccss then rcpeats itscll cuntinu-
ouslv.
When lixed. longcr interrals are needed. lirlers are used instead of thc repetitive
cltrk. Thcse interrirl situalions uere covered in chapter9. Thc repetitive ckrck ciln bc used
with other rrithmclic f'unctions hr'sidcs ADD anrl SUBTRACT. This includes all tirnctions
in the rerrraindcr ol this chapter. The repetitive clock can also bc used u'ilh many other
f'unctions which nced periodic updating or acluation. Nunrber conrparison t'unctions of thc
next chapter are exiltuples of turrher use of the repetitive ck)ck.

tt4 PLC MULTIPLICATION, DIVISION, AND SQUARE ROOT


The multiplication tirrmat is sinrilar to the addition and subtracti(nl tbrmuts preriously
discussed. Figurc I l-10 shows the MULTIPLY function. We discuss rhe block tunction
only. Operand I is assigned a register number. Operand 2 can be another regisrer. rrr it rnuy
be a constant. The result of the nlultiplication appears in the destination when the tunction
is enabled. The destination is two regisrers wide by necessiry. Multiplying tX)3.1 by fD86
would require only one register, tbur numbers wide. lbr the answer (2()ff). However.
PLC MULTIPLICATION. DIVISION, AND SQUARE ROOT r89

IIGURE II.IO tN0612 MP0207


Enable
XULTIPLY Function Operand 1
(May be
H80037
multiple codacts)
Operand 2
May be a constant 1H0081

Destinalion
Total result is in
HR0068
HR0068 and HR0069

a Block Formal

121 o3o 031 032 033

Line 1
HH"H"}<,X,F
05 121 486 058 806

032 034 033 0s5 010

Line 2
--{"H=H"H=H)-
058 806 10

b Coil Format
Nole: For result of less than 6 digits, use Line 1 only

multiplying 6453 by 8933 (57,644,649) would require an 8-bit-wide slot or two registe$ to
accommodate the answer,
The multiplication takes place only when enable comes on. Normally, the coil comes
on when the multiplication is comPleted. The coil on-off state has no numerical signifi-
cance as it did in ADD and SUBTRACT
A simple process application for counting cartons is shown in figure I I-l l The count
from a canon counter enters the PLC and is put into IR000l and then into operand l Each
carton contains 12 bottles: therefore, 12 is entered as a constant in operand 2 To keep a

Constant value
MP0126
cR0127 (r80001)
Operand Analog lnput x 0012 = (HR0001XHR0002)
180001
1
(0 to 4095) 0000 xxxx
(0 to 8190)
Operand 2
1 1
0012
MSDS LSDS
Destination
HR000l Register Pair

FIGURE 11-1I
Multiplication Example
190 PLC ARITHMETIC FUNCTIONS

constant count of bottle output, the PLC would constantly multiply the carton count by 12. lI(
The destination register, HR000l, will show the number of bottles output each time the func- DI
tion is enabled. A number of these MULIIPLY functions could be combined to give a total
plant unit output. The constants in each function would be bonles per carton for that panicu-
lar count. A PLC addition program of all individual counts would then give the total plant
bottle count.
Th€re is normally no squaring function in a PLC format. Squaring is simply a matter
of putting the number to be squared into both operand I and operand 2 of a MULTIPLY
function. The square of the original number then appears in the destination register The
squaring function is shown in figure l1-12. We show the block format only.
The division function, which is shown in figure I l-13, is similar to the multiplication
function. We discuss the block format only. Operand l, the dividend, is divided by operand 2,
the divisor. The numerical result of the division appea$ in the destination register when the
function is enabled. Again, the division takes place only at the time Enable is energized. To
facilitate diyision, operand I is two registers wide and operand 2 is only one register wide.
Operand 2 may normally be a register or a constant numerical value.
In PLCs, the destination is almost always two registers wide. The first destination
register is the numerical resutt of the division. The second register value is the remainder in
numerical form. The remainder is not a decimal value. A numerical example of a division
is illustrated in figure ll-14. The determination of rhe number value in the second
destination register is explained in the figure.
Figure ll-15 is an example of scating by division. An analog measurement
numeric value, in inches, is fed into a PLC input register. The measurement value is
transfen€d (not shown) within the PLC to registers HR0078 and HR0079 (two registers
wide). To diyide by 12, put this constant value in Operand 2. This divisor could also be a
fixed or variable value put in a specified register (one rcgister wide). The resultant divi-
sion value appears in OR0l24 and OR0l25 (two registers). The resulting whole number
appears in OROl24. The remainder appears in ORl25. The remainder is a whole number
and not a decimal value. To convert the remainder to feet, another division process is
necessary.
If the required output accuacy is less than whole fe€t, convert the remainder into
decimal form. This would be accomplished by an added program step (not shown): Divide
the numerical remainder in OR0l25 by 12 and place the result in another output register,

MP0001
cRo127 R

Operand 1
HR0005
HR0005 x HR0005 @ lE@
Op€rand 2
H80005
Dostination
HR0006

FIGURD IT-12
Squaring by the MULTIPLY Function
PLC M U LII PLICAII oN DIVIS oN ND sQU RE ROOT 191

DV0119
URE 1l-13 tN0194
Enable
IDE Function Operand 1
(May be
HR0033
mulliple contacts)
Operand 2 May be
Total Operand includes
HR0061 a
HR0033 and HR0034
Destination constant
Total Destination includes
OR0013 and 080014 oR0013

A Block Format

121 o3o 031 032 033

Line 1
IH.H"H-X=F
05 891 26 034 269

032 034 033 035 010

Line 2
"H=H"H=HF_
ou 269 10

B Coil Format

Note: Value is in 032 and Decimal is in 033.

Remainder
FIGURE 11-14
DMDE Destination Register Operand 1 Operand 1
64A,127
64a,127 minus ]
Content Determination value in Two Regislers ]
divid€d by 267
X 646, 40 7
Operand 2 2,421 2421
Constanl Value
1120
equals I zatltots equals 1

Oestination
Value in the Two Registers @@
vatue is not71o4 )

FIGURE T1-15 0V0068


cR0178
Example of the Process Use of the Operand 1
DMDE Function HR0078
(HH0O78 and HH0079)
Op€rand 2
0012
0012
Destination
,oH0r24.,, oH0125 \
( t..r I/(Remainderl oR0l24
tv2 PLC ARMHME-TIC FUNCTIONS

tr.IGURE 11-T6 SOHOI


i
cR006i'
SQUARE ROOT Function Enab{g
I Source
(May be
HR0047
multiple contacls)

Source includes
i HRoO,I7 and HR0O48
Destination
I HR0062

for example, OR0l26. You would theo have four-decimal-place accuracy when the
ORo I 26 output register value is recognized as ten-thousandths of an inch.
Figure I l-16 strows the SQUARE ROOT fuirction found on some PLCs (block format
o'nly). The number whose square root we want to determine is placed in the source. The
source input number is contained in two registers so that it may be up to 99,999,999 in value.
When enabled, the function calculates the square roo( and places it in the destination. The
destination is one register wide, up to 9999 in value. There is usually no remainder register.

ll-5 PLC TRIGONOMETRIC AND LOG FUNCTIONS


A number of functions perform trigonometric and logarithmic operations in general in
midsize PLCs. A general blak function for these functions is shown in figure I l-17. lnput
going from off to on causes the mathematical operation to take place. The source register
value is analyzed appropriately and the calculated value appears in the destination register.
The angles involved in trigonometric function arc normally stated in radians. Therc arc

FIGI]RE I I-I7 Fundion


Arithmetical Ceneral Block Dasignation
Diagram
ollFut
Pertorm
Operation Source

D6tination

qion in Soms PLCS:


otJtBx On vuften ope.ation is corfldete.
otJpr/t O{f when perform operatbn is lum€d ofl.
OIHER PLC ARITH[IETIC FUNC"TIONS 193

upper limits on how big numhr the log functions will handle, as listed in operating
manuals. Some PLCs have an antilog function, where a conversion is made from a log to
its number. These various functions are:

Function Symbol Source Destinatlon

Arc Cosine ACS Cosinc Degrees


Arc Sine ASN Sine Degrees
Arc Tangent Tatlgenl Degrces
Cosine cos Degrees Cosine
Sine stN Degrees Sine
Tangent TAN Degrees Tangent
Conven Radians to Degrces DEG Radians Degrees
Conven Degrees to Radians RAD Degrees Radians
Natural tog LN Plus Numb€r Natural Log
t 8 to Base I0 toG Plus Number Log

ll{ OTHER PLC ARITHMETIC FI,]NCTIONS


Some additional, nontrigonometric and nonlogarithmic arithmetic functions are avaiiable
in midsized and larger PLCS. The function block are identical !o the one shown in 6gure
I l-17. Tlrcse functions are:

Function Symbol Sours Ilestination

Compute-Using a Formula CPT A formula Thc answ€r


Average a File AVE A s€ri€s of numbers The average
Negative NEG Plus or minus Minus or plus
Staodard Deviation STD A scrics of numbers Value of std. dev.
X to the power ofY XPY X and Y valuea The answer

The first function, CPT, can take complex expressio[r within the limits of the PI.c,
which are spelled out in the operatirg maoual. For example, fie expression (A + B)* (Sine
-
C Square root of D) could be entered- Instead of prog.ramming a number of arithmetic
steps, you program only on€ function. A table of the mathematical functions usable in the
Allen-Bradley system is shown in figure I l-18.
Another arithmetic process often needed is thc DOUBLE PRECISION procedure.
Suppose a process needs seven- or eight-place figurc accuracy, nol just the normally
calculated four figures. Some advanced Plf,s havc the capability to double the number of
output decimal digits, for example, from four digits to cight. For more precise processes,
r94 PLC ARITHMETIC FUNCTIONS

Teble 4.C
Valld Operetiom lor Uss ln 8 CPT Expr$slon
Operslor Dcacrlptlon Examplo Oporatlon
copy none copy from A to B enler sourc€ address in th€ expression;
enter dostination address in dostinalion
Clear none set a value lo zoro 0 €nter 0 {or the expression)
Arithmelic + add 2+3
2+3+7 (Enhancsd PLC-s
subtracl 12-5
112 - 5) - 7 (Enhanced PLC-s
muhiply 5 2
6 5 PLC.5
| (venical bar) divids 2416
I 6)'2 (Enhanced PLC-5 processors
negate - N7:0
SOR squar€ root SQR N7:0
exponentlal ' 10"3
(x to tho power ot y)
LN natural log ' LN F8:20
LOG log lo th€ base l0 ' LOG F8:3
Trigonomelic ACS arc cosine ' ACS F8:18
ASN arc sine ' ASN F8:20
ATN arc langsnt ' ATN F8:22
cos @sin6' COS F8:14
stN sine ' SIN F8:12
TAN tangent TAN F8:,l6
Bitwis€ ANO bitwise AND D9;3 AND 010:4
OR bitwiso OR Dl0:4 OB 010:5
xoR biMso sxclusive D9:5 XOF 010:4
OR
NOT biMse complemsnt NOT D9:3
Convorsion FRD converl trom BCD FRD N7:0
to binary
TOD convorl lrom Unary TOO N7:0
to BCD
OEG @nvert Edians DEG F8:8
io d€groas '
RAD convert degrsgs RAD F8J O TR
to radians '
'Available in Enhancod PLC-5 prooessors only

FIGURE 11-18
Valid Opentioos for use in a CPT Fulction (Coutcsy of
A[er Bradley)
TROUBLESHOOAING PROBLEMS 195

AD0001 MSDs LSDs


cRo127
Operand 1 HR000t HR0002
H80002

Operand 2 HR0003 fffiRooo4_l


HR0004
Destinalion H80005
H80006
Catry
AD0002
c80127
Operand 1
HR0005 HR0006
HR0001

Operand 2
HR0003

Deslination
HR0005

AD0003
A00001
Operand 1

HR0005

Operand 2
0001

Destination
HR0005

T'IGURE TI-I9
Typical DOUBLE PRECISION Funcrion Formar

this increased accuracy may be required. The PLC's system to increase accuracy is called
DOUBLE PRECISION. Figure I l-19 illustrates one manufacturer's system for carrying
out DOUBLE PRECISION for the ADD function. Consult your user's manual for how
your particular PLC does this, or, inde€d, whether it can do it at all.

TROUBLESHOOTING PROBLEMS
The PLC has been programmed to operate as shown in the figures referred to. However, the circuit
has the malfunction noted. What misprogramming or other factor or factors could cause the
malfunction?
TS I l-l Refer to figure I l-3. The printed count is for orre conveyer only.
TS I l-2 Refer to figure I l-6. The printer starts pdnting negative numbers.
r96 PLC ARITHMETIC FUNCTIONS

EXERCISES
All
l.
exercises assume that all numbers ale in decimal form.
Construct a basic PLC ADD function. Use lN000l as the enable circuit. Use HRmol and
HR0002 as the registers holding the numbers to b€ added and HR0003 as rhe sum. Insert rela-
tively small numbers in HR000l and HRm02, cnable the function, aod verify that the rcsulting
sum in HR0O03 is correct. Use the appropriate numbering syst€m to accomplish the addition.
Next. ins€rt large numbers whose sum exceeds the capability of HR0003 and observe the result.
I
Does lhe rcsult conespond to figure I I-2?
2. Three conveyors feed a main conveyor. The count from each feeder conveyor is fed into an ioput
register in the PLC. Construct a PLC program to obtain the total count of parts on the main con-
veyor. As an additional exercise, use a timer to update the total every 15 seconds.
3. Construcl a SUBTRACT function in a manner similar to exercise I. Insert numbers in the
operands that resuh in a positive destination number. Next, use numbers that give a negativ€
answer. Does the rcgative answer prcduce the results as shown in figure I l-5?
4. Two conveyon, A and B, fe€d a main conveyor, C. A third conveyor, R, removes rejerts a short
distance down the main conveyor. Tlre counts for conveyorc A, B, and R are each input into hold-
ing rcgisters in the PLC. Construct a PLC program to obtain the total output, C, partcount. As an
additional exercise, use a timer to update the total a! a time interval of your choice.
5. Set up a process range PLC program following the system shown in figures I l-7 and I l-8. The
nominal value or set point is 15.35 inches. The tolerances are +O.2'l and, -O.27 inch. Show that
the resulting Plc-calculaled limits are correct. To test the program's validity further, change rhe
set point and tolerances to diffirent values and check the resulls.

6. Repeat exercise 5 with different tolerances, Both tolemnces are negative, -0.05 to -0.20.
7. A main conveyor has two conveyors feeding it. One feeder puts 6-packs on the main conveyor;
the other feeds 8-packs. Both feeder conveyors have counters that count the number of packs
leaving them. Design a program to give a total can count on the main conveyor.
8. A conveyor has 6-,8-, and l2-packs ofcanned soda entering it. Each size of an entering pack has
an individual pack quantity counter feeding a PLC register To know how many total cans are
entering the conveyot set up a program for multiplying and then adding to give a total can count.
9. We have an output that gives us a dimension in inches. We wish to have the dimension diaplayed
in feet and yards. Develop a PLC program to output all three dimensions. (rrlrl: Use two divi-
sions for two outputs and one dircct-access output.)
10. Set up a PLC program to obtain an output, P. in r€gisrer OR0055. The output is to give a value
based on two inputs, M and N. P equals the square ofM plus the square root of N.
11. Develop pmgrams for other math equations of your choice. Example: N = (J + K - l-)/M.
-.

PLC Number Comparison


Functions

OUTLINE
l2-1 Introduction o l2-2 PLC Basic Comparison Functions rjt l2.3 pLC Basic Comparison
Function Applications o 12-4 PLC Advanc€d Comparison Functions

OBJECTIVES
At the end of this chapter, you will be able to
o List atld define fie six basic COMPARE functions.
tr Apply each of the basic COMPARE furctions to application proccss€s.
o Describe advanced COMPARE functions and their use.
o Apply combinations of COMPARE functions to do multiple comparison amlysis

tyt
198 PLC NUMBER COMPARISON FUNCTIONS

tz-l INTRODUCTION
Medium and large PLCs have number comparison capabilities. The number comparisons
are performed intemally in a manner similar to microcomputers and microprocessors. With
the PLC, there is no internal programming necessary for the operator. The PLC
programming is set up for direct keyboard/screen arithmetical logic. This chaPter
illustrates how to perform number comparisons of all types of PLC programming.
What kind ofnumber comparisons can be made by a PLC? We may wish to compare
two numbers. We might compare a varying coult to a fixed value, We might wish to com-
pare two varying input values every five seconds.
In an even more complicated situation, we might wish to determine whether a
periodically varying number is between two limits. These limits of comparison might be
6xed, or one or both limits could be variable.
Some PLC models have two basic comparison functions, with four other comParison
functions derived from the two basic functions. Other PLCs have all six functions as
individual functions. These are covered in section l2-2. Other PLCs have more advanced
compare functions, covered in section l2-3. Applications of comparison functions arc
illustiated in section l2-4.

t2-2 PLC BASIC COMPARISON FUNCTIONS


Many PLCs have only two COMPARE functions: equal, and greater than or equal to. To
perform any one of the other four functions (not equal, less than greater than, and less than
or equal to), combinations of the basic two ale used. Some PLCs have all six individual
functions, which makes programming easier. Of course, some less-expensive PLCS do not
have COMPARE functions at all.
This chapter uses the PLC comparison system with two basic functions for illustra-
tions. The other four PLC COMPARE functions use the inverse or combinations of the two
basic functions.
Figure l2-l shows a table ofcomparison functions. Functions I and 3 are the two basic
functions that we have discussed. The other four are derived functions. The six direct
functions for PLCs having them in their programming capability are listed on the right side
of the table.
lrt's take an example of each COMPARE function. Assume that A, the standard for
comparison, is placed in operand 2. A is set at 182. Then B, the number to be compared to A,
will be placed in operand l. We are therefore comparing the value of B to the value ofA, 182.
1. Equal (EQ) is true only if B is exactly 182 also.
2. Not equal (NE) is true if B is lEl or less, or if B is 183 or more.
3. Greater than or equal to (GE) is true only when B is 182 or less.
4. Less than (LT) is true only when B is 183 or more.
5. Greater than (GT) is true only when B is l8l or less.
6. Less than or equal to (LE) is true only when B is 182 or more.
In actual op€ration, A might be a varying number, not a fixed value of 182. Later chapter
examples illustrate how it may be changed periodically.
PLC BASIC COMPARISON FUNCTIONS 199

fCi,c.lt (conducts *ttenl Dlrucl


Comparl3on Funcllon Equallon
I qquatlon ls tnre) Funcllon
EO
'1 Equal (EO) A=B EQU

EO
2 Not equal A*B -------y- NEO

Greater than GE
or squal to (GE)
A>B GEQ

GE
4 Less than A<B LES

GE EO
5 Greater than A>B ---l GRT

GE

6
Less than
or equal lo
A<B leol
--___14____ LEO
L--r Fl
' Basic Functions

FIGURE T2-1
Six COMPARE Functions

In figure l2-2 we show three tyPical programming formats. Figure l2-2a' the block
format, is the type that we will use for illustration in this chapter' Figure l2-2b is one type
of coil format. For figure l2-2b, the typ of comparison-for examPle, e4ual to (=Fis
entered in the 37 coil center (not shown). Logic on (numbers OPI and OP2 equal) and IN
0071 on energizes output 106 thrcugh a 37 input contact. Figure 12-2c is another coil-type
format similar to figure l2-2b but on one line only. For figure 12-2c, we show.a function
for equal to for illustration. If the number in location 030 is equal to 225, output 021 is
energized.
Figure l2-2 shows three basic comParison function layouts. The two numben being
compared are operand 1 and operand 2. One operand can be a constant, the other a register.
Both operands may also be registers that contain numericalvalues. The identification num-
ber of the rcgister would be specified in the functional block.
When the function is enabled by the input contact, the comparison is made. If the
comparison is true, the output goes on. If the comParison is not true, the outPut goes off, or
i stays off. The comparison in some PLCS is made continuously as long as the enable is on.
i It makes the comparison on each scan. In some other PLCs, the comparison is made only
I at the tim€ the enable goes on. To make another numerical comparison, the input must go
ofl and then back on.
The pattems of the two basic COMPARE functions are normally similar. Figure l2-2
shows three formats of layouts that may be used for any COMPARE function. The only dif-
ference between the two basic functions would be the coil designation (and the mathemat-
ical inanipulation by the PLC CPU).
200 PLC NUMBER COMPARISON I.UNCTIONS

l'tcURE l2-2 Prelix tor Funclion


Typical PLC COMPARE Functions
;
I t2-
tN0071 I 0081
Enable
Compare
Operand
1

Op6rand
s 2

a Block Format

tN0071 oP1 37
Enable O?2 f Logic
(specrty)

37 r06
Output

b Coil Format Type 1

Goes on when numbers


are equal.
121 036 --.=, Oz,

-F-{"H.H
xxx
04
> 225 o7

Variabl€ Belersnce
(can be variable)

c Coil Format Type 2

Some PLCs, for example some models of Modicon PLCs, make all comparisons by
the use of the subtraction function. These models of PLCs have a subtraction (subtractor)
function with three outputs. One output is ON if the answer is positive, a second output is
ON if the answer is zero, and the third output is ON if the answer is negative. The orher
comparisons are made by paralleling any two outputs,

t2-3 PLC BASIC COMPARISON FUNCTION APPLICATIONS


This section illustrates the use of each of the six COMPARE functions in PLC process con-
trol situations. Both direct and derived functions are shown for each example. Note that
only the equal-to and greater-than-or-equal-to COMPARE functions are the same for de-
rived and direct function systems. Additionally, it shows one process application with two
COMPARE functions used in combination and an indusrial COMPARE application.
PLC BASIC COMPARISON FUNCTION APPLICATIONS 20r

PLE This example consists of two illustrations of the use of the equal-to COMPARE function.
I We are banding dowels into bundles of 40. A counter function (not shown) keeps track of
the count of the number of dowels in the bundle as they are added. The dowel counter's
count number is kept in HR0005. The running count is compared to 40, as shown in 6gure
l2-3. When the count reaches 40, the comparison is true, and the output, CR00l9, goes on.
Output CR00l9 is connected to a bander that op€rates when 40 is reached. The bundle
removal and system reset systems are nol shown, The other system would involv€ other
functions.
The count in HR0005 must be in the coIlect numbering system. We are comparing to
a decimal ,10, so HR0005 must be in decimal for proper oPeration. Some PLCS convert to
the proper numbering system automatically and some do not. Appropriate number conver-
sions may be needed, as shown in chapter 13.
Another equal-to application is also shown in figure l2-3. In this case, an output
must go on when two numkrs are equal. The number's values do not matter, excePt that
they are equal. The two numbers to be compared are fed from the out$ide process into
HROl23 and HROl47 for the illustration. When enabled, outPut CRol0l will come on any
time the numbers in the two registers arc equal.

NGURE 12-3 EOU


Example l2-l: F4ual-To ol
COMPARE Function EO
cR0019
tN000t
Operand 1
HR0005

Operand 2
0040

Compa son lo 40
EOU
or
EO
cR0101
1N0011
Opsrand 1
HR0123

Operand 2
HR0147

Compa aon ot fif,o vrtylnC XumbGrg


202 PLC NUMBER COMPARISON FUNCTIONS

EXAMPLE This example is forthe not-equal-to function. Figure l2-4 shows its programming ln the
t2-2 example, the output is to be on excePt when an input count is exactly 87. The input couot
is tracked in IR0062. Operand 2 can be programmed as the number 0087' It could also be
programmed as a register, HROl83. The number 87 would then be inserted into HR0l83'

EXAMPLE An automatic pill-bottle-filling operation has two possible bottle sizes' One bottle is b be

t2-3 Iilled to a count of225 or more. The other is to have 475 or more. This example uses a greater-
than-or-equal-to COMPARE function. Figure l2-5 shows the PLC function to control the
pill
counts. The pill count (counter not shown) is fbd from an input to IR 0142 as the bottle is
filled. The appropriate minimum numberofpills for proper 6lling,225 or 475. is insened into
HROl28. A Lonle is put under the pill disPenser (not shown). For a small bottle, the 225 limit
is put into HROl28; for a large bottle, 475 would b€ entered into HROl28'
As the bottle starts filling, Enable is continuously pulsed. The comparison is untruc
and output CR0030 is off. Once the Pill count reaches 225 for the small bottle, CR0030
goes on. Output CR0030 is connected to a cap-and-remove operation (not shown) The bot-
ile is capped and removed, and the process is reset and can be rePeated The same sequence
would be caried out for the large bottle with HRol28 set at 475.
Why not use an equal-to function for example l2-3? EQ would probably worlc
but what if the process overshoots? Suppose the counl somehow got to 226 for the small
bottle. The fill would go on unabated. If the count got to 226 (or 476 for the large size)'
however, the fill process would not erroneously continue if you use the GE function'

EXAMPLE Completed assemblies flow off of a production line as illustrated in figure t2-6 lf an
IH assembly is removed for rework somewhere along the line, the part to be reworked is

NEO EQ
cR0022 c80022
tN0007 tN0007
Operand 1 Operand 1
Logic
tR0062 tH0062

Operand 2 Operand 2 Could alternately


0087 0087 be a register
cR0023
cqoo22
Nol Equal
lndicator

a Dlrect Funcllon b Derlved Function

I'IGURE I2.4
Example l2-2: Not-Equal-To COMPARE Function
PLC BASIC COMPARISON FUNCTION APPLICAIIONS 20.1

FIGURE I2-5 GRE


Example l2-3: Greater-Than -or- or
GE
Equal-To COMPARE Function
cR0030
tN006
Operand 1 Output
tR0142

Operand 2
H80128

Register set at
eilhet 225 ot 475

Note: Direct and Derived Functions


are the same

GE
LES cR0032
cR0032 tN0015
rN0015 Logic
Operand 1
Operand 1
HR0063
HR0063

Operand 2
Opetand 2 0019
0019
cRo118
cR0032
Output
Green Light

I Oirecl Function b Derlved Function

URE 12.6
ple l2-4: Less-Than COMPARE Function

automatically counted. If there are more than 18 assernblies removed in an hour, a light in
the foremanis office is to tum off. If there are fewer than l9 rejects per hour, the light will
remain on. The required hourly reset-to-o system is not shown' (The only part of this
program that is shown is the comparison portion.) The defect count is kept in HR0063,
bpeiand l. The allowable hourly number of defects, 18, is inserted as operand 2 Since the
ailowable hourly number of defects is 18, 19 is inserted as operand 2'

MPLE The greater-than COMPARE function is illustrated in figure 12-7' Two comparison func-
greater than
t2-5 tions-arc required for this example. This prcduction oPeration requires a count
ooo oooooo
N(\IN
ooo
ooo
(o tr tr c.tG
ooo troooooo
i.. CC(ITE
"l=
EBEiaHl
=6rL " -l
I

-l-F+
ICEI I
EXAI
UII=
t2.4
c
o
=c
.9 .9 a
E lt
o E
J J o
E
o
oa
UJts
AI
o
o o
tt
tE

;-
F8 s5
i= es
o(f 0,d EE otE f,XAI
o- o- 8r o- N
N
o l2-7
cl
o
ot
o
o
zo z E
o
T T T

.9

EH IL
o t! Ef,Alt
t2-t
E= r:! z
EE a o
bE @IE I Q
o- o- t
Ita ll
e
6
o \ ..,
sd
l, ., tlA
z
=o.
oa
T fr ,!

N
PLC ADVANCED COMPARISON FUNCTIONS 205

348 for the output to tum on. The number 348 is insened as operand 2 in both functions.
For a count of 34?, rhe EQ function keeps the output off. Below a count of 349. the CE
function keeps the output off. For 349 or more, the outPut is on. as both contacts will be
closed for the indicator ladder line.

BAMPLE The less-than-or-equal-to COMPARE lunction is shown in Iigurc l2-8. A production sys-
n4 tem produces a product that can be one of three colors: red, white, or blue. The production
is limited to 348 blue units per day. The blue units are counted by using a color-sensitive
detector. The detector count is fed to the PLC into HR00l l. The maximum desired count,
348. is inserted into HR00l2.
The indicator is on for counts below 348. When the count reaches 348, GE stays off,
and EQ comes on. The output remains on. When the count goes up one more to 349, EQ
goes off, indicating that the production limit for blue has been reached. The outPut is now
off and will remain off for higher counts.

E{AMPLE This example, shown in figure l2-9, is a multiple-comparison program for lighting an
t2-7 indicator only when the count is between l5 and 22. A GE function is used for the lower
count. Another GE function is used as an indicator for 22 and is set at 23. IN00l6 enables
the functions. Below 15, the top GE function is off. keeping the output in the lower ladder
line off.
When the count, starting from 0, reaches 15, the top GE function goes on. Ti,e
output, CR00l9. tums on when the CR00l7 contact closes. The other contact in the bottom
line, CR00l8, remains closed because the lower GE function has not yet come on.
When the up count reaches 22, the output is still on. When the count reaches 23, the
lou,-, GE function goes on. Its contact in the lower ladder line opens' The outPut is
therefore lurned off at 23 and beyond,

EXAMPLE This problem shows how COMPARE l'unctions might be used in industry. A conveyor
l2-8 is supposed to have exactly 45 parts on it. You have three indicating lights to indicate the
conveyor count status: less than 45. yellow: exactly 45, Sredn; and more than 45, red.
The count of parts on the conveyor is set at 45 each morning by an actual count of parts.
There are two sensors on the conveyor, One is actuated by parts entering the conveyor,
and the other is actuated hy pr:t; lc;ir ing. A PLC program to carry out this function is
showrr in figure l2-10.

tu PLC ADVANCED COMPARISON FUNCTIONS


i
* Three often useful comparison functions included in some advanced PLCs are LIMIT TEST
T (LIM), MASK COMPARE EQUAL TO (MEQ), and COMPARE EXPRESSIoN (CMP)
function. In this section we describe the use of each of these advanced COMPARE fuuctions.
ooo ooo ooo
F<!C' F(!(9
-N(')
ot <\t (\l ot (\1 (\J or N (\J
ooo ooo ooo
ooo ooo ooo
.o
i.. oooE ,I.I(!.
ooo rIrltr
cE tc
ooo
N l, 6) g

FEESuE 3X
=(!A
36P
ulI=
c
.9
.9r(rJ.:c c
,9 .9 lt
-9 o t(,
E
o
oto trP (r
o
o
o

E= E= ua
oIr l!o
otr o(E
sts z
o(E
o- o- o- o-

!-\r OJ

o
z z uJ
o lu

o!
UJO
Jtc
o

o
o
F
'o! e
EP c
bE o(E .9
g.l

o- o- c,
o
lr.
F
6 3
o o
JN
z8 4 -a.

T ht!

N5
2vt
PLC ADVANCED COMPARIS ON FU NCTION s

GE
cR0017
Greater tN00l6
than or Operand 1
Loqic-GE
equal to Enable HR0261
15

Operand 2
15
GE
tN0016 cR0018
Less
lhan Logic-GE
Oporand 1

23 Hn0261
Enabl6

Operand 2
23

Output
cR0019
tN0016 CR0017 CR0018 lndicator-
lndicator On when

Enabls
r.- Opens for a
count is
within
value of 23
limits
or more
(15 to 22)
Clgses at
15 and up

FIGURE T2-9
Example l2-7: Multiple-Comparison hogram

Suppose that you want to see if a varying value is between two limits' which
are

either fiiei or varying. You could set up a Fogram like that shown in figure 9-2' perform
only
two comparisons, and do a logic step. With the LIM function you need to Program
one function. The function block is shown in figure l2-t la There are three inputs: the
varying value and the two limits. Figure l2-l lb shows the two aPPlications of the
LIM
functiJn. The first determines ifthe value is between the high and low limits The second'
with the low timil greater than the high limit, shows ifthe value being evaluated is outside
the limits.
The second advanced function sometimes used is the MASK COMPARE EQUAL
TO (MEQ) function. The function comparcs bits in two registers selectively' The mask is
is shown in
used to denote which bits to comPare and which not to compare The function
ftgure l2-12a. The use of the mask is illustrated in figure l2-l2b Where a mask bit is l'
is made' When enabled'
th-e comparison is made. Where the mask bit is 0, no comparison
the funciion goes on (true) if all unmasked bits pairs match' If one or morc Pair do not
match, the function remains ofr (false).
2m PLC NUMBER COMPARISON FUNCTIONS

rN002
uc9
Prssgt LOGIC
9999

Ir{001 R6g
HR
Rel- fig.,l0-4 'OI

rN003 DC 10

Preset LOGIC
9999

tN001 Reg
HR 101

tN00r EO 1l

1 OP' Equal To
l,r E
HR IOI GFEEN
Ret. fig.12-3
(uppe0
oP2
045

I tN001
GE I2
oP1 LOGIC
Hn 101

oP2
045
Rel. tig.12-6

GE
cB12 cH t3
Le66 Than
YELLOW
GE EQ
I cR 14
cal2 cR 1r
Ref. tig.12-7 Greale, Than
(Lowe4 RED

FIGURE TLIO
Example l2-8: PLC Program for Pilot Light Indicatioo of
Convcyor Part Count
PLC ADVANCED COMPARISON FUNCTIONS 209

LIM
tN007
*
High

Value

a - Function

Ull Example Using lnteger:

ll value Lovr Limil < value High Limit; When the processor detects that the
value ol B (Test) is equal to or between limits, the instruction is true; il value
Test is outside the limits. the instruclion is lalse.

tatse . | I - true - .
..1n... ---- -- tatse
----
from -32,768 .cl
<valueB>
......... to +32,767
I I

ll vslue Low llmit > value High Limit: When the processor detects lhat the
value of Test is equal to or oulside lhe limils, the instruclion is lrue; if value
Test is b€tween, but not squal to either limit, the inslruclion is ,alse.

true < falss ----- > taue


kom -32.768 ...,...c 4.. ..... -.. to 132,767
value B< < value g

b - Funcllon Operation

FIGURE I2.II
Operation ofthe Limit Test (LIM) Function (Courtesy of Allen-Bradley)
2ro PLC NL.TMBER COMPARISON FUNCTION"S

FIGURE I2-I2 MEO


Operation ol the Masked Comparison
tN001
*
(MEQ) Function .l Source
Enable

Mask

Compare to
f_l
a - MEQ Funclion

Nol Used
Scurce 1011 0111 0011 1000

Mask 0100 1011 1000 0100

Compare to 0010 1111 0r01 0000

1
No

Masked Comparlson is False

Comparison ol 14 bits lor a 16-bit register


Conpar son is masked so that only bits 2, 5, 7, 8, 9, & 14 are compared

b - MEO Operalion

Another ad\ an!r.l !r!nction sometimes used is the COMPARE EXPRESSION (CMP)
function. This hrlrci!,,r, .-ompares values of complex expressions. For example, if you TRC
wished to detenllilic '\,[ether one side of an equation was equal to the other side, you would
program

((HR 107*72) - 8 I ) = (SQR HR006 + 23)*(HR 0s610.6E

Any of the other five comparison functions can also be applied. The valid operations
for advanced Allen-Bradley PLCs are shown in figure 12-13. When enabled. the CMP
function checks the eq.uation values. If the equation is true, the output goes on. If false, the
output remains off.
TROLiBI ESIt(X)TlN(l I']ROBl.rrNiS 2tl

Valid Operations lor Use in a CMP Expression


Type Operator oescription Example Operation
Compar son equalto if A = B. ltren

nol equallo it A.- > B hen


less lhan ilA<B.then
ess than or equal lo ilA.-:= B ll"er
greaier than irA -, ts. lhe. .

grealer th an or equal lo if A ,.= B,1hen


Ar lhmetic add 2 - 3 Enhanced PLC-5 processor:

subtract 12 5
o ulliply 5' 2 PLC-5,30. 5i 40. '5i 60,

! (vertical bar) divide 246


te N7C
SOR square rool SQR N7J
exponential ' 10-'3
(x to the power ol y) Enhancec PLC-5 processors only)
Conversion FRD convert Irom BCD FRD N7 C

lo binary
TOD converl lrom brnary TOD N7:0
lo 8CD

rr(;t. RI.t l2,t -r


Vdlid of('rllrof\ liJi Ll\c in rLCl\11']1\pre\\ior {C()urlc\\
ol Allen-Brrdl!'\ )

TROUBI,ESHOOTIN(; PROI}I,HNIS
'lhr"'l'l-('hls hcr'n [()!runl0lad to ()l!cr!lc:]s sh(]'ru tn lhc llglrrr\ r.l('r('( 1.,. ilii\\r\!.r. tlit (ircuit
I:as tlru rrliuncli,)r n,,lcd Whnl lr1i\j)rosrirnrnlrr! r" (.lher l.ril,,r or ircl(r:.r)Li,-l \iilr\( lhc
rrr.rliLrnctior l
1'S l?-l itcl( r () liuure l2 9 (example l2 7).
l. Thc {)ufnt indicator never goes on.
2. Thc outl)ul indicalor docs nol go olf when acoriirt(,1 II ir rc:rL'hr.r.

TS I2 -2 R( frr to fi8ure I2 l0 (example I2 8 r.


l. Ycllow and green liShts both go on-
2. Green and red lights both go on.
PLC NUMBER COMPARISON FUNCTIONS

EXEITCISLS
Construcl and test PLC COMPARE funcrion programs fbr the fbllowing exercises. :
l. A light is to come on only if a PLC coun(er has a value of45 or 78. (Iy'irl: Two EQ functions with
or.llpuls in parallel.)
2. A light is to be on if a PLC counter does not have values of eirher 23 or 31.
.1. A light is to come on il (hree input numbers have the same value. (Iri,t: Use two functions with
lhe same registers and two contacts conlrolling an output coil.)
4. An output is on if the inpul count is less rhan 34 or more than 4l .

5. Sanle as exercise 4. but if the count is 37, lhe outpul is also on.
6, An oulput is to be on if the count is between 34 and 4l . The count includes 34 and 4l .
7. Same as exercise 6. but if the counr is 37, the output is to be olT.
8. There are two conveyors, each with sensors lo count input and output of parts entering and
leaving the conveyors, as in example l2-8 lbr one conveyor There are to b€ three indicating
Iights lbr the process as follows:
Number of pa(s on the conveyors equal White lighl
Number of parts on conveyor I is greater Green lighr
Number of parts on conveyor 2 is greater Blue light
9. Repeat exercise 8 except lhat the desired situation is thal conveyor I have exactly l2 morc units
on il rhan conveyor 2. When this siluation is true, a white light goes on. If conveyor I has less
than I 2 more parts on il than conveyor 2. a green lighl goes on. If conveyor I has more than 12
morc pans on il lhan conveyor 2. a blue light go€s on.
10. Use lwo or more LIM funcrions to check a varying value for the following values oftrue or false.
l-ess than 52 True
52lo59 False
More than 59 and less than 7l True
7l to and including 86 False
More lhan 86 and less lhan 99 True
99 and above False

ll. For the MEQ function, what would lhe rnask look like to check all rhe even-numb€r (only) bits
in a source tbr a match to the COMPARE bts?
Numbering Systems
and PLC Number
Conversion Functions

OUTLINE
l}-l Introduction . l3-2 Numbering Sysrems: Decimal, Binary, and BCD D l3_3 pLC
Conversions Between Decimal and BCD D l3-4 Octal and Hexadecimal Numbering Systems L-

l}-5 Other Numbering and Code Systems

OBJECTIVES
At the end ofthis chapter, yoLr will be able to
o Explain the basis ofthe binary counting system.
o Conven numtt€rs from binary to decimal, and vice ve$a.
o Explain the basis of the binary-coded decimal (BCD) sysrem.
D Convert numbers from BCD to binary, and vice versa.
o Program a PLC for binary-to-BCD and BcD-to-binary conversions.
D Explain the basis of the octal and hex systems.
tr Convert among the three numbering systems-decimal, octal, and hex.
! Describe the three coding systems-Cmy, American Standard Code for Information
Interchange (ASC[[), and Extended Binary Code Decimal lnrerexchange Code (EBCDIC)

213
211 NU\,I BERINC SYSTENIS AND Pt_C NLTNIBER COT"VERSION FUNCTION S

l3-1 INTRODUCTION
\tosl PLC tunctional and prograntming operations can be handled in the decinlal number_
ing system. Sor:re P[-C models and indir idual pLC tunctions use other numbering systems.
This chapter deals uith sonre of these numbering systems. including binary, BCD. octal,
hexadecimal. Gray. ASCII. and EBCDIC. The basics of eaclr system are exp)ained. and
conversions ltr)n one syste,n lo another ar!' illuslrated.
If your PLC wrrrks entirely in decimal. rhis chapter is optional. The purpose of the
chapter is to give you enough backgrountl to handle anv numbering systenl that you may
encounter on larger PLCs or in the fufure. Various texts are available that detail the use of
all numbering systems.
Note that this chapter does all conversions "longhand." Actutl conversions can be
made easily with a nroderately priced. scientific. hand-held calculator Various personal
corlputer programs fbr larger numbers are lrailable.

lJ-2 NUN{BERING SYSTENIS: DECITIAL, BINARY, ATT.D BCD


The first pan oi this section describes the binarv nuntbering slsten. ho!\. ir ditlers fronr
decimal, and how to convert lionr one to the othcr.
The dcciroal numberin-l systerl. which usc's I base of 10. is the one we use every day.
The decinral system is said ro huve developed by tens because lhe originators had ten
fingers and so could casilv count io I0. Above 10. another person or means had to be used
to keep track of the tcns. lf rhc count uas over 99 (antl less than l(X)0) a thiril means \r,,ls
needed to keep track ol thc 100s. Thus. the decimal system u.as developecl.
When digital computers were developed. they were designed to count by 2\: lheir
counters were cither olF or on. Therelbre. the base ol the computer counting svstem is 2,
instead ofthe l0 used in rhe decimal system. This base,two binary system. which hatl been
around ti)r a long tinrc. becanre the basis for all computer systems. With the advent of
integrated circuil (lC) chips. hundreds of binary, on-off switches can now be fbund on a
single IC chip in conrputers. All PLCs work internallv in the binary sysren) because they
are IC chip based. Since outside inti)rrnation is deeimal or BCD (BCD is defined later in
this section). a con\t'rsion ro ud tionr the binary used in the pLC CpU is needed.
Figure l -1 l shou s u comparison r)f the interprelation of a decimai and a bin0r), number. Bits
The numbers are arbilrarily picked tbr this illustration. There are l0 possible count values
(0 through 9) in each dccinral prsrtion. For the hinary counter, there are only l\vo possible
4
counts. 0 or L As a r(]suil_ fi)r hinary we must move lo the next bit or JIol afier we react. l. not
9. as in decimal. '[he bin.rry rruntber shown has a decimal equivalent value of .l + I or
, -5. I

FIGURE I.]-I 16
00s 10s ls
Decinlal and Blnary Svstenl Typrcal Decrmal Number 976 I
+ +
Comparison 9 7 6 32
4S 2s 1s
Typical 8inary Number 101
I t I
1 None 1
FIGI
Typi,
NUMBERINC sYSl l:llS: l)I:CIl\'1AI.. IIINARY. AND BCD 2t5

t'IctrRE l3-2 Decimal- Binary.


Decimal and Binart !aluc Base Base
Comparison 10
1 1

2 10
3 11
4 100
5 101
6 110
7 111
8 1000
s 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
17 10001
18 10010
19 10011
20 101 00
21 101 01
22 10110
23 10111
24 11000
25 11001

Figure l3-2 compares the value of a given quantity tbr decimal and binary
systems.
Figure l3 3 illustrares the counting slots or bit status for sonre typical binary num-
bers. The morc bits 1ou usc. the higher you can count. The maximum decimal equivalen
count is given f()r each example 1l in all bits). The equiralent decimal values firr the giver

Bits Maximum Value - Typical Binary Number Equivalent Decimal Value


lF All Blts A.e 1

4 15 8s ,is 2s 1s = 13
0

8 255 128s 64s 32s 16s 8s 4s


1 0 0 1 0

32s l6s ) 8s 4s 2s 1s
t, o 64s
16 4095 2048s 1024s 512s 256s 128s
1011 1 1 o ro 101 = 2917

32 65,553 i32,768 r6.384 8192 4096/2048 1024 512 256 )128


110101i00 '1 11 0 '1
6
)8 4 2 i = 44.270
1 10
}'IGURE 1}3
Tlpical Binar, Numbers and Decimal Equivalenls
2t6 NUMBERING SYSTEMS AND PLC NUMBER CONVERSION FUNCTIONS

Digllal Numbel Conversion Declmal nesult


1011 (8+0+2+1) 11 'IGU]
Decim
0101 0101 (0+64+0+ 16) +(0+4+0+ 1) 85
0011 1110 (0+0+32 + 16) + (8+4+2+0) 62
1101 0011 (128 + 64 + 0 + 16) + (0+ 0 +2+ 1) 211
1010 1010 11 11 (2048 + 0 + 512 +0) + (128 + 0+ 32+ 0) + (8 + 4 + 2 + 1) 2735

FIGURE I3-4
Binary-to-Decimal Conversions

binary bit panerns are given also. Typical PLCS work in 8- or 16-bir form. Other PLCs may
have 4, 6, 12. or other numbers of bits as a base for each address or register
Figure l3-4 gives some examples of conversions from binary to decimal. Four-,
8-, and l2-bit numbers are shown in the example. Different numbers of bits are convened
similarly, staning liom ghr ro left.
Figure l3-5 illustrates the opposite conversion, from decimal to binary. The conver-
sion is not as easily accomplished as binary to decimal, especially as the numbers get
Iarger. Basically. the procedure is to find the largest numb€r in the digital columns that is
less than the decimal number being converted. A I is placed in that binary column. Next,
subtract the column's binary/decimal value number from the decimal number being
converted. Then move one column to the right and apply the same procedure to the
remainder. Keep repeating the procedure until the remainder is zero.
A related number system used often in PLCs is the binary-coded decimal, or BCD,
systcm. The key to the BCD system is ro urilize four digital bits for each single decimal
number of output or input. A commonly used BCD system contains four decimal numbers
and can display decimal values from 0000 through 9999. The four-.digit decimal number
is then represented by 4 times 4, or 16 bits. Figure 13-6 shows some typical decimal

Decimal Number + Blnary Numbe]


t, pa 64 132 116
',
ie',4 i 2
I I

r0r0r0r0r0r0r0r0r
3 0 0 0 0 0 0
7 r0r0r0r0r0r1rlrlr
0 0
I
0l1l 0 1 0
',zz-rc/
I
6-4 ,),
I
t I
22 I r =6 I r

0 110 0
?3-161 .,
I
I
I -64,,
a7 I I
a7 23t
r1
I

0 r1r111r1r 0
t-s 4
Irzs- 641-61 - 32t 29 - 16t.13 - g
I I I
- _?
r =61 /t =29/t = 13.-, =5,.t =1
I I I
125 t

I 1r0
1164-1281
1r0 t0t
tt
0 0
36-3 2 ., I I

164 I =ee I
I I

FIGURE I}5
Decimal-to-Binary Conversion
NUMBERING SYSTEMS DECIMAL. BINAR Y, AND BCD
217

fIGURE T3.6 Oecimal BCO Blnary


Drcimal and BCD Equivalents (Fer.)
1 000r I
2 0010 10
3 0011 ,1
4 0100 100
5 0101 ,0,
6 0110 110
7 0111 111
8 1000 1000
1001 1001
10 0001 0000 1010
11 0001 0001 1011
12 0001 0010 1100
0001 0011 1101
14 0001 0100 1110
15 0001 010, 1111
16 000r 0110 10000
17 0001 0111 10001
18 0001 1000 10010
19 0001 1001 10011
20 0010 0000 10100
21 00r 0 0001 10101
0010 0010 10110
23 0010 0011 10r 11
24 0010 0100 11000
25 0010 0101 11001

Table ol Values

Decimal + 8 62 971
I
BCD * looo O1lai ooto' 1001 0111 0001

Decimal + 1142 7a,493


.----l \---,.., ----/
./.zr\-.-
I \---.
0001 0001 0100 oolo + BCD+ 0111 lOOO OlOO lOOl OO11

Converslons

numbers and their BCD equivalents. For comparison,


the binary values are also shown in
tbe table.
PLC CPUs function in binary, not BCD or decimal. If rhe pLC received a BCD
number from an input thumbwheel
ia small rotary device set to 0if,r*gll S Uy rotating it
with the thumb or finger), it would interpret the number
as a binarynumblr The BCD input
number must be convened to its binary equivalent
for correct pic cenral processing unit
(CPU) operation. We could converr the number
manually, u. .to*n-in Figure 13_6;
however, ifit must be done 25 times per secon4 for example, manual
conversion would be
218 SYSTEMS AND PLC NUMBER CONVERSION FUNCTIONS
^.UMtsERINC

FIGURE I]_7 Thumbwheel Setting


BCD+o Binarl and BinarJ-to-BCD
PLC Processing
EEE 2 in Decimal

1000 0110 0100 0010 BcD (8642)

I
0010 0001 1100 0010 Binary (lor 8642 decimal)

I (r 5) *--
L lnternally scaled 1 to 2
0001 0000 1110 0001 (1/2value)
Binary (for 4321 decimal)
I
0010 0011 0010 0001 BCD (4321)

.- Output reading on
LED read oul
in decimal

impossible. For fast operation, the conversion must be performed by the PLC. A PLC
function for the conversion is available. Your PLC may do the conyersion automatically:
however. in most cases! you must program in the BCD-to-binary conversion for inputs. For
outputs. you program binary-to-BCD conversions.
Figure i 3-7 shows a simple example of a required conversion. The PLC is required
to take an input value in BCD and multiply it by 0.5. The resulting number is thel dis-
played in BCD on an output LED readout. Since the PLC functions in binary, the inpu
BCD value must be converted to binary before intemal processing can take place. Then, thc
converted binary number is multiplied in binary by 0.5. This'resulting binary value is ther
convcrted to BCD for output to the display.

13-3 PLC CONVERSIQNS BETWEEN DECIMALAND BCD


In this seclion of the chapter we show the formats of the PLC number convelsiot
functions and use the conversion functions in a PLC program. Many PLCs include thesc
functions fbr converting BCD numbers to binary for use by the CPU. They also cn
contain the inverse conversion, binary to BCD. Figure 13-8 is a typical PLC applicatir
problem requiring number conversions. It illustrates in block diagram form how the cor
versions are accomplished. The mathematical manipulation in the middle block can talc
any form.
PLC CONVERSIONS tsl:T\vEI\ l)1,( l\l \1..\\l) B( lr ll9

Thrmbwheelor Decrmarl
Olher lnpul Readout

6 4 1 9 BCD
Math
Binary 1765
ol
lo to
Other
Binary BCD
Conv.
lnput Output
Module Module
Rack Back

FIGURE 13-8
Block Diagram of a PLC s BCD-to-Binary Conversion Program

Figure l3-9 shows the layout of a typical BCD-to-binary conversion tunction, r hich
is usually used for input data conversions. It converts the BCD value found in the source
register to a binary number in the destination register for PLC CPU use. When the
function's input line is energized, values in the source register are converted f'rom BCD to
binary. The resultinS number is put into the destination register. Typically, the coil comes
on only if one of the BCD digits exceeds 9 during mathematical conYersion.
Figure I 3 - I 0 shows how the reverse of the conversion in tigure I 3- 9 is accontplishe,i.
A binary valrre in the source is convened to a BCD value in the destination. This functi(nl'\
primary use is for f'eeding an output display. Typically fbr this function, the coil comes on
only if the binary value exceeds 9999 in decimal during operalion.
To learn how the individual functions of figures l3-9 and l3-l0l'unction. you rrrr)
use the MONITOR mode (colered in chapter 26). Progran the function to be observed in

FIGURE I}9 BCD/BN


BCD-to-Binary Conversion tN0116
0062
Function Convert Source
1R0032

Deslination
HR0081

FIGURE 1}10 BNi BCD

il Bifl ary-to-BCD Conversion


Function
tN0071
Convert Source
0063

I HR0081

Destinalion
oFlo111
220 NUMBERING SYSTEMS AND PLC NUMBER CONVERSION FUNCTIONS

the EDIT mode, place the PLC in the MONITOR mode, and then call up the two registers
involved in the conversion function. Insen appropriate values into the flrst register. Enable
the conversion function being used and obserye the resulting value in the second register
Verify the conversion function's correct mathematical operation manually or by calculator
conversion computation.

ty OCTAL AND HEXADECIMAL NUMBERING SYSTEMS


Two other number codes often encountered in dealing with PLCs and computers are the
octal code and the hexadecimal. Hexadecimal is normally shortened to hex. The octal
code uses a base of 8. and the hex uses a base of 16. These bases are in contrast to deci-
mal and BCD, which have a base of 10. If the computer's numbers are 3 bits long, it is in
the octal numbering system. Three bits can count up to 7 as a maximum and start over at
8. If 4 bits are used for each number, the numbering system is in hex. Four bits can count
up to l5 and then start over at 16, Figure l3-l I shows the comparison of octal- and hex-
to-decimal equivalents.
Figure l3 l2 gives a table comparing values for decimal numbers with their octal
equivalents (and binary for reference). When we reach 8, octal starts over and a I goes in
the slot to the left.
How do we convert between octal and decimal? Figure l3-13 shows some typical
octal-to-decimal conversions. and figure l3-14 illustrates some decimal-to-octal conver-
sions. For decimal-to-octal conversions, repetitive division is used.
As stated previously, the hex system uses 4 bits per number, compared to octal's 3.
Therefore, hex is base 16, as was shown in figure l3-l l. Since we must count beyond 9 in
a single column. we use sequential letters ofthe alphabet for numbers l0 through 15. The
hex system is shown in figure l3-15.

tr
100s 10s
4
tr
1s
347 Decimal

,'--\ /,--\ 5x64=320


6x 8= 18
1 0 1 1 1 0 0 1 1
3x 1= 3
64s 8s 1s 371 Decimal
Octal
12 x 256 =3072
0 0 0 0 0 0 0
14x 16- 224
1 1 1 1 1
2x 1= 2
256s 16s 3298 Decimal
Hex

FIGURE T}TT
Decimal-Octal-Hex System Comparison
OCTAL AND HEXADECIMAL NUMBERING SYSTEMS

FIGURE 1}I2 (Bel.)


Octal Code Table Declmal Octal Binary
Base Base Base
(10) (8) (2)
1 1 1

2 2 10
3 3 11
4 4 100
5 5 101
6 6 110
7 7 111
8 10 1000
I 11 1001
10 12 1010
11 13 1011
12 14 1100
13 15 1101
14 16 1110
15 17 1111
16 20 10000
17 21 10001
18 10010
19 23 10011
20 24 10100
21 25 10101
22 26 10110
10111
24 30 11000
25 11001

Figure I 3- I 6 shows how hex numbers are convened to decimal. The conversion uses
straightforward multiplication. as does the octal-k)-decimal conversion.
The conversion of decimal to hex is a little more involved than hex to decimal. We
use repetitive division similar lo that used for decimal-to-octal conversions, as shown in
figure l3..17.

Oclal Number Convgrsion Decimal Resull


0203 (0 x 512)+ (2 x 64) + (0 x 8) + (3 x 1) 131
1111 (1 x 512) + (1 x64)+.(1 x8) +(1 x1) 585
(2 x 512) +(6x 64) +(7xB) +(3 x 1) 1467
107r (1 x 512) + (0 x 64) +(7x8) +(1 xl) 569
4918 =-- Nol a valid octal number - (9s & 8s impossible)
r 8-8
trase I Bx8=64
Ia's,e=srz
FIGURE T}T3
Octal-to-Decimal Conversions
)r) NL.\,1t]ERINC SYSTE]!IS AND PI-C NIJMBT.-R CONVERSION FUNCTIONS

Decimal Number Conversion OctalNumber


5 None Needed 5
11 li8=lwith3Rerrainder 13
28 288=3with4Bemainder 34
B5 85.B = 10 wllh 5 Flenrarnder
L. tO,g = t with 2 Remainder 125
116 116'B = 14 with 4 Remainder
L- 14i8 = 1 with 6 Remainder 164
982 982/8 = 122 with 6 Bemainder
L* 1228 = 15 wilh 2 Bemalnder 1726
L+ l wth T Remainder
t't(;t'Rf l3-l{
Decinral'to'Oclal Convcr\ion\

lIGtiRlt l3-15 Decima! Hex Binary


Derinral Hex Binrry Comparison Base Base Base
10 16 2
0 0 0c00
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 c111
I 8 1000
9 I 1001
10 1010
1,1
B 1 011
12 c 1100
13 D 1 101
14 E 1110
15 F 1111
16 l0 10000
17 11 10001

Hex Number Conversion Oecimal Resuit


t3 (1 ,(16) +(3x1) 19
uc (11 x 16) +(12x1) 188
F.lt) (15 x 256) +(4r 16) + (13x 1) 3917
(11 g; (12x4096) +(1 x256) + (11 x 1e)+(7 x 1) 49,591

16
Base 16 i 16 - 256
16r16i16=4096
FI(;UEr.r l3-r 6
lle\ tr) l)ecinlr) Conversions
OTHER NUMBERING AND CODE SYSTEMS

Decimal Numbers Conversion Hex Number


7 7
12 C
21 21l16 = 1 with 5 Bemaindel 15
111 111/16 = 6 with 15 Remainder 6F
247 247116 = 15 with 7 Remainder F7
398 398/16 = 24 with 14 Bemainder 18E
L- 24/16 = 1 with 8 Remainder
FTGURE I3-17
Decimal-to-Hex Conversions

Ll-5 OTHER NUMBERING AND CODE SYSTEMS


Three other numbering/coding systems are often encountered irt PLC work: Gray, ASCII'
and EBCDIC. The Gray code involves only numbers; ASCII and EBCDIC codes involve
both numbers !nd letters or symbols.
The Gray code's structure, which is shown in figure 13-18' is constructed so that
only one digit changes as you go down one step. You will note this arrangcntcnt bv
following dowu the left Gray code column. Note the step from the fourth step to the fifth
step. Only one number changes for the Gray code. The third digit changes from a 0 to a l'
For the same binary step, 3 bits' digits change.
The single-digit change is impoftant when certain mechanical and photoelectric
encoders are used. Details of these encoding systems may be found in vadous texts on
control systems. If you follow the binary code in the right-hand column, you see that one.
two, three, or more digits change from one number to the next The Gray code has only
one change per step. A change of more than one digit is difficult to handle when usinB err-
coders.

FIGURD 1}T8 cray Code Binary


Gray Code Compared to BinarY
Code 0000 0000
0001 0001
0011 0010
0010 0011
0110 0100
0111 0101
0101 0110
0100 01ll
1100 1000
1101 1001
1l1l 1010
1110 1011
1010 1100
1011 1101
1001 11r 0
10q0 1111
2A NUMBERING SYS'TEMS AND PLC NUMBER CONVERSION FUNCTIONS

The Gray code and standard binary are different and are not interchangeable. Caution
must be exercised not to mix the two. If your PLC works in binary, pqtting Gray code
values into it will give false input information. The inverse is also true for output; a Gra)
code output will not function properly in binary.
ASCII stands for Arz erican Stsndard Code for lnformation lnterchange. As you can
see from its listing in tigure I 3- 19, it covers numbers, letters, symtrols' and abbreviations.
The ASCII code requires 6 or 7 memory bits, depending on the system used. h is used to
interface the PLC CPU with alphanumeric keyboards and printers.
The EBCDIC code is similar to theASCII code in function. [t is shown in figure l3-20.
EBCDTC uses 8 bits, compared to the 6 or 7 bits used for the ASCII code. whether
ASCII or EBCDIC is used depends on the panicular PLC's operational requirements and
capabilities.

Heradeclmal Dscimal Octal Binary Characler Oescription

00 0 000 0000000 NUL Null


01 1 001 000000r SOH Stan ol heading
02 2 002 000001 0 STX Start o, texl
03 3 003 0000011 ETX End of text
04 4 0O,l 0000100 EOT End ol lransmission
05 5 005 0000101 ENO Emuiry
06 006 0000110 ACK Acknowledge
o7 7 007 0000111 BEL Bell
08 8 010 000r 000 BS Back space
09 9 01r 000r001 HT Horizontal tab
OA 10 012 0001010 LF Line feed
OB 11 013 0001011 Vertical tab
12 014 0001100 FF Form teed
OD IJ 015 0001101 CR Caniage return
OE 14 016 0001110 SO Shift oul
OF 15 017 0001111 SI Shift in
10 16 020 0010000 DLE Data link escape
11 17 021 0010001 DCI Device Control 1
12 18 022 0010010 oc2 Device Control 2
13 19 023 0010011 DC3 Device Contlol 3
14 20 024 0010100 DC4 Device Control 4
15 21 025 0010101 NAK Negative
acknowledge
16 22 026 0010110 SYN Synchronize
17 23 027 0010111 ETB End ol transmission
block
18 24 030 0011000 CAN Cancel
19 25 031 0011001 EM End ol media
1A 26 032 00110,l0 SUB Substitute
1B 27 033 001r 011 ESC Escape
1C 28 034 @11100 FS File separalor
1D 29 03s 0011101 GS Group separator
1E 30 036 0011110 RS Record separator
1F 31 037 0011111 US Unil separator
20 32 040 0100000 SP Space
21 04.| 010000r I Exclamation

FIGURE T}T9
ASCII Code
OTHER NUMBERING AND CODE SYSTEMS

Hexadeclmal Declmal Oclal Binary Chaiactel Descrlption

22 u 042 0100010 Double quote


Number or pound
23 35 043 0100011 It
24 36 044 0100100 $ Dollar sign
25 045 0100101 Percentage
26 046 0100110 & Ampersand
27 39 o47 0r00111 Apostrophe or
single quote
28 40 050 0101000 Left parenthesis
n 41 051 0101001 Right parenthesis
Asterisk
2A 42 052 0101010
29 43 053 0101011 Plus
2C 44 054 0101100 Comma
2D 45 055 010r 101 _ Minus
2E 46 056 0r 011r 0 Period
2F 47 057 0101111 ) Slash
30 48 060 01r 0000 0 Zerc
49 061 0110001 1 One
32 50 062 0110010 2 Two
33 5l 063 01100r 1 3 Three
34 52 064 0110100 4 Four
35 53 065 0110101 5 Five
36 54 056 0110110 6 Six
37 55 067 0110r 11 7 Seven
38 56 070 0111000 Eight
39 57 071 0111001 9 Nine
3A 58 072 0111010 Colon
3B 59 07s 0111011 Semirolon
3C 60 071 0111r 00 : Less than
3D 61 075 0tlt101 Equal
3E 62 076 011r110 Greater than
3F 63 077 0111111 ? Ouestion
40 64 100 1000000 @ At sign
41 t01 1000001 Letter A
42 66 102 1q)0010 B Letter B
43 r03 1000011 c t$lter C
44 68 104 1000100 D Letter D
45 69 105 1000101 E Lslter E
46 70 106 1000110 F Letter F
47 71 107 1000111 G Lettsr G
48 110 1001000 H Letter H

49 1tl 1001001 I Letter I


4A 74 112 ,001010 J Lstter J
4B 75 113 1001011 K Lstter K
4C 76 r14 1001100 L Lstter L
4D 77 115 1001101 M Letter M
4E 7A 116 1001110 N Letter N
4F 79 117 1001111 o Lelter O
50 80 120 1010000 P Lefler P
51 8l 121 1010001 o Letter O
52 82 122 1010010 R Lstter R
53 83 123 r010011 S Lstter S
5,r 84 124 1010100 T Lener T
55 85 125 1010101 U Lefler U

FIGURE lll9 (cordaaed)


226 NUMBERIN"G SYSTEMS AND PLC NUMBER CONVERSION FUNCTIONS

Hexadecimal Oecimal Octal Blnary Character Description

56 86 126 1010110 Letter V


57 87 127 1010111 Letter W
58 88 130 r011000 x Letler X
89 131 1011001 Letler Y
5A 90 132 1011010 z Letler Z
5B 91 133 1011011 t Lell bracket
5C 92 134 1011100 Back slash
5D 135 1011101 l Right b.acket
5E 94 136 1011110 t Up arrow
Back arrow
5F
60
95
96
137
140
1011111
1100000
: Back quote or
accent mark
61 97 141 1100001 a Small letter a
62 98 142 1100010 b Small lelter b
63 99 143 1100011 c Small letter c
64 100 144 1100100 d Small letter d
65 101 145 1100101 e Small letter e
66 102 146 1100110 I Small letler f
67 103 147 1100111 s Small letler g
68 104 150 1101000 h Small letter h
69 105 151 1101001 i Small letter i
6A 106 152 1101010 j Small le(er I
6B 107 153 1101011 k Small letter k
6C 108 154 1101100 I Small letter I
6D 109 r55 1101101 m Small letter m
6E 110 156 1101110 n Small letter n
6F 111 157 1101111 o Small letler o
70 160 t110000 p Small letler p
71 113 161 1110001 q Small letter q
114 1110010 I Small letter r
115 163 1110011 s Small letter s
74 116 164 1110100 t Small letter t
75 117 165 1110101 U Small lelter u
76 118 1110110 Small letter v
77 119 1110111 Small letter w
78 120 170 1111000 Small letter x
79 121 171 1111001 v Small letler y
122 172 1111010 z Small letter z
7B 173 1111011 { Left brace
124 174 1111100 I
Vertical bar
70 125 175 1111101 l Right brace
7E 126 176 1111110 Approxinrate or tilde
7F 177 1111111 DEL Delete (rub out)

FIGU RE l3-l9 (c ont inue d )


EXERCISES

FIGURE I.1-20
fiBCDIC'Code Character asc EBCDIC

0 011 0000 1111 0000


011 0001 1111 0001
2 0110010 1111 0010
3 011 0011 1111 0011
4 011 0100 11110100
5 0110101 11110101
6 011 0110 1111 0110
7 011 0111 1111 0111
8 011 1000 1111 1000
9 011 i0::' 1111 1001
100 00C i 1100 0001
B 100 c010 1100 0010
C 100 0011 1100 0011
D 100 0100 1100 0100
E 100 0101 1100 0101
F 100 01 10 1100 0110
G 100 0111 1100 0111
H 100 1000 1100 1000
I 100 1001 1100 1001
J 100 1010 1101 0001
K 100 1011 1101 0010
L 10c 1100 1101 0011
1\,4 100 1101 1101 0100
N 1C0 1110 1101 010i
C) 100 1111 1t 01 0110
P 101 0000 1101 C111
o r01 0001 1101 1000
F 101 0010 1101 1001
S 101 0011 1110 0010
T 101 0100 1110 0011
U 101 0r 01 1110 0100
101 01 10 111 0 0101
r01 0111 1110 C11C
x 101 1000 i110 0111
101 1001 1110 100C
z 101 1010 1110 1001

E\ER(]ISES
Irr exerci:cr { throu-eh 8. L.,n\cil the gi\en numhel5liotn on.'svslerl. l,) thr o1he, s1',terrr rpeci}ied
l. [JiE!.] {1) iiL'rinrri:
lll.li)ll. 1t) 1010. ll(r 1l()1. i0ll 001 I. l00l l0l1 ll I0
2. Decinral t(, birar\
j.1..1:. 35 l6l. :07.,1s.1

-1. Decimal () B( [)
56. 381. i I2I . 15lll. 66tr6
224 NUMBERINC SYSTEMS AND PLC NUMBER CONVERSION FUNCTIONS

4. BCD to decimal:
0ll000ll l0l I I 100(rnrt: Isthispossible?)
0 0 00l l 0l 0l t0
1000 l00t 0r00 0001
010t0000 1000 0t01
001 I 00lt 00lt 0l

5. Decimallo octal:
7, 15,88,327,69r, lt2l
6. C)ctal to decimal:
6, 35, 11 , 201 . 841 . 4461
7. Decimal to hex:
8, 14, 79, 410, 558, t24l
8. Hex to decimal:
I I, 3C, 2A2, BCF, IB4C. DDDDD
9. Octal uses 3 bits and hex uses 4 bits. (What would a quad number system, which utilizes only 2
bits. look Iike?) Construct a table ofcomparison values to decimal.
Data Handling Functions

t4 The PLC SKIP and MASTER


CONTROL RELAY Functions
15 Jump Functions
16 PLC Data Move Systems
17 Other PLC Data Handling Functions
The PLC SKIP and
MASTER CONTROL
RELAY Functions

OUTI,INE
l4-1 Introduction r: l4-2'lhe SKIP Funclion and Applicarions rr 1+3 The IVIASTER
CONTROL RELAY Funcrion and Applicarions

OBJECTIVES
At the end of this chapter. you will be able to
E Describe the operation of the SKIP function.
D Describe the operarion of the MASTER CONTROL RELAY function
. Apply the SK and MCR functions to operarional applications.

231
232 THE PLC SKIP AND MASTER CONTROL RELAY FUNCTIONS

t4-l INTRODUCTION
Both the SKIP (SK) and MASTER CONTROL RELAY (MCR) functions are powerful
programming tools. The SK iunction allows us to skip, or bypass, a chosen portion of a
ladder sequence. The coils and functions skipped remain in the state they were in during the
last scan before SK was enabled. SKIP enables us to effectively branch to a different por-
tion of the program. In some programming systems, SKIP is called ZCL (zone control last
state). In many PLCs the SKIP function is carried out by a JUMP programming system,
which is covered in chapter 15.
MCR operates similarly. When MCR is enabled on, the ladder diagram functions
normally. When MCR is not enabled, a speci{ied number of coils and functions are frozen
in the off position. Coils in the frozen section will then stay off even if their individual
enable lines are tumed on. In some systems. MCR means Master Control Reset (nol
Relay).
The difference between the two fulctions is that SKIP leaves the next specified num-
ber of ladder lines in their previous on or off state. MCR turns the next specified number of
ladder lines to the off state. Another difference is that SKIP is active when enabled aod
MCR is active when not enabled. which makes it fail-safe.

t4-2 THE SKIP FUNCTION AND APPLICATIONS


The SKIP (SK) function, illustrated in figure 14-1, allows a portion of a PLC program to
be bypassed when its coil is enabled. The enable line of the lunction is energized when th€
skip of one or more subsequent lines is desired. In addition to programming a coil number
in the usual manner, the number of lines to be skipped is also specilied and programmed as
shown.
Figure l4-2 shows a basic application ofthe SKIP tunction in a program. The eight-
line program used for illustration has seven lines with output f'unctions. A SKIP function is
included on the third line of the eighrline program. When the SK function is off, the othcr
seven functions operate in the normal manner When the seven lines corresponding to
inputs are on, their outputs are on, and when inputs are otl, outputs are off. For thir
illustration, the value for number of lines to be skipped will be set al 3.
When the SKIP function (set at 3) is tumed on, the 6rst two lines will function r
usual. However, the next three lines, 4 through 6, will stay on or olf in their previous slatc-
With SKIP on, changing the input on-off status feeding the coils on lines 4 through 6

FIGURE T+I y',--- Coil Numbet


SKIP Function
sK0216
cR0013 0003 + Numberd
Enable lines to b
skipped
THE SKIP FUNCTION AND APPI-ICATIONS 233

t- RE l+2 Enabling Contacls


Function PLC Operation tN0054 cR0083
Line No
1

1N0055 c80084
2

sK0046
tN0056 0003
3

tN0057 cR0085
4
Three lines
c80086 skipped when
tN0058
5 SK0046 is on;
Coils remain in
cR0087 last state ' on
rN0059
o, of,
6

rN0060 CR
7

tN0061 cR0089
8

hare no el}'ect on output coils 4 through 6. Coils on lines 4 through 6 will retain their
previous states. Lines 7 and 8 will continue to operate normally. unaffected by the SKIP
f'unction's operation. Lines 7 and 8 could also be skipped if we had inserted a 5 in place of
3 as the number of lines to be skipped by the function. When SKIP is turned off. the ladder
will operate normally.
For an illustration of the SKIP function. we apply it to a production line. The
production line has eight stations, each of which can perform an assembly operation as the
product comes doun the line. Depending on the individual parl number, all of the eight
operations may or may nol be set up and carried out. The pattem of whether or not the
operations are to be set up and performed is stored in registers, as explained in detail in
chapter 18. Each of the eight stations is sel up to operate or not. according to register bit
statuses. A bil of I says tum the setup on, and a 0 says turn the setup off.
At the third station. an inspection takes place. If the pan is good, it continues down
the operating line: if it is bad, it is shunted to a side conveyor and repaired. After repair, the
part reenters at the beginning of the conveyor. The product flow and conveyor layout are
shown in figure 1.1-3.
When a part arrives at the beginning ofthe line, a sensor (not shown) detects the pres-
ence of the parts at the beginning of the conveyor and causes the eight stations to be set up
for operation. The sensor causes register contents to turn each of the eight setup switch
234 TH E P LC SK P N D M AS TE R CO N TRO l_ R EL Y F U CT oN S

Set Up: 1 lo 8 Product Flow

Set Up: 4 lo 8
Skip 1 1o 3 Reenter
Station Starl
Slation
Numbers Numbers
E
1
CE

(f
2 2

Beject Reiect.
3
o
4 4
OK Check Point

5 b
a'

6 6 o

7 7
i
8 8

Product Flow Statlon Layoul

FIGURE I+3
SKIP Function APPIication Layoui

B P'tlR con tact o n o off Fi ure 44 h ows th S SC up s v


S te m on the
c o n tac tS the
h p art proc eeds dow n the con
T he e tu p functi on S are CR 004 through CR 0048
at eac h
e ac h operatlo n S performed f set up
p
hen the art detected by sensors
on the right of figure l4-4.
These sensors are IN0021 through N00 2 8 a S hown
o peratrons iue CR006 thro ugh C R 0068
f a P art S IE.,ec ted a S tati on 3 shu n ted to repal r. L ate r, hen the ep aired
do n ot h a to be reset U
reenters the conveyor, the setups of stations I throu h 3
and 0060 The o S K function
sary retest is prevented by the two SK functions' 00
turned on by a sensor at the repair reentry Point'

l4:3 THE MASTER CONTROL RELAY


FUNCTION AND APPLICATIONS
The MASTER CONTROL RELAY (MCR) funct o n ope at on s s m ar to rh
function Fi ure 4-5 h ows a v cal
p M CR functi on. Whe n ts en ab le li ne S energl zed
of fo llow n adder diagram lines sPecl fi ed
turns oo When MCR is off, the nu mber
Sel Up Operate

I
-5 sK0011 sK0060
tN0051 0003 051 0003
a. Slation Skip Alter
8P0001 Bepair
1R0307
cR0041 rN0021 cR0061 Only
$
8P0002
tR0307 cB0c42 tN0022 cR0062
:. 2
8P0003
tR0307 cR0043 tN0023 c80063
3
8P0004
t80307 cR0044 tN0024 cR0064
4
BP0005
t80307 cR0045 tN0025 CR 65
c. 5
BP0006
180307 cR0046 tN0026 cR0066
6
8P0007
1R0307 cR0047 tN0027 c 7
7
8P0008
1R0307
cR0048 1N0028 cR0068
+ 8

Set-Up j Operate
Switches Proximity
Switches
Typical ReOister - 1R0307 (8 Bit)

8+21
1010 1101

14-4
{pplication Program

R_E l4-5 Coil Number


Function /,,-
MR0111
tN0073 0003
Enable
Number of lines
to be turned otf

235
236 THE PLC SKTPAND MASTER CONTROL RELAY FUNCTIONS

tumed off. In contrast to the SK operation, where lines were skipped, the MCR turns
following specified number of lines to the off state. In many PLCs, the MCR function
off only the nonretentive outputs in the zone. All retentive functions are unaffected u
this system.
Figure 14-6 shows how the MCR function oPerates in a program. There are ei
lines. The third line is the MCR function. The other seven lines are contact-coil fu
tions. For fail-safe reasons. the MCR must be turned on to be inactive. [f the func
goes off for some reason, it is active and turns the specified lines off. also. When M
is on, the other seven lines operate normally. When MCR is off. the next three lines.
through 6, are turned off. Lines l. 2, 7, and 8 are unaffected. With MCR ofi there is
way to turn on coils 4 through 6 by energizing their enable lines. When MCR is
on, the ladder operates in the normal manner
A production line example similar to the SK example will be used for the M
application illustration. There are again eight production stations. Whether each sta
operates for a given part number as the Part goes past depends on the setup (not sh
Each station's operation is initiated by proximity switches at each station
proximity switches are lN008l through IN0088. Figure l4-7 shows the production I
Iayout and product flow.

FIGURE I4-6 Li ne No
MCR Function PLC Operation I tN0201
cR0031

1N0202 cR0032
2

MCB0132
tN0203 0003
3

1N0204
cR0033
4

tN0205 cR0034 Three lines ifievocably


turned otl when
MCF|o132 is ofl
rN0206 cR0035
6

tN0207 c
7

1N0208 cR0037
8
TROUBLESHOOTING PROBLEMS 237

lrcr'RE l+7 Set Up: 1 to I Product Flow


XR.{pplication Layout

Stan Reenter
SetUp6toS Station
Skip 1 to 5 Numb6rs

1
6
o
G, (I
2

Repair Reiect
o
6
Check Point

Product Flow Station Layout

Station 5 is an inspection station. Rejected pans are shunted to a repait conveyor.


After repair, the part reenters the conveyor. When it reenters, it turns on IN00l l, which
turns on and seals an MCR relay, CR002l. The first five steps are therefore not repeated
for the part, because the first five operations are prevented by the MCR. When the parl
gets to station 5, the MCR is unseated. The part then continues through stations 6, 7, and
8. These last three steps were not performed the first time through, but are now
performed to complete the process. The MCR program fo, these operations is shown in
figure l4-8.

TROUBLESHOOTING PROBLEMS
TS l4-l You have s€t up a SKIP program similar to that shown in figure l4-2. The three lines are
skipped whell the pro$am is first tumcd on. what could be wrong?
TS l4-2 You have set up an MCR plogram similar to that shown in ngure 14-6. The three lines are
still on when the progtam is tumed on. What could be wrong?
23E THE PI-C SKIP A.ND N{ASTER CONTROL RELAY FUNCTIoNS

FICURE IlLS [rcR0021


N'lCR Applicittion Progranr tN0011 0005
Shut otl after
Repair ooly
MCR0021 rN0085

Stalion
tN0081 cR0141
1

tN0082 cR0142
2

tN0083 cR0r 43
3

rN0084
cR0144
4

tN0085 cR0145
5

rN00B6 cR0146
6

tN0087 cR0147
7

tN0038
cR0148
8

Operate
Proximily
Swilches

EXERCISES
l. For the I2ladder line program in figure 1,1-9. insen three sK lunctions one al a time. The firsr
problem is to skip lines 3 through 5. The second Problem is to skip lines 8 and 9.'Ihe third is lo
skip lines 3 through I l. Progiam them and check out their operation. \\'hen tlre SK function is on'
changing inpul status should nol affecl the previous status oI outputs li)r lhe line: lo be skipped.
As an added problem, insec the line 8 and 9 skip and alto the line I throuch Il skip at Ihe samc
time. What happens when either one or both are tumed on l
2. Repeat exerciseI using the IvtCR function instead ofthe SK function. when MCR is on. all MCR-
dcsignated lines should be off. Additionally. changing any conlrol line s input status fot
MCR-controlled lines should have no effecl on its output. Repeat the added problem in exercise l.
u.ing MCR inslead of SK.
EXERCISES 239

FIGURE l,l-9
Diagram for Exercise I 1N0001 cR0017

tN0002 cR0018

t
3 through
tN0011
10 similar cR0027
I
tN0012 cR0028

3. Devise an MCR system to conrol the assembly line shown in figure I.l-10. All 15 stations are lo
function as set up by one of two registers. Shon and tall pans a.e sent down the line. Shon parts
get all l5 operations, if specified. Lines 6 through 9 are omitted for the tall parts onl),. Thdrefore.
have operations 6 through 9 turned offby an MCR function when a tall pan goes by. Tallpans are
detected by a limit switchjust after station 5. After starion 9. another limit switch unseals rhe MCR
lunction. so the next pan, whether shon or tall. goes through the proper process.

For
Tall Pans
OnlY

-#- Patlern A
I, l,].i.1.1. l, l, l'
On On Otf On On On On Ofi On
1,,1,, 1,,1,,1,.1,'l
Ofl Ofi On OnOfiO n Small
Pattern B Otf Otf On On On Otl On On Otl On On Otf OflOnO n Large

Pattern A is tor a product ol tall and short parls.


Pallern B is for another product of tall and short parts.

FIGURE I+IO
Diagram for Exercise 3

r
$

Potrebbero piacerti anche