Professional Documents
Culture Documents
I
C
R
O
M
E
N
T
O
R
M
i
c
r
o
M
e
n
t
o
r
U
n
d
e
r
s
t
a
n
d
i
n
g
a
n
d
A
p
p
l
y
i
n
g
M
i
c
r
o
P
r
o
g
r
a
m
m
a
b
l
e
C
o
n
t
r
o
l
l
e
r
s
Understanding and Applying
Micro Programmable Controllers
Mi c r oMent or
Understandi ng and Applyi ng
Mi cro Programmable Controllers
Soli d state equi pment has operati onal characteri sti cs di fferi ng from those of
electromechani cal equi pment. Safety Gui deli nes for the Appli cati on, I nstallati on
and Mai ntenance of Soli d State Controls ( Publi cati on SGI -1.1, Allen-Bradley Company)
descri bes some i mportant di fferences between soli d state equi pment and hard-wi red
electromechani cal devi ces. Because of thi s di fference, and also because of the wi de
vari ety of uses for soli d state equi pment, all persons responsi ble for applyi ng thi s
equi pment must sati sfy themselves that each i ntended appli cati on of thi s equi pment
i s acceptable.
I n no event wi ll the Allen-Bradley Company be responsi ble or li able for i ndi rect or
consequenti al damage resulti ng from the use or appli cati on of thi s equi pment.
T he examples and di agrams i n thi s book are i ncluded solely for i llustrati ve purposes.
Because of the many variables and requirements associated with any particular installation,
the Allen-Bradley Company cannot assume responsi bi li ty or li abi li ty for actual use based
on the examples and di agrams.
Reproducti on of the contents of thi s book, i n whole or i n part, wi thout wri tten
permi ssi on of the Allen-Bradley Company i s prohi bi ted.
1995 Allen-Bradley Company, I nc. Pri nted i n USA
TM
T he mi cro symbol i s a trademark of Allen-Bradley Company, I nc., a Rockwell I nternati onal company
Page
Pr ef ace . . . . . . . . . . . . . . . . . . . . . . . . . . .vi i
Chapt er 1
Int r oduct i on t o PLCs
1.0 Hi story of PLCs. . . . . . . . . . . . . . . . . . . 2
1.1 Why Use a PLC?. . . . . . . . . . . . . . . . . . .4
1.2 Tradi ti onal PLC Appli cati ons. . . . . . . . . 5
Chapt er 2
The Mi cr o PLC
2.0 Development of the Mi cro PLC . . . . . . 8
2.1 What Makes a Mi cro PLC a Mi cro? . . . 10
2.2 Capabi li ti es Overvi ew . . . . . . . . . . . . . 13
2.3 Mi cro PLC Appli cati ons. . . . . . . . . . . . 14
Chapt er 3
Mi cr o PLC Oper at i on
3.0 Components Overvi ew. . . . . . . . . . . . . 18
3.1 I nputs. . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2 Outputs . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Central Processi ng Uni t CPU . . . . . . 21
3.4 Types of Appli cati on Memory . . . . . . . 22
3.5 Data, Memory and Addressi ng. . . . . . . 23
3.6 Operati ng Cycle. . . . . . . . . . . . . . . . . . 24
3.7 Power Suppli es . . . . . . . . . . . . . . . . . . 26
3.8 Programmi ng Devi ces . . . . . . . . . . . . . 28
3.9 Operator I nterfaces. . . . . . . . . . . . . . . 30
T
A
B
L
E
O
F
C
O
N
T
E
N
T
S
Page
Chapt er 4
Ladder Logi c Fundament al s
4.0 Programmi ng Languages. . . . . . . . . . . 34
4.1 Electri cal Ladder Di agrams. . . . . . . . . 35
4.2 Ladder Logi c Programs. . . . . . . . . . . . 36
4.3 Ladder Logi c I nstructi ons . . . . . . . . . . 39
4.4 Combi ni ng I nstructi ons. . . . . . . . . . . . 44
4.5 Program Executi on . . . . . . . . . . . . . . . 49
Chapt er 5
How t o Appl y a Mi cr o PLC
5.0 What i s a Potenti al
Control Appli cati on? . . . . . . . . . . . . . . 52
5.1 What are the Appli cati ons
Requi rements?. . . . . . . . . . . . . . . . . . . 53
5.2 Selecti ng a Control Method. . . . . . . . . 60
5.3 What are the PLC Speci fi cati ons? . . . . 66
5.4 Program Development Procedures. . . . 70
5.5 I nstallati on Requi rements . . . . . . . . . . 80
Page
Chapt er 6
Commi ssi oni ng and Tr oubl eshoot i ng
6.0 Commi ssi oni ng. . . . . . . . . . . . . . . . . . . 84
6.1 Troubleshooti ng Overvi ew. . . . . . . . . . 86
6.2 Fi ndi ng the Problem . . . . . . . . . . . . . . 87
6.3 Troubleshooti ng the PLC. . . . . . . . . . . 88
6.4 Troubleshooti ng I /O . . . . . . . . . . . . . . . 88
6.5 Program Troubleshooti ng . . . . . . . . . . 91
6.6 Faults. . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.7 Safety. . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.8 Troubleshooti ng Model. . . . . . . . . . . . . 93
Chapt er 7
Appl i cat i on Exampl es
7.0 I ntroducti on. . . . . . . . . . . . . . . . . . . . . 96
Basi c Logi c
7.1 OR Ci rcui t . . . . . . . . . . . . . . . . . . 96
7.2 AND Ci rcui t . . . . . . . . . . . . . . . . . 97
7.3 Start/Stop Ci rcui t . . . . . . . . . . . . 98
7.4 Fli p/Flop Ci rcui t . . . . . . . . . . . . 100
7.5 Alarm Ci rcui t . . . . . . . . . . . . . . . 102
7.6 Start/Stop wi th Jog . . . . . . . . . . 104
Page
T i mi ng and Counti ng
7.7 On Delay . . . . . . . . . . . . . . . . . 106
7.8 Off Delay . . . . . . . . . . . . . . . . . 108
7.9 One Mi nute Clock. . . . . . . . . . . 110
7.10 Up/Down Counti ng . . . . . . . . . 112
Data I nstructi ons
7.11 Movi ng Data. . . . . . . . . . . . . . . 114
7.12 Compari ng Data. . . . . . . . . . . . 117
7.13 Math Commands . . . . . . . . . . . 120
Advanced I nstructi ons
7.14 Sequencers. . . . . . . . . . . . . . . . 123
7.15 FI FO . . . . . . . . . . . . . . . . . . . . 125
7.16 Hi gh-Speed Counter . . . . . . . . 128
7.17 Two Stage Alternator. . . . . . . . 129
7.18 T hree Stati on Alternator . . . . . 133
Appendi ces
Glossary . . . . . . . . . . . ( Appendi x A) . . . 142
I nput and
Output Devi ces . . . . ( Appendi x B) . . . 153
I nstructi on
Executi on T i mes . . . ( Appendi x C) . . . 161
Sample Program
Worksheets . . . . . . . ( Appendi x D) . . . 164
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Welcome to Mi croMentor Understandi ng
and Applyi ng Mi cro Programmable
Controllers. I n less than a decade, mi cro
PLCs have gone from a bluepri nt to one of the
fastest growi ng segments of the control products
market. Unfortunately, scant li terature exi sts
about mi cro PLCs. I n addi ti on, many of the
current PLC text books are too cumbersome
for todays busy personnel.
Wi th those thoughts i n mi nd, Allen-Bradley
produced thi s book as an i ntroducti on to mi cro
PLCs for the desi gn engi neer, electri cal techni ci an
and mai ntenance person wi th li ttle or no
background i n programmable logi c controls.
Readers wi ll qui ckly learn about the mi cro PLCs
evoluti on, capabi li ti es, operati on, and advantages
over other control opti ons. Non-speci fi c to
any manufacturer, the text also covers basi c
programmi ng, i nstructi ons, appli cati on
examples, and troubleshooti ng.
Wri tten to be easi ly understood, the
M i croM entor can augment classroom materi al,
and i t can serve as a supplement to the operator
manuals and techni cal data suppli ed by mi cro
PLC manufacturers.
T he authors hope that those experi enced wi th
mi cro PLCs wi ll use thi s book as a trai ni ng ai d, and
that Mi croMentor prompts all readers to ask, What
i s the best control soluti on for my appli cati on?
Good Luck!
P
R
E
F
A
C
E
vi i
Hi story of PLCs . . . . . . . . . . . . . . . . . . . . 1.0
Why Use a PLC?. . . . . . . . . . . . . . . . . . . . 1.1
Tradi ti onal PLC Appli cati ons . . . . . . . . . . 1.2
C
H
A
P
T
E
R
Int r oduct i on t o PLCs
1
1
1
1.0
Hi st or y of PLCs
A programmable logi c controller ( PLC) i s an electroni c devi ce that
controls machi nes and processes. I t uses a programmable memory to
store i nstructi ons and execute speci fi c functi ons that i nclude On/Off
control, ti mi ng, counti ng, sequenci ng, ari thmeti c, and data handli ng.
PLC development began i n 1968 i n response to a request from the
Hydramati c Di vi si on of General Motors. At the ti me, GM frequently
spent days or weeks replaci ng i nflexi ble relay-based control systems
whenever i t changed car models or made li ne modi fi cati ons. To reduce
the hi gh cost of rewi ri ng, GMs control speci fi cati on called for a soli d
state system that had the flexi bi li ty of a computer, yet could be
programmed and mai ntai ned by plant engi neers and techni ci ans. I t
also had to wi thstand the di rty ai r, vi brati on, electri cal noi se, humi di ty
and temperature extremes found i n the i ndustri al envi ronment.
T he first PLCs were installed in 1969 and quickly became a success.
Functioning as relay replacements, even the early PLCs were more reliable
than relay-based systems, largely due to the ruggedness of their solid state
components compared with the moving parts in electromechanical relays.
PLCs provided material, installation, troubleshooting and labor cost savings
2 2
3
1
3
An early PLC
Fi g. 1-1 Typi cal electri cal ladder di agram
by reducing wiring and associated wiring
errors. T hey took up less space than
the counters, timers and other control
components they replaced. And their ability
to be reprogrammed dramatically increased
flexibility when changing control schemes.
Perhaps the bi ggest key to i ndustrys
acceptance of the PLC was that the i ni ti al
programmi ng language was based on the
ladder di agrams and electri cal symbols
commonly used by electri ci ans ( see
Fi g. 1-1) . Most plant personnel were already
1
trai ned i n ladder logi c, and they easi ly adopted i t for PLCs. I n fact, ladder
logi c sti ll plays an i ntegral role i n programmi ng and troubleshooti ng,
even though more advanced programmi ng languages have been
developed.
1.1
Why Use a PLC?
Should we be usi ng a programmable logi c controller? Duri ng the
1970s and early 80s, many engi neers, manufacturi ng managers and
control system desi gners spent consi derable ti me debati ng thi s i ssue,
tryi ng to evaluate cost effecti veness.
Today, one generally accepted rule i s that PLCs become economi cally
vi able i n control systems that requi re three to four or more relays.
Gi ven that mi cro PLCs cost only a few hundred dollars, coupled wi th
the emphasi s manufacturers place on producti vi ty and quali ty, the cost
debate becomes almost i mmateri al.
I n addi ti on to cost savi ngs, PLCs provi de many value-added benefi ts:
Reli abi li ty. Once a program has been wri tten and debugged, i t can
be easi ly transferred and downloaded to other PLCs. T hi s reduces
programmi ng ti me, mi ni mi zes debuggi ng, and i ncreases reli abi li ty.
Wi th all the logi c exi sti ng i n the PLCs memory, theres no chance of
maki ng a logi c wi ri ng error. T he only wi ri ng requi red i s for power and
i nputs and outputs.
Flexi bi li ty. Program modi fi cati ons can be made wi th j ust a few key
strokes. OEMs ( ori gi nal equi pment manufacturers) can easi ly
4 4
1
i mplement system updates by sendi ng out a new program i nstead of
a servi ce person. End-users can modi fy the program i n the fi eld, or,
conversely, OEMs can prevent end-users from ti nkeri ng wi th the
program ( an i mportant securi ty feature) .
Advanced functi ons. PLCs can perform a wi de vari ety of control
tasks, from a si ngle, repeti ti ve acti on to complex data mani pulati on.
Standardi zi ng on PLCs opens many doors for desi gners, and si mpli fi es
the j ob for mai ntenance personnel.
Communications. Communi cati ng wi th operator i nterfaces, other
PLCs or computers faci li tates data collecti on and i nformati on exchange.
Speed. Because some automated machi nes process thousands of
i tems per mi nute and obj ects spend only a fracti on of a second
i n front of a sensor many automati on appli cati ons requi re the
PLCs qui ck response capabi li ty.
Di agnosti cs. T he troubleshooti ng capabi li ty of programmi ng devi ces
and the di agnosti cs resi dent i n the PLC allow users to easi ly trace
and correct software and hardware problems.
1.2
Tr adi t i onal PLC Appl i cat i ons
No matter what the appli cati on, the use of PLCs helps i ncrease
competi ti veness. Processes usi ng PLCs i nclude: packagi ng, bottli ng
and canni ng, materi al handli ng, machi ni ng, power generati on,
HVAC/bui ldi ng control systems, securi ty systems, automated assembly,
pai nt li nes, and water treatment. PLCs are appli ed i n a vari ety of
5 5
1
i ndustri es, i ncludi ng food and beverage, automoti ve, chemi cal, plasti cs,
pulp and paper, pharmaceuti cals, and metals. Vi rtually any appli cati on
that requi res electri cal control can use a PLC.
6 6
Wastewater treatment faci li ty
Papermaki ng operati on
Tradi ti onal PLC
appli cati ons
Development of the Mi cro PLC . . . . . . . . 2.0
What Makes a Mi cro PLC a Mi cro?. . . . . . 2.1
Capabi li ti es Overvi ew. . . . . . . . . . . . . . . . 2.2
Mi cro PLC Appli cati ons . . . . . . . . . . . . . . 2.3
2
C
H
A
P
T
E
R
The Mi cr o PLC
7
2
2.0
Devel opment of t he Mi cr o PLC
Unti l the i ntroducti on of the mi cro PLC i n the mi d 1980s, the
potenti al to i ncrease automati on on si mple machi nes or less complex
processes remai ned largely untapped. T hi s was due to the lack of
attracti ve alternati ves to hardwi red relay control.
T hough OEMs had benefi tted by usi ng PLCs to control equi pment,
process li nes, or even whole plants, they could not always j usti fy usi ng
a PLC on small appli cati ons and low-cost machi nes. And i f cost was not
an i ssue, si ze often was. Someti mes even small PLCs were si mply too
large to fi t i n the space allocated for electri cal controls.
As such, the dri vi ng force behi nd the development of the mi cro PLC
was the demand by OEMs for a PLC that was small and i nexpensi ve
enough to replace relays, dedi cated ti mers and counters, and si ngle
board controllers. For a $5, 000 machi ne, a small PLC control system
costi ng $1, 000 i s not economi cal. However, at a few hundred dollars,
a mi cro PLC i s cost effecti ve and provi des all the benefi ts of tradi ti onal
PLC logi c control.
PLCs have followed a product development curve si mi lar to that
of the personal computer; early PLCs were large, cost thousands of
8
2
dollars, and had relati vely few features. But wi th the evoluti on of
mi croprocessors and other board-level components, PLCs grew i n
sophi sti cati on whi le si ze and cost shrank. I n fact, advanced features
that were consi dered stri ctly i n the domai n of medi um-si ze PLCs fi ve
years ago are now common i n mi cro PLCs.
Typical Micro PLC Features
Math capabi li ti es
Data handli ng i nstructi ons
9
Shown near actual si ze, a 16 I/O mi cro PLC. Hundreds of electromagneti c relays would
be needed to obtai n an equi valent level of control.
2
Hi gh-speed counti ng
BCD to bi nary conversi on routi nes
Drum ti mer and sequencer functi onali ty
Subrouti nes and i nterrupts
Programmed wi th a personal computer
Communi cati on wi th other electroni c devi ces
10
2.1
What Makes a Mi cr o PLC a Mi cr o?
Several cri teri a are used to categori ze PLCs as mi cro, small, medi um
or large. Cri teri a i nclude functi onali ty, number of i nputs and outputs
( see Fi g. 2-1) , cost, and physi cal si ze.
Fi g. 2-1 I/O count i s the most common method of categori zi ng PLCs.
2
Generally speaki ng, mi cro PLCs share the followi ng characteri sti cs:
32 I /O
Cost <$500
1K of memory
Small si ze, roughly:
- 5" ( 127 mm) long x 3" ( 76 mm) hi gh x 3" ( 76 mm) deep ( 16 I /O)
- 8" ( 203 mm) long x 3" ( 76 mm) hi gh x 3" ( 76 mm) deep ( 32 I /O)
Mi cro PLCs come as self-contai ned uni ts wi th the processor, power
supply, and I /O all i n one package. Because they are self-contai ned,
mi cro PLCs are also known as packaged controllers. A modular PLC i s
one that has separate components that i nterconnect. T he advantage of
11
A 32 I/O packaged mi cro controller i s consi derably more compact than a 32 I/O
modular controller.
2
Rel ay l ogi c i nst r uct i ons
examine if closed (normally open contacts)
examine if open (normally closed contacts)
output energize (coils)
output latch
output unlatch
one-shot rising
Ti mer s
on-delay timer
off-delay timer
retentive timer
Up and dow n count er s
Hi gh-speed count er
Mat h
add
subtract
divide
multiply
clear
square root
Bool ean l ogi c
AND, OR, Exclusive OR, NOT, Negate
Compar i son
=, , <, , >,
limit
Dat a handl i ng
move, masked move
FIFO and LIFO (First-In First-Out; Last-In First-Out)
BCD to binary conversion
binary to BCD conversion
Appl i cat i on speci f i c i nst r uct i ons
sequencer
bit shift
Pr ogr am f l ow
subroutine
MCR (master control reset)
immediate input or output with mask
selectable timed interrupt
jumps
12
Fi g. 2-2 The i nstructi on set of a typi cal mi cro PLC.
2
a packaged controller i s that the all-i n-one package i s smaller, less costly,
and conveni ent to i nstall ( see photo-p.11) . However, few packaged
controllershave expandable I /O capabi li ti es, where all modular
controllers can be expanded easi ly by addi ng more I /O cards to the rack.
2.2
Capabi l i t i es Over vi ew
A PLCs capabi li ti es are determi ned by the type of commands a
user can i nstruct i t to execute. Whi le the i nstructi on set and names of
i nstructi ons wi ll vary sli ghtly among mi cro PLC manufacturers, Fi g. 2-2
gi ves an overvi ew of the i nstructi ons commonly avai lable.
As has been noted, PLCs were i ni ti ally desi gned to functi on as
electroni c replacements for hardwi red control devi ces pri mari ly
relay coi ls and contacts, counters and ti mers. Today, these functi ons
sti ll compri se the maj ori ty of i nstructi ons used i n mi cro PLC
appli cati ons.
By way of example, i magi ne desi gni ng a control system for a
conveyor i n a food packagi ng operati on. Based on the status of fi eld
devi ces, a PLC can start a conveyor, sense the presence of a box,
move the box forward to the desi red posi ti on, hold i t there for a
predetermi ned fi lli ng ti me, and count the number of full boxes comi ng
off the li ne.
Mi cro PLCs also open up new control possi bi li ti es wi th advanced
functi ons such as: four-functi on math, data compari son ( i .e., equal to,
greater than, etc.) , data handli ng ( such as parts sorti ng or fault tracki ng) ,
sophi sti cated subrouti nes, sequenci ng ( replaci ng drum sequencers) ,
13
2
and other features that experi enced control system desi gners can
appreci ate. To demonstrate the value of these features, appli cati on
examples are provi ded i n Chapter 7.
Possi bly the most exci ti ng feature of mi cro PLCs i s thei r hi gh-speed
counti ng capabi li ti es. Speed, the key to success for many automated
appli cati ons, can also cause problems i f the speed of the PLC cannot
keep up wi th the manufacturi ng operati on. For example, i f parts or
materi al are movi ng at hi gh speed past a proxi mi ty sensor, a normal
PLC counter could mi ss some parts. T hi s i s because the parts are
movi ng faster than the PLC scans the sensors i nput.
However, a hi gh-speed counter operates i ndependently of the
program scan. T hi s enables i t to count at a much faster rate, typi cally
2, 000 to over 6, 000 ti mes per second. I n addi ti on, some hi gh-speed
counters can energi ze an output i mmedi ately ( i .e., wi thout havi ng to
wai t for the normal program scan ti me) , thus substanti ally i mprovi ng
speed and performance. T hi s enables the counter to affect control
operati ons when spli t-second accuracy i s cri ti cal.
2.3
Mi cr o PLC Appl i cat i ons
Mi cro PLCs are i deal for controlli ng stand-alone, di screte machi nery
or processes. Many appli cati ons that are presently controlled by relays
and/or custom si ngle board controls are mi grati ng toward mi cro PLCs.
Mi cro PLC appli cati ons are consi dered i n detai l i n Chapter 5 ( How to
Apply a Mi cro PLC) and Chapter 7 ( Appli cati on Examples) .
14
15
2
Canni ng operati on
Typi cal mi cro
PLC appli cati ons
Packagi ng machi ne
Components Overvi ew . . . . . . . . . . . . . . . 3.0
I nputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1
Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . .3.2
Central Processi ng Uni t CPU. . . . . . . . . 3.3
Types of Appli cati on Memory. . . . . . . . . . 3.4
Data, Memory and Addressi ng. . . . . . . . . 3.5
Operati ng Cycle . . . . . . . . . . . . . . . . . . . . 3.6
Power Suppli es. . . . . . . . . . . . . . . . . . . . . 3.7
Programmi ng Devi ces. . . . . . . . . . . . . . . . 3.8
Operator I nterfaces . . . . . . . . . . . . . . . . . 3.9
C
H
A
P
T
E
R
Mi cr o PLC Oper at i on
3
17
3
3.0
Component s Over vi ew
I n order to learn how PLCs operate, a qui ck overvi ew of PLC
components i s necessary. All PLCs from mi cro to very large use
the same basi c components and are structured i n a si mi lar fashi on. PLC
systems consi st of:
I nputs
Outputs
Central processi ng uni t ( CPU)
Memory, for program and data storage
Power supply
Programmi ng devi ce
Operator i nterfaces
3.1
Input s
T he i nput screw termi nals on a PLC form the i nterface by whi ch
fi eld devi ces are connected to the PLC.
18
3
I nputs i nclude i tems such as pushbuttons, thumbwheel swi tches,
li mi t swi tches, selector swi tches, proxi mi ty sensors and photoelectri c
sensors. T hese are all di screte devi ces that provi de an On or Off status
to the PLC. Whi le larger PLCs can di rectly accept analog values ( vari able
voltage or current si gnals) such as from temperature or pressure sensors,
mi cro PLCs do not typi cally possess thi s capabi li ty.
T he electri cal si gnals that fi eld devi ces send to the PLC are typi cally
unfi ltered 120V ac or 24V dc. T he i nput ci rcui try on the PLC takes thi s
fi eld voltage and condi ti ons i t to be usable by the PLC. Condi ti oni ng
i s necessary because the i nternal components of a PLC operate on
5V dc, and thi s mi ni mi zes the possi bi li ty of damage by shi eldi ng them
from voltage spi kes. To electri cally i solate the i nternal components
from the i nput termi nals, PLCs employ an opti cal i solator, whi ch uses
19
Programming/
Communication
Devices
Central
Processing
Unit
I
N
P
U
T
C
I
R
C
U
I
T
S
C
I
R
C
U
I
T
S
O
U
T
P
U
T
CR
Optical
Isolation
MEMORY
program data
Optical
Isolation
Power Supply
Fi g. 3-1 Control of a machi ne or process entai ls moni tori ng the status of devi ces
connected as i nputs and, based on a user-wri tten program, controlli ng devi ces
connected as outputs.
3
li ght to couple si gnals from one electri cal
devi ce to another.
T he PLCs i nput ci rcui try also fi lters
fi eld voltage si gnals to quali fy them as vali d,
such as a si gnal from a sensor, or not vali d,
such as hi gh-frequency electri cal noi se or
stati c. I nput fi lters determi ne the vali di ty of
a si gnal by i ts durati on; they wai t to
confi rm that a si gnal i s a reference from
an i nput devi ce rather than electri cal noi se.
A typi cal fi lter ti me i s 8 ms, but some PLCs
have adj ustable i nput fi lter response ti mes. A
longer response ti me provi des better fi lteri ng
of electri cal noi se. A shorter response ti me
helps i n appli cati ons that requi re hi gh-speed
operati on ( e.g., i nterrupts or counti ng) .
3.2
Out put s
Connected to the output termi nals of the
PLC are devi ces such as solenoi ds, relays,
contactors, motor starters, i ndi cator li ghts,
valves and alarms. Output ci rcui ts operate
i n a manner si mi lar to i nput ci rcui ts: si gnals
from the CPU pass through an i solati on
barri er before energi zi ng output ci rcui ts.
Assorted I/O devi ces. See Appendi x B for a
more thorough descri pti on of I/O devi ces.
20
Transi stor, relay and triac for PLC output
circuitry. Paper clip indicates relative size.
3
PLCs use a vari ety of output ci rcui ts to energi ze thei r output
termi nals: relays, transi stors and tri acs.
Relays are for ei ther ac or dc power. Tradi ti onal PLC electromagneti c
relays typi cally handle current up to a few amps. Relays can better
wi thstand voltage spi kes, and they have an ai r gap between thei r con-
tacts whi ch eli mi nates the possi bi li ty of current leakage. However,
they are comparati vely slow and subj ect to wear over ti me.
Transi stors swi tch dc power, are si lent and have no movi ng parts to
wear out. Transi stors are fast and can reduce response ti me, but only
carry loads of 0.5 amp or less. Speci al types of transi stors, such as
FETs ( Fi eld Effect Transi stors) can handle more power, typi cally up
to 1 amp.
Tri acs stri ctly swi tch ac power. Li ke transi stors, tri ac outputs are
si lent, have no movi ng parts to wear, are fast, and carry loads of
0.5 amp or less.
Note: soli d state outputs ( tri acs and transi stors) can be damaged or
destroyed by over-voltage or over-current.
3.3
Cent r al Pr ocessi ng Uni t CPU
T he CPU, made up of a microprocessor and a memory system, forms the
primary component of the PLC. T he CPU reads the inputs, executes logic as
dictated by the application program, performs calculations, and controls the
outputs accordingly.
PLC users work wi th two areas of the CPU: program fi les and data
fi les. Program fi les store a users appli cati on program, subrouti ne fi les,
21
3
Even though EEPROM
and RAM memory can save
appli cati on programs i f power
i s lost, they do not necessari ly
save process data, such as the
accumulated value of a ti mer
or counter. If retai ni ng process
data i s i mportant for an
appli cati on, look for a mi cro
PLC that offers 100 percent
data retenti on. Upon power loss,
thi s type of PLC automati cally
saves process data to the
nonvolati le EEPROM.
and the error fi le. Data fi les store data
associ ated wi th the program, such as I /O
status, counter/ti mer preset and
accumulated values, and other stored
constants or vari ables. Together, these two
areas are called the appli cati on memory or
user memory.
Also within the CPU is an executive
program or system memory that directs
and performs operation activities such as
executing the user program and coordinating
input scans and output updates. System
memory, which is programmed by the
manufacturer, cannot be accessed by the user.
3.4
Types of Appl i cat i on Memor y
As the name i ndi cates, programmable
logi c controllers have programmable
memory that allows users to develop
and modi fy control programs. Memory
i s a physi cal space i nsi de the CPU where
the program fi les and data fi les are stored
and mani pulated.
Memory types fall i nto two categori es:
volati le or nonvolati le. Volati le memory can
22
3
be easi ly altered or erased, and i t can be wri tten to and read from.
However, wi thout proper backup, a power loss can cause the loss of
programmed contents.
T he best known form of volati le memory i s Random Access Memory,
or RAM. RAM i s relati vely fast and offers an easy means to create and
store users appli cati on programs. I f normal power i s di srupted, mi cro
PLCs wi th RAM memory use battery or capaci tor backups to prevent
program loss. ( However, note that capaci tors and batteri es may fai l.)
Nonvolati le memory retai ns i ts programmed contents wi thout a
battery or capaci tor backup even i f power i s lost. T he EEPROM
Electri cally Erasable Programmable Read Only Memory i s a
nonvolati le memory that has the same flexi bi li ty as RAM, and i s
programmed through appli cati on software, whi ch runs on a personal
computer or through a mi cro PLCs Hand-Held Programmer.
3.5
Dat a, Memor y and Addr essi ng
Whereas memory i s a physi cal space, data i s i nformati on stored i n
that space. T he CPU operates j ust li ke a computer; i t mani pulates data
usi ng bi nary di gi ts, or bi ts. A bi t i s a di screte locati on wi thi n a si li con
chi p that ei ther has a voltage present, read as a value of 1 ( On) , or not
present, read as a value of 0 ( Off) . T hus, data i s a pattern of electri cal
charges that represent a numeri cal value.
A bi t i s the smallest uni t of memory avai lable. Generally, CPUs
process and store data i n 16 bi t groups, also known as words.
However, users can sti ll mani pulate data on the bi t level.
23
Whi le PLCs operate i n
bi nary (1 and 0), they also use
bi nary to convert, accept and
mani pulate data from other
number systems. These systems
i nclude bi nary coded deci mal
(BCD), hexadeci mal, octal, and
gray code (see Fi g. 3-3).
Begi nni ng PLC users
probably do not need to know
how to use these di fferent
number systems, so they
wi ll not be explai ned further.
However, note that they may
need to be learned later, as
these numberi ng systems are
valuable when worki ng wi th
certai n types of i nputs. For
example, thumbwheel swi tches
usually requi re four bi ts per
wheel; i .e., they communi cate
i n BCD. Thus, any PLC used
wi th a thumbwheel must be
able to accept a BCD i nput.
Each word of data has a speci fi c, physi cal
locati on i n the CPU called an address or a
regi ster ( note that the terms word,
address, and regi ster are often used
i nterchangeably) . Every element i n the user
program i s referenced wi th an address to
i ndi cate where data for that element i s
located. When assi gni ng addresses to I /O i n
a program, note that the address i s related
to the termi nal where i nput and output
devi ces are connected ( see Fi g. 3-2) .
24
3
Decimal Hexadecimal Binary BCD Octal Gray code
0 0 000 0000 0 0000
1 1 001 0001 1 0001
2 2 010 0010 2 0011
3 3 011 0011 3 0010
4 4 100 0100 4 0110
5 5 101 0101 5 0111
6 6 110 0110 6 0101
7 7 111 0111 7 0100
8 8 1000 1000 10 1100
9 9 1001 1001 11 1101
10 A 1010 12 1111
11 B 1011 13 1110
12 C 1100 14 1010
13 D 1101 15 1011
14 E 1110 16 1001
15 F 1111 17 1000
Fi g. 3-3
3.6
Oper at i ng Cycl e
All the components of the PLC system
come i nto play duri ng the operati ng cycle,
whi ch consi sts of a seri es of operati ons
performed sequenti ally and repeatedly.
3
25
I/O Wiring
Input word
Output word
Pushbutton wired
to input terminal I/3
Pilot light wired
to output terminal O/2
Memory location of I/O status
This bit corresponds to
Input terminal I/3
This bit corresponds to
Output terminal O/3
Program with addresses
I/3 O/2
Fi gure 3-2 Thi s fi gure shows the relati onshi p between the actual I/O wi ri ng
termi nal locati on and the address of the i nstructi ons i n the program. Note:
The I/O address format may di ffer, dependi ng on the PLC manufacturer.
3
T he maj or elements of an operati ng cycle are:
1. The i nput scan. Duri ng the i nput scan
the PLC exami nes the external i nput
devi ces for a voltage present or absent;
i .e., an On or Off state. T he status of
the i nputs i s temporari ly stored i n an
i nput i mage memory fi le.
2. Program scan. Duri ng the program scan,
the PLC scans the i nstructi ons i n the
ladder logi c program, uses the i nput status
from the i nput i mage fi le, and determi nes
i f an output wi ll or wi ll not be energi zed.
T he resulti ng status of the outputs i s
wri tten to the output i mage memory fi le.
3. Output scan. Based on the data i n the
output i mage fi le, the PLC energi zes or
de-energi zes i ts output ci rcui ts, controlli ng
external devi ces.
3.7
Pow er Suppl i es
T he power supply provides power to the
controllers internal electronics, converts the
incoming voltage to a usable form and protects
the PLCs components from voltage spikes.
26
I
n
p
u
t
S
c
a
n
O
u
t
p
u
t
S
c
a
n
PLC
Operating
Cycle
Program
S
c
a
n
Fi g. 3-4 Image of operati ng cycle.
3
Gi ven that most faci li ti es experi ence li ne
voltage fluctuati ons, PLC power suppli es are
desi gned to mai ntai n normal operati on even
i f the voltage vari es from 10 to 15 percent.
Di ps or surges i n power are caused by
natural li ne losses from the uti li ty, brownouts
or the start-up or shutdown of nearby heavy
equi pment ( such as motors or arc welders) .
For voltage condi ti ons that are especi ally
unstable, consi der i nstalli ng a constant
voltage transformer between the PLC and
the pri mary power source.
T he PLCs power supply i s desi gned to
wi thstand short power losses wi thout
affecti ng the operati on of the system. A PLC
can operate for several mi lli seconds wi thout
li ne power before the power supply si gnals
the processor that i t can no longer provi de
adequate dc power to the system. T he power
supply then instructs the processor to execute
a controlled shut down, which saves the users
program and data i n memory.
Another factor affecti ng the functi on of the
PLC i s electromagneti c i nterference ( EMI ) or
electri cal noi se. Whi le PLCs are more rugged
than most electroni c equi pment ( especially
the PCs or single board controllerssometi mes
27
Speed
What i s the fastest acti on
requi red i n the control process?
How much ti me i s needed to
control that acti on? Speed i s
one of the pri mary advantages
of todays mi cro controllers.
Operati ng cycles typi cally take
1 to 25 mi lli seconds (thousandths
of a second). When judgi ng the
speed, i t i s i mportant to look at
total throughput ti me, not just the
operati ng cycle.
Components of throughput
ti me i nclude: ti me for actuati on
of the physi cal i nput; ti me for
PLCs i nput ci rcui t to sense
the si gnal; ti me for i nput scan,
program scan and output scan;
ti me for actuati on of the output
ci rcui t and correspondi ng fi eld
devi ce; and ti me for the CPUs
housekeepi ng or overhead
functi ons. See throughput ti me
worksheet i n Appendi x D.
For appli cati ons that requi re
hi gh-speed operati on, advanced
mi cro controllers offer functi ons
such as hi gh-speed counti ng
wi th di rect control of outputs
and i mmedi ate I/O update
i nstructi ons. These functi ons
enable the mi cro controller
to detect and react qui ckly to
changi ng i nput condi ti ons.
3
used i nstead of PLCs) , EMI may sti ll be a problem. I f so, the PLC should
be electrically isolated by installing an isolation transformer.
Unti l recently, all mi cro PLCs operated on 24V dc. However, several
mi cro PLC manufacturers now offer products that operate on ei ther
120V ac, 220V ac or 24V dc. T hi s gi ves the user the opti on of selecti ng the
voltage that best suits the application. For example, if ac power is used on
other parts of the machine ( actuators, for example) , a micro PLC that can
accept ac power may eli mi nate the need to i nstall a dc power supply.
3.8
Pr ogr ammi ng Devi ces
When enteri ng a program i nto a mi cro PLC, the two devi ces most
commonly used are a personal computer ( PC) and a Hand-Held
28
Most users create thei r programs wi th software run on a PC.
29
Plant techni ci ans
value Hand-Held
Programmers
(shown actual si ze)
because of thei r
portabi li ty,
ruggedness and
troubleshooti ng
capabi li ti es.
3
3
Programmer ( HHP) .
T he PC i s used to run PLC programmi ng
software. T hi s software allows users to
create, edi t, document, store and
troubleshoot ladder di agrams, and generate
pri nted reports. Software i nstructi ons are
based on graphi cal symbols for vari ous
functi ons. Usi ng such software does not
requi re knowledge of hi gher programmi ng
languages, j ust a general understandi ng of
standard electri cal wi ri ng di agrams.
Whi le the HHP can be used to program
the PLC, i t i s more commonly used as a
troubleshooti ng tool. T hi s i s because the
HHP i s compact and has i ts own memory to
store programs. HHPs are i nvaluable for
troubleshooti ng equi pment whi le on the
factory floor, for modi fyi ng programs, and
transferri ng programs to multi ple machi nes.
T he language used by the HHP i s a graphi cal
form of i nstructi on li st programmi ng based
on the PLCs ladder logi c i nstructi ons.
3.9
Oper at or Int er f aces
I n order to convey i nformati on about
30
Operator i nterface
3
machi ne status, the front panel of a mi cro PLC has a seri es of i ndi cator
li ghts. T hese are for such thi ngs as power, run, faults or I /O status. To
communi cate wi th the PLC to enter data or moni tor and control
machi ne status tradi ti onal operator i nterfaces i nclude pushbuttons,
thumbwheel swi tches, pi lot li ghts and LED numeri c di splays.
To i mprove the i nterface between the operator and the mi cro PLC,
a new generati on of electroni c operator i nterface devi ces ( or
peri pherals) can be connected. T hese are not programmi ng devi ces,
but graphi c or alphanumeri c di splays and control panels that
consoli date all the functi ons of tradi ti onal operator i nterface devi ces
i nto a si ngle panel.
T hese i nterfaces can output data and di splay messages about
machi ne status i n descri pti ve text ( Motor 1 On) , di splay parts count,
and track alarms. T hey can also be used for data i nput. By provi di ng
better and more easi ly conveyed i nformati on, these i nterfaces decrease
the need for operator trai ni ng on machi ne operati on and reduce
system, component, and i nstallati on costs.
T hese products communi cate wi th the PLC through an RS 232
communi cati ons port. T hi s opens up I /O poi nts, whi ch can be used for
sensors and output devi ces and enables a mi cro PLC to control a more
complex machi ne or process.
31
Programmi ng Languages . . . . . . . . . . . . . 4.0
Electri cal Ladder Di agrams . . . . . . . . . . . 4.1
Ladder Logi c Programs . . . . . . . . . . . . . . 4.2
Ladder Logi c I nstructi ons . . . . . . . . . . . . 4.3
Combi ni ng I nstructi ons . . . . . . . . . . . . . . 4.4
Program Executi on. . . . . . . . . . . . . . . . . . 4.5
4
C
H
A
P
T
E
R
Ladder Logi c Fundament al s
33
4
4.0
Pr ogr ammi ng Languages
A programi s a user-developed seri es of i nstructi ons or commands
that di rect the PLC to execute acti ons. A programmi ng language
provi des rules for combi ni ng the i nstructi ons so that they produce
the desi red acti ons.
T he most commonly used language for programmi ng PLCs i s
ladder logi c. I n fact, more PLC programs are wri tten i n ladder logi c
than any other language. T he ladder logi c programmi ng language i s an
adaptati on of an electri cal relay wi ri ng di agram, also known as a ladder
di agram. Because ladder logi c i s a graphi cal system of symbols and
terms, even those not fami li ar wi th electri cal relay wi ri ng di agrams can
easi ly learn i t.
Other control languages occasi onally used to program PLCs i nclude
BASI C, C and Boolean. T hese computer languages faci li tate programs
that requi re complex i nstructi ons and calculati ons too cumbersome to
i mplement wi th a ladder logi c program. However, mi cro PLCs that can
be programmed wi th BASI C and C are not wi dely avai lable.
T he i nstructi ons used to program most mi cro PLCs are based on a
combi nati on of Boolean, ladder logi c and mnemoni c expressi ons. A
34
4
35
M1
L1 L2
PB1
Stop
PB2
Start
Motor
M1
Rung
Power Bus Power Bus
Auxiliary
Holding
Contact
mnemoni c expressi on i s a si mple and easy to remember term whi ch
represents a complex or lengthy i nstructi on. For example, T ON stands
for ti mer on. Di fferent PLCs use sli ghtly di fferent i nstructi ons, and
these can be found by consulti ng the users manual.
4.1
El ect r i cal Ladder Di agr ams
Ladder logi c programs evolved from electri cal ladder di agrams, whi ch
represent how electri c current flows through devi ces to complete an
electri c ci rcui t. T hese di agrams show the i nterconnecti on between
electri cal devi ces i n an easy-to-read graphi cal format that gui des the
electri ci an when wi ri ng ( see Fi g. 4-1) .
An electri cal di agram consi sts of two verti cal bus li nes, or power li nes,
wi th current flowi ng from the left bus to the ri ght bus. Each electri cal
ci rcui t i n the di agram i s consi dered a rung. Every rung has two key
components: i t contai ns at least one devi ce that i s controlled, and i t
Fi g. 4-1 Electri cal di agram of a hardwi red start/stop ci rcui t.
4
contai ns the condi ti on( s) that control the devi ce, such as power from
the bus or a contact from a fi eld devi ce.
A rung i s sai d to have electri cal conti nui ty when current flows
uni nterrupted from left to ri ght across the rung ( i .e., all contacts are
closed) . I f conti nui ty exi sts, then the ci rcui t i s complete and the devi ce
controlled by the rung turns On ( see Fi g. 4-2) . I f conti nui ty does not
exi st, the devi ce stays Off.
36
M1
L1 L2
PB1
Stop
PB2
Start
Motor
M1
Rung
Power Bus Power Bus
Auxiliary
Holding
Contact
Electrical Continuity
4.2
Ladder Logi c Pr ogr ams
A PLC ladder logi c program closely resembles an electri cal ladder
di agram ( Fig. 4-3) . On an electri cal di agram, the symbols represent real-
world devi ces and how they are wi red. A PLC program uses si mi lar
symbols, but they represent ladder logi c i nstructi ons for the appli cati on.
A ladder logi c program exi sts only i n the PLCs software i t i s not
the actual power bus or the flow of current through ci rcui ts. Another
Fi g. 4-2 If PB1 i s NOT pushed and PB2 i s pushed, the ci rcui t wi ll be complete. Under
these condi ti ons, the rung has electri cal conti nui ty and the motor wi ll turn On.
4
di fference i s that i n an electri cal di agram, devi ces are descri bed
as bei ng open or closed ( Off or On) . I n a ladder logi c program,
i nstructi ons are ei ther True or False ( however, the terms are often
used i nterchangeably) .
37
] [ ( ) ] [
] [
Rung
Stop
I /1
Start
I/2
Motor - M1
Motor - M1
Auxiliary
Holding
Contact
Condition Instructions Control Instruction
Each rung i n a ladder logi c program must contai n at least one
control i nstructi on ( output) and usually contai ns one or more condi ti on
i nstructi ons ( i nputs) . Condi ti on i nstructi ons are programmed to the left
of the control i nstructi on. Examples of condi ti on i nstructi ons i nclude
si gnals from connected i nput devi ces, contacts associ ated wi th outputs,
and si gnals from ti mers and counters.
Programmed on the ri ght si de of the rung, a control i nstructi on i s
the operati on or functi on that i s acti vated/de-acti vated by the logi c
of the rung. Examples of control i nstructi ons i nclude output energi ze
( turn On the PLCs output ci rcui try to acti vate a fi eld devi ce) and
i nstructi ons i nternal to the PLC, such as bi t commands, ti mers, counters
and math commands.
Fi g. 4-3 Noti ce the si mi lari ty between the ladder logi c program and the hardwi red
ci rcui t i n Fi g. 4-1.
4
Recall from Chapter 3
that every element i n the user
program i s referenced wi th an
address to i ndi cate where data
for that element i s located.
T he control i nstructi ons are energi zed
or de-energi zed based on the status of the
condi ti on i nstructi ons i n the rung. T he PLC
does thi s by exami ni ng a rung for logi cal
conti nui ty ( i .e., all condi ti on i nstructi ons are
evaluated as True) . I f logi cal conti nui ty exi sts,
the PLC energi zes the control i nstructi on
( see Fi g. 4-4) . I f logi cal conti nui ty does not
exi st, then the PLC mai ntai ns the control
i nstructi on i n the Off or de-energi zed state.
38
] [ ( ) ] [
] [
Rung
Stop Start Motor - M1
O/1
M1
O/1
Auxiliary
Contact
Logical Continuity
I/2 I /1
Fi g. 4-4 If a si gnal i s NOT present at i nput termi nal I/1 and a si gnal i s present at
i nput termi nal I/2, the rung has logi cal conti nuity and the PLC wi ll energi ze output
termi nal O/1 controlli ng the motor.
4
4.3
Ladder Logi c Inst r uct i ons
T he most frequently used i nstructi ons i n a PLC ladder logi c program
are the normally open ( N.O.) i nstructi on, the normally closed ( N.C.)
i nstructi on, and the output energi ze i nstructi on ( see Fi g. 4-5) . T hese
i nstructi ons are represented as symbols placed on the rungs of the
program ( whi ch i s why PLC users may hear ladder logi c descri bed as
contact symbology) .
39
] [ ( ) ] [
] [
Normally
Closed Instruction
Normally
Open Instruction
Normally
Open Instruction
Output
Energize Instruction
/
Normally Open Instruction
A normally open i nstructi on exami nes a PLC memory locati on for an
On condi ti on ( i .e., i t checks to see i f the bi t element at the i nstructi ons
address i s On ( bi nary 1) ) . I f the PLC detects an On condi ti on, the
i nstructi on i s True and has logi cal conti nui ty.
For example, a N.O. pushbutton ( PB1) i s wi red to i nput termi nal
I /3 on the PLC. T he ladder logi c program contai ns the followi ng rung
( Fi g. 4-6.1) , where I /3 i s programmed as a N.O. i nstructi on.
When PB1 i s pressed ( On) , that On status i s wri tten to i nput i mage
Fi g. 4-5 Common ladder symbols.
Normally Closed Instruction
A normally closed i nstructi on exami nes the PLC memory for an
Off condi ti on ( i .e., i t checks to see i f the bi t element at the i nstructi ons
address i s Off, or 0) . I f the PLC detects an Off condi ti on, the i nstructi on
i s True and has logi cal conti nui ty.
4
memory locati on I /3 duri ng the PLCs i nput scan. When the rung
contai ni ng the N.O. i nstructi on wi th address I /3 i s scanned, that
i nstructi on i s seen as True and the PLC energi zes output O/4 duri ng
i ts output scan.
40
PB1
Input
Device
Input
Terminal
on PLC Ladder Program
Status of
Output
/ /
ON
True True
( ) ] [
I /3
I /3 O/4
0/4
Output
Terminal
on PLC
When PB1 i s released, the Off status i s wri tten to address I /3.
T he N.O. i nstructi on i s now False and the rung lacks logi cal conti nui ty
( 4-6.2) . Duri ng the PLCs output scan, output O/4 wi ll be de-energi zed.
Input
Device
Input
Terminal
on PLC Ladder Program
Status of
Output
OFF
PB1
False False
( ) ] [
/
I /3
I /3 O/4
/
0/4
Output
Terminal
on PLC
Fi g. 4-6.1 Normally open i nstructi ons.
Fi g. 4-6.2 Normally open i nstructi ons.
4
41
Input
Device
Input
Terminal
on PLC Ladder Program
Status of
Output
PB1
ON
True True
( ) ] [
I /4
I /4
/ /
O/5
/
0/5
Output
Terminal
on PLC
For example, a N.O. pushbutton ( PB1) i s wi red to i nput termi nal
I /4 on the PLC. T he ladder logi c program contai ns the followi ng rung
( Fi g. 4-7.1) , where I /4 i s programmed as a N.C. i nstructi on.
When PB1 i s not pressed ( Off) , that Off status i s wri tten to i nput
i mage memory locati on I /0 duri ng the PLCs i nput scan. When the rung
contai ni ng the N.C. i nstructi on wi th address I /0 i s scanned, that
i nstructi on i s seen as True ( NOT On) and the PLC energi zes output O/5
duri ng the output scan.
When PB1 i s pressed, the On status i s wri tten to address I /4. T he N.C.
i nstructi on i s now False and the rung lacks logi cal conti nui ty ( Fi g. 4-7.2) .
Duri ng the PLCs output scan, output O/5 wi ll be de-energi zed.
Fi g. 4-7.1 Normally closed i nstructi ons.
Input
Device
Input
Terminal
on PLC Ladder Program
Status of
Output
PB1
OFF
False False
( ) ] [
I /4
I /4
/ /
O/5
/
0/5
Output
Terminal
on PLC
Fi g. 4-7.2 Normally closed i nstructi ons.
4
42
Output Energize Instruction
( )
Controlled by the condi ti on i nstructi ons that precede i t on a rung,
the output energi ze i nstructi on ( OT E) turns On a bi t element i n the
output i mage fi le when rung condi ti ons are True. Output energi ze i s the
ladder logi c equi valent of a relay coi l on an electri cal di agram.
When logi cal conti nui ty exi sts on a rung, the On condi ti on ( bi nary 1)
i s wri tten to the locati on i n memory associ ated wi th the output
energi ze i nstructi on. I f the address i s that of an external output devi ce,
the PLC energi zes the output duri ng the output scan. When the rung i s
False, the PLC de-energi zes the output. T he output energi ze i nstructi on
PB1
Input
Device
Input
Terminal
on PLC Ladder Program
Status of
Output
( )
( )
PB1
( )
( )
PB1
( )
( )
PB1
( )
( )
] [
] [
] [
] [
] [
] [
] [
] [
/
/
/
/
/
/
/
/
/
/
/
/
A
A
A
A
A
A
W
X
X
Y
Z
Z
Y
W
B
B
B
B
B
B
/
/
/
/
OFF
ON
ON
OFF
ON
OFF
OFF
ON
W
X
X
W
Y
Y
Z
Z
Output
Terminal
on PLC
N.O. Pushbutton
Not Activated
N.O. Pushbutton
Activated
N.C. Pushbutton
Not Activated
N.C. Pushbutton
Activated
Fi g. 4-8 Condi ti on i nstructi ons and thei r results.
4
controls real world devi ces ( solenoi d valves,
motors, li ghts, etc.) or i nternal bi t elements.
Higher Level Instructions
Whi le relay logi c i s sui table for si mple
On/Off sensi ng and control, many
appli cati ons requi re more powerful
i nstructi ons. To allow thi s, enhanced ladder
language commands have been developed.
T hese i nstructi ons deal wi th numeri cal data
beyond si mple 1s or 0s by mani pulati ng data
i n bytes or words. Examples of hi gher level
i nstructi ons i nclude counters, ti mers,
sequencers, math, compari son and other
operati ons that N.O., N.C. and OT E
i nstructi ons cannot perform.
To keep the i mplementati on of these
operati ons si mple, hi gher level i nstructi ons
are usually represented i n ladder logi c
programmi ng as functi on blocks. As shown
43
Hardwired to Programmed
Remember to make a
di sti ncti on between the physi cal
i nput devi ce and i ts ladder logi c
representati on, and note that
an i nstructi on i n a ladder
program i s programmed
i ndependently of how the i nput
devi ce i s wi red. Therefore, the
status of a N.O. pushbutton can
be tested wi th a N.C. i nstructi on,
and vi ce versa. Fi g. 4-8
demonstrates all the possi ble
combi nati ons and thei r results.
Also remember that when PLC
i nstructi ons change state
(e.g., make a False-to-True
transi ti on), a normally open
i nstructi on does not change
to a normally closed i nstructi on.
Where electromechani cal relay
contacts open and close, PLC
i nstructi ons test a memory
locati on for a 1 or 0.
] [
Lower Gate
CTU
Count Up
Counter C5:10
Preset 500
Accum 0
(CU)
(DN)
Number of
Vehicles
in Garage
Fi g. 4-9 Hi gher level i nstructi ons such as thi s counter are represented wi th
functi on blocks i n the ladder program.
i n Fi g. 4-9, functi on blocks are li terally programmed as blocks on the
rung of a ladder program. Dependi ng on thei r operati on, hi gher level
i nstructi ons can be ei ther condi ti on i nstructi ons ( e.g., compari son
i nstructi ons) or control i nstructi ons ( e.g., ti mer or counter
i nstructi ons) .
4.4
Combi ni ng Inst r uct i ons
Two fundamental logi c operati ons AND and OR provi de the
rules for governi ng how i nstructi ons are combi ned.
AND Logic
Condi ti on i nstructi ons programmed i n seri es are the ladder di agram
equi valent of AND logi c ( Fi g. 4-10) . For example, pi cture a metal
stampi ng operati on where the machi ne acti vates only i f the operator
si multaneously pushes both a left-hand start button ( X) AND a ri ght-
hand start button ( Y) .
44
T he output of an AND equati on wi ll be True only i f all condi ti ons i n
seri es are True. I f any condi ti on i s False, then the rung does not have
logi cal conti nui ty and the output wi ll be Off.
Y X Z
( ) ] [ ] [
Fi g. 4-10 Wi th i nstructi ons programmed i n seri es, output Z wi ll be True (On) only i f
both i nput X ANDi nput Y are True (On).
4
4
OR Logic
Condi ti on i nstructi ons programmed i n parallel are the ladder
di agram equi valent of the OR operati on ( see Fi g. 4-11) . For example,
i magi ne a conveyor that has two run swi tches, one located at each
end. T he conveyor could be confi gured to start i f an operator pressed
a start button at one end ( X) OR the other ( Y) .
45
Y
X Z
] [
] [
( )
Fi g. 4-11 Wi th i nstructi ons programmed i n parallel, output Z wi ll be True (On) i f
ei ther X OR Y are True (On).
T he output of an OR equati on wi ll be True i f any condi ti on i n parallel
i s True. I f all condi ti ons are False, then the rung does not have logi cal
conti nui ty and the output wi ll be False.
4
Branch Operations
T he functi on of a branch i s to allow both condi ti on and control
i nstructi ons to be programmed i n parallel i n a si ngle rung ( Fi g. 4-13) .
Condi ti on i nstructi ons programmed i n parallel are the equi valent of
an OR operati on.
Control i nstructi ons programmed i n parallel are the equi valent of an
AND operati on.
46
Fi g. 4-12 Combi ni ng seri es and parallel logi c.
( )
( )
] [
] [
] [
] [
] [
] [
/
/
W
X
X
Y
Y
Z
Z
W
Noti ce that AND and OR logi c
(series and parallel circuits) can
be combined on a single rung, as
shown i n Fi g. 4-12.
4
Branch operati ons also provi de the relay wi ri ng equi valent of an
auxi li ary holdi ng contact or memory functi on ( refer back to Fi g. 4-3) .
Auxi li ary contacts keep thei r output energi zed after a momentary start
si gnal i s no longer present.
47
] [
/
] [
/
] [
/
] [
/
( )
( )
Front Door
Drivers Side
Front Door
Passengers Side
Rear Door
Drivers Side
Rear Door
Passengers Side
Bell
Dome Light
] [
Key Present
Fi g. 4-13 In thi s example, branch i nstructi ons are appli ed to a program controlli ng the
dome li ght and door ajar bell of a 4-door sedan. The li ght and bell (multi ple outputs)
wi ll turn On i f ANY of the doors (multi ple i nputs) are opened whi le a key i s present i n
the i gni ti on.
4
As shown i n Fi g. 4-14, an auxi li ary holdi ng contact i s always
programmed wi th the same address as i ts referenced output ( remember,
one of the advantages of a PLC i s that an address can be used more
than once) . Momentari ly pressi ng start button I /2 energi zes control
i nstructi on O/3 ( whi ch turns On the motor) , and i t also energi zes
condi ti on i nstructi on O/3. Energi zi ng O/3 i n the branch operati on
mai ntai ns the On status of the output unti l stop button I /1 i s pressed.
48
Stop Button Start Button Motor
Auxiliary
Holding
Contact
I/1 I/2 O/3
O/3
Fi g. 4-14 An auxi li ary holdi ng contact keeps i ts referenced output energi zed even
after a momentary start si gnal has been removed.
4
4.5
Pr ogr am Execut i on
Before readi ng how the PLC executes a ladder logi c program,
re-readi ng Chapter 3.6, Operati ng Cycle may be helpful.
T he PLC solves each rung sequenti ally, from top to bottom of the
program. Even i f the output of the current rung ( e.g., rung 5) affects
a previ ous rung ( e.g., rung 2) , the PLC does not go back to solve the
earli er rung unti l the next program scan. For the output of one rung
to affect an i nstructi on i n another rung i n the same scan, i t must have a
lower rung number than the rung i t i s to affect. T hat i s, the controlli ng
rung must be programmed before the controlled rung.
Whi le rungs are often ordered to show a sequence of events the
top-most rung i s the fi rst event and so on thi s i s done purely for
organi zati onal conveni ence. I n both electri cal di agrams and ladder
logi c programs, rung order does not necessari ly di ctate the sequence
of operati on. Remember, the status of the condi ti on i nstructi ons of
each rung di ctates the sequence i n whi ch outputs are controlled.
49
What i s a Potenti al Control Appli cati on? . 5.0
What are the Appli cati ons Requi rements?. 5.1
Selecti ng a Control Method . . . . . . . . . . . 5.2
What are the PLC Speci fi cati ons? . . . . . . 5.3
Program Development Procedures. . . . . . 5.4
I nstallati on Requi rements. . . . . . . . . . . . . 5.5
5
C
H
A
P
T
E
R
How t o Appl y a Mi cr o PLC
51
5
5.0
What i s a Pot ent i al Cont r ol Appl i cat i on?
Any si tuati on where coordi nated operati on of electri cal or electroni c
devi ces i s requi red i s a potenti al control appli cati on. Typi cal devi ces
controlled i nclude contactors, solenoi d valves, relays, li ghts and motors.
Machi nes or processes that operate based on any of the followi ng
characteri sti cs could be consi dered potenti al control appli cati ons:
Repeti ti ve operati ons Hi gh-speed control
T i me-dri ven operati ons Requi rements for data
Event-dri ven operati ons acqui si ti on/mani pulati on
Examples i nclude conveyors, form and fi ll operati ons, packagi ng
operati ons, strappi ng machi nes, palleti zi ng and wrappi ng machi nes,
traffi c li ght sequenci ng, gate control, cut-to-length li nes, semi -automati c
weldi ng and pai nti ng, storage and retri eval systems, pump alternators,
car washes, pri nti ng presses, vendi ng machi nes, and many more.
T hese appli cati ons may be able to be controlled by relays, PLCs, or
si ngle board controllers ( SBCs) all of whi ch possess logi c capabi li ti es.
However, before selecti ng a control system, the appli cati ons requi rements
must be determi ned, as they help gui de the selecti on process.
52
5
Personal computers ( PCs) are also someti mes used for control
appli cati ons, but always for more complex control requi rements than
the appli cati ons controlled by relays, mi cro PLCs or SBCs.
5.1
What ar e t he Appl i cat i ons Requi r ement s?
No matter what type of control system i s ulti mately selected, the
fi rst step i n approachi ng a control si tuati on i s to speci fy the appli cati ons
requi rements. T hi s i ncludes determi ni ng:
I nput and output devi ce requi rements.
T he need for speci al operati ons i n addi ti on to di screte ( On/Off)
logi c, i ncludi ng:
- T i mi ng - Sequenci ng
- Counti ng - Data acqui si ti on
- Hi gh-speed counti ng - Data calculati ons
T he electri cal requi rements for i nputs, outputs, and system power.
How fast the control system must operate ( speed of operati on) .
I f the appli cati on requi res shari ng data outsi de the process,
i .e., communi cati on.
I f the system needs operator control or i nteracti on.
T he physi cal envi ronment i n whi ch the control system wi ll
be located.
To determi ne appli cati on requi rements, desi gners need to begi n by
i denti fyi ng all operati ons the control system needs to perform and the
53
5
condi ti ons that affect the system. [Note: I f an operati on speci fi cati on
exi sts for the process/machi ne, consult i t before begi nni ng. I f no
speci fi cati on exi sts, i t needs to be created at thi s poi nt.]
As an example, i magi ne desi gni ng a control system for a parki ng
garage wi th a 500 car capaci ty. T he fi rst step i s to defi ne and descri be
the car parki ng process. Note that whi le descri pti ve text i s used here
( most people si mply wri te out a descri pti on wi th pen and paper) ,
sequence of operati on charts or process sheets are used, too.
What i s the desi red operati on for the parki ng garage?
T he car approaches an automated ti cket machi ne at a gate.
T he dri ver pushes a button on the ti cket machi ne to recei ve a ti cket.
I f there i s space left i n the garage, the dri ver wi ll recei ve a ti cket.
T he machi ne should not provi de a ti cket i f the garage i s full or i f
the gate i s already up.
Removi ng the ti cket rai ses the gate and turns on a green
enter li ght.
After the car clears the gate, the gate lowers and the green li ght
shuts off.
T he number of vehi cles i n the garage needs to be known at any ti me.
I f maxi mum capaci ty i s reached, a Garage Full si gn i s i llumi nated,
the ti cket machi ne wi ll not provi de a ti cket, and the gate wi ll
not rai se.
An alarm must sound when the gate i s obstructed.
Input and Output Requirements
After defi ni ng the operati on of the system, the next step i s to
54
5
determi ne what i nput and output devi ces the system requi res. Li st
the functi on requi red and i denti fy a speci fi c type of devi ce. Also, group
devi ces by whether they sense an event has occurred or i s occurri ng
( i nputs) or whether they control somethi ng ( outputs) .
From the descri pti on of the parki ng garage control system, the
followi ng I /O requi rements can be li sted:
Function (inputs) Device
T i cket request Pushbutton
T i cket taken Li mi t swi tch
Car cleared gate Photoelectri c sensor
Car departed garage Photoelectri c sensor
Gate obstructed Motor overload contact
Gate i n up posi ti on Proxi mi ty sensor
Gate i n down posi ti on Proxi mi ty sensor
Function (outputs) Device
Provi de ti cket Solenoi d
Garage Full si gn Li ght
Green li ght Li ght
Alarm Horn
Rai se gate Gear motor forward
Lower gate Gear motor reverse
From the li st of fi eld devi ces, the parki ng garage control system
requi res seven i nputs and si x outputs.
Advanced Function Requirements
Appli cati ons often requi re operati ons besi de si mple di screte ( On/Off)
logi c. T hese advanced functi ons i nclude ti mi ng, counti ng, sequenci ng,
communi cati ons, math, compari son, and many other operati ons
i nvolvi ng data mani pulati on and calculati on.
55
5
Li st the advanced functi ons requi red and note how they wi ll be used.
From the descri pti on of the parki ng garage control system, the followi ng
advanced functi on requi rements can be li sted:
Function Use
Up counter Count cars enteri ng garage
Down counter Count cars leavi ng garage
Electrical Requirements
When determi ni ng the electri cal requi rements of a system, consi der
three i tems: i ncomi ng power ( power for the control system) , i nput
devi ce voltage, and output voltage and current. Because the voltage
used wi th each devi ce may be di fferent, maki ng a di sti ncti on i s i mportant.
To deci de what voltage to use, consi der the followi ng:
What type of power i s avai lable ( e.g., 24V dc, 120 or 240V ac) ?
How wi ll the machi ne or process controlled be used?
Wi ll people come i n contact wi th the machi ne?
What power do the fi eld devi ces use?
What electri cal codes apply?
I n the parki ng garage example, safety i s a pri mary consi derati on
because people physi cally contact the ti cket machi ne. By usi ng 24V dc
power for the i nput and output devi ces, hazards to the user dramati cally
decrease. However, the gate controller selected for the parki ng garage
requi res devi ces capable of swi tchi ng 120V ac, such as dry contact relays.
( Si nce people do not touch the gate controller i n the normal course of
operati on, i t poses a mi ni mal hazard to users.)
56
5
Whi le i t may be more conveni ent to use one voltage, appli cati on
requi rements often di ctate the need for di fferent voltages. I f thi s i s the
case, as wi th the parki ng garage, i solate the di fferent voltages from each
other on separate commons.
Summari zi ng the electri cal requi rements for a control system i n a
chart faci li tates organi zati on. For the parki ng garage example, i t looks
li ke thi s:
Function (inputs) Device Voltage
T i cket request Pushbutton 24V dc
T i cket taken Li mi t swi tch 24V dc
Car cleared gate Photoelectri c sensor 24V dc
Car departed garage Photoelectri c sensor 24V dc
Gate obstructed Motor overload contact 24V dc
Gate i n up posi ti on Proxi mi ty sensor 24V dc
Gate i n down posi ti on Proxi mi ty sensor 24V dc
Function (outputs) Device Voltage
T i cket provi ded Solenoi d 24V dc
Full si gn Li ght 24V dc
Green li ght Li ght 24V dc
Alarm Horn 24V dc
Gate up Gate controller 120V ac
Gate down Gate controller 120V ac
Advanced functions Device Voltage
Up counter To be determi ned T BD
Down counter To be determi ned T BD
Control system Voltage
To be determi ned 24V dc or 120V ac
57
5
Speed of Operation
When determi ni ng speed of operati on, consi der these poi nts:
How fast does the process occur or machi ne operate?
Are there ti me cri ti cal operati ons or events that must be detected?
I n what ti me frame must the fastest acti on occur ( i nput devi ce
detecti on to output devi ce acti vati on) ?
Does the control system need to count pulses from an encoder or
flow-meter and respond qui ckly?
T he control system selected needs to meet the speed demands of the
process or machi ne, so knowi ng these cri teri a i s i mportant.
Clearly, the parki ng garage control system does not requi re a fast
response. Consi deri ng that PLC- or SBC-based control systems respond
i n mi lli seconds, the relati ve speed of operati on for many appli cati ons,
such as the parki ng garage, i s very slow compared to the processi ng
speed of a PLC or SBC.
Operator Interfaces and Communication
I n order to convey i nformati on about machi ne or process status, or
to allow an operator to i nput data, many appli cati ons requi re operator
i nterfaces. Tradi ti onal operator i nterfaces i nclude pushbuttons, thumb-
wheel swi tches, pi lot li ghts, and LED numeri c di splays. Electroni c
operator i nterface devi ces di splay messages about machi ne status i n
descri pti ve text ( Motor 1 On) , di splay parts count and track alarms.
T hey can also be used for data i nput ( see secti on 3.9 for detai ls) .
Communi cati on i nvolves shari ng appli cati on data or status wi th
another electroni c devi ce, such as a computer or a moni tor i n an
58
5
operators stati on. Communi cati on can take place locally through a
twi sted-pai r wi re, or remotely vi a telephone or radi o modem. PLC-based
control systems are desi gned to support communi cati on and electroni c
operator i nterfaces, where relay-based systems are not. SBC-based
systems typi cally support communi cati ons, and some operator i nterfaces.
As i t has been defi ned, the parki ng garage control system does
not requi re operator i nterfaces beyond the ti cket request pushbutton,
the green enter li ght and the alarm horn. However, advanced
communi cati on capabi li ti es could provi de benefi ts. For example, i f a
porti on of the garage was bei ng repai red and 50 parki ng spaces were
eli mi nated, i t would be advantageous for the garage operator to change
the control system parameters so that only 450 vehi cles could be
admi tted. I n addi ti on, the control system could also let dri vers know an
area had been temporari ly closed.
Environment
Consi der the envi ronment where the control system wi ll be located.
Wi ll i t be subj ected to temperature extremes? Water? Humi di ty?
Salt? Shock? Dust? Vi brati on? I n harsh envi ronments, house the
control system i n an appropri ate NEMA- or I P-rated enclosure. Also,
remember to consi der accessi bi li ty for mai ntenance, troubleshooti ng
or reprogrammi ng.
I f the control system for the parki ng garage i s located i n the ti cket
machi ne, i t needs to be housed i n an enclosure to protect i t agai nst
moi sture and di rt. Consi deri ng that outdoor temperature extremes may
exceed the control system operati ng temperature, the enclosure may
also need temperature and condensati on controls. See the secti on on
59
60
5
PLC Advantages
Whi le relay-based control
systems can perform some
advanced functi ons (typi cally
ti mi ng and counti ng, wi th
li mi ted sequenci ng), a wi de
range of higher level instructions
can only be performed by PLCs
or SBCs.
The data acqui si ti on and
communi cati on capabi li ti es
of PLCs also deserve speci al
menti on, as they far exceed the
capabi li ti es of tradi ti onal relays.
PLCs can gather i nformati on
from the machine for production
and status reports, out-of-spec
or faulty parts count, total
parts count, producti on
rates, and machi ne run ti me
(whi ch i s valuable for peri odi c
mai ntenance operati ons).
Further, PLCs can communi cate
thi s data to other control
equi pment or to operators i n
remote locati ons.
I nstallati on Requi rements later i n thi s
chapter for further envi ronmental
consi derati ons.
5.2
Sel ect i ng a Cont r ol Met hod
Once appli cati on requi rements have
been defi ned, the next step i s determi ni ng
whi ch type of control method can accompli sh
the task.
As noted at the start of thi s chapter,
system desi gners can select from three types
of control systems: relays, PLCs or SBCs. To
help determi ne whi ch control method
i s best sui ted for the task, develop a chart
whi ch i ntegrates appli cati on requi rements
wi th control methods. T he followi ng chart
( Fi g. 5-1) has been fi lled out for the parki ng
garage example.
61
5
Application Required? Quantity Can the control method accomplish task?
Characteristic Relay PLC SBC
I nputs Yes 7 Yes Yes Yes
Outputs Yes 6 Yes Yes Yes
T i mers No 0 Yes Yes Yes
Counters Yes 1 up/down Yes Yes Yes
Hi gh speed requi red? No 0 No Yes Yes
Data calculati ons? No 0 No Yes Yes
Data acqui si ti on No 0 No Yes Yes
Communi cati ons No 0 No Yes Yes
Operator i nterfaces No 0 No Yes No ( typi cally)
As Fi g. 5-1 shows, all three control methods can accompli sh the
task, so selecti ng a control method cannot be based on appli cati on
requi rements alone. However, thi s does not mean that all three
methods provi de the opti mum soluti on. To di fferenti ate between
control methods, evaluate the relati ve cost i mpact of each method
usi ng the followi ng cri teri a:
Criteria Relays Micro PLCs SBCs
System desi gn and development Not appli cable Not appli cable
****
Control system hardware
**/*** */** *
Panel assembly
*** * *
Panel space
*** * *
I mplementi ng logi c
*** ** ***
Dupli cati ng appli cati on
**** * *
Documenti ng logi c
**** * **
Modi fyi ng logi c
**** * **
Mai ntenance
*** * **
Fi g. 5-1 Compari son of appli cati on requi rements and control opti ons.
Fi g. 5-2 Relati ve cost compari son of control methods.
*
=Low
**
=Moderate
***
=Hi gh
****
=Very hi gh
Space and Cost
System desi gners usually consi der physi cal space and cost for
components the two most i mportant i ssues by far. Many appli cati ons,
especi ally machi nery, have a small, fi ni te amount of space allocated for
5
controls. I f an assembled control system occupi es more space than
allotted, i t often cannot be used because too many changes to the
machi nery would need to be made to accommodate i t.
Once mounted on a panel, a relay-based control system typi cally
occupi es much more space than the equi valent control i mplemented
wi th a mi cro PLC or SBC. Wi th mi cro PLCs avai lable i n the si ze of a
bri ck and smaller, only the si mplest relay-based system takes up less
space. Wi th the control system for the parki ng garage requi ri ng 13 I /O
and a counter, a mi cro PLC or SBC are the most space effi ci ent
control soluti ons.
Several cost factors i nfluence the selecti on of a control method,
i ncludi ng control system desi gn and development, costs for components,
assembly, space, and logi c i mplementati on.
Control system design and development costsare i ncurred i n
the desi gn of the system.
- For a relay system, these costs are not appli cable as the components
have already been desi gned and produced.
- For a mi cro PLC, these costs are not appli cable because the PLC
has already been desi gned and produced.
- For an SBC, costs i nvolve securi ng the servi ces of an electroni c
engi neer to desi gn the board and test i ts vi abi li ty ( unli ke relays and
PLCs, SBCs are not typi cally avai lable off-the-shelf) .
Note: Many i nstallati ons requi re the control system to meet global
i ndustri al standards, such as UL, CE or CSA. PLCs usually have been
certi fi ed to meet those standards, where relay- and SBC-based systems
typi cally are not.
62
5
Component costsare for the control-related hardware. Costs
also i nclude recei vi ng, i nventory, and the quali ty control of
the components.
- For a relay system, thi s i ncludes relays, mechani cal ti mers,
and counters.
- For a mi cro PLC, all necessary hardware i s packaged i n the PLC.
- For an SBC, thi s i ncludes the board, i ts components, and ci rcui try.
Assembly costscover putti ng the components together so they
are usable.
- For a relay system, thi s i ncludes mounti ng components on a panel
and wi ri ng the logi c power.
- For a mi cro PLC, the only assembly costs are for mounti ng the uni t
to a panel wi th screws or on a DI N rai l.
- For an SBC, thi s i nvolves securi ng a manufacturi ng faci li ty to
produce i t. For thi s reason, SBCs become economi cally vi able only i n
hi gh volume or very uni que appli cati ons.
Panel space costsi nclude the si ze of the panel and the enclosure
needed to house the control system. T he larger the enclosure, the
greater the materi al costs for i t.
- For a relay system wi th many components, si ze could be prohi bi ti ve.
- For a mi cro PLC, si ze i s mi ni mal.
- For an SBC, si ze i s usually mi ni mal.
Logic implementation costsrelate to the i nstallati on of the logi c
i nto the control system ( assumi ng costs for developi ng the logi c are
si mi lar for all three control methods) .
63
5
- For a relay system, i mplementi ng logi c i nvolves wi ri ng the
components together. Each subsequent appli cati on requi res the
same amount of labor to assemble, debug, and adj ust ti mer and
counter presets.
- For a mi cro PLC, costs i nclude purchase of programmi ng software
or a Hand-Held Programmer. Programmi ng a subsequent appli cati on
only requi res downloadi ng the program; there are no program
debuggi ng costs for dupli cate appli cati ons. However, users sti ll need
to commi ssi on each control system ( see Chapter 6) .
- For an SBC, costs i nvolve retai ni ng an electri cal engi neer to
program a mi croprocessor. Programmi ng each subsequent appli cati on
typi cally requi res copyi ng a memory chi p; there are no program
debuggi ng costs for dupli cate appli cati ons. Commi ssi oni ng i s
also requi red.
Future Costs
Total costs for a control system dont end after i mplementati on.
After system start up, i t may be necessary to modi fy the control logi c,
document system changes, and troubleshoot the system.
Wi th a relay-based system, re-wi ri ng costs associ ated wi th logi c
changes can be extraordi nari ly hi gh i t was j ust thi s type of si tuati on
that prompted General Motors to call for PLC development i n the
fi rst place. T he labor i nvolved wi th relays can be i ntensi ve and
costly, especi ally i f more than one machi ne needs rewi ri ng. Further,
documenti ng relay wi ri ng logi c changes requi res drafti ng a new
wi ri ng di agram. Because thi s task i s so tedi ous ( and adds cost) , system
changes can go undocumented. I n fact, short of traci ng every wi re, there
64
5
i s no way to ensure that the latest wi ri ng di agram actually reflects the
logi c bei ng executed by the system.
Wi th an SBC-based control system, users typi cally cannot communi cate
wi th the mi croprocessor, nor i s there programmi ng software avai lable.
Logi c changes are not easy to i mplement, automated documenti ng
capabi li ti es do not usually exi st, and users typi cally cannot upload or
download programs. SBC-based systems are di ffi cult to troubleshoot
because they rarely have troubleshooti ng features bui lt i nto thei r
software. Users of these systems must go to the manufacturer for
support because no one else understands the SBC operati on.
PLCs offer consi derably more flexi bi li ty. Programmi ng software
faci li tates relati vely qui ck logi c changes, and permi ts the new program
to be easi ly downloaded to multi ple machi nes. T he program i s always
up-to-date, and documentati on i s accompli shed wi th the push of a
button. Troubleshooti ng help and di agnosti c functi onsare a standard
part of the software, and can be conducted wi th the Hand-Held
Programmer as well ( see Chapter 6) .
PLCs are the easi est control system to support. Assi stance for
programmi ng and troubleshooti ng i s avai lable at reasonable costs
from many sources. And, i f a PLC fai ls, a replacement PLC can
be purchased off-the-shelf from the nearest i ndustri al electri cal
suppli er there i s no need to wai t for a shi pment from the factory.
Furthermore, the ruggedness of PLCs compared to SBCs gi ves them
a defi ni te advantage i n harsh envi ronments or when durabi li ty i s a
pri mary consi derati on.
65
66
5
Selecting the Micro PLC
For all cri teri a by whi ch control systems are evaluated cost,
si ze, flexi bi li ty, and supportabi li ty mi cro PLCs provi de the user
wi th di sti nct advantages over other control opti ons for many control
appli cati ons. T hus, a mi cro PLC has been selected to provi de the logi c
control for the parki ng garage.
5.3
What ar e t he PLC Speci f i cat i ons?
After determi ni ng appli cati on requi rements and selecti ng a method
for provi di ng system control, the next step i s to determi ne speci fi cati ons
for the control system. When determi ni ng PLC speci fi cati ons, i denti fyi ng
appli cati on requi rements i n certai n categori es can be helpful. Categori es
that typi cally need to be consi dered are:
Total number of I /O
Electri cal requi rements
Output ci rcui ts
Memory requi rements
Speed of operati on
Communi cati on
Operator i nterfaces
I/O Total
To determi ne a PLCs I /O requi rements, exami ne the appli cati on
requi rements to determi ne how many i nput and output devi ces the
PLC needs to moni tor and control.
5
Revi ewi ng the I /O requi rements for the parki ng garage, a PLC for
thi s appli cati on requi res seven i nputs and si x outputs.
Note: When determi ni ng I /O total, many people add an extra
10% for unanti ci pated I /O needs, as well as future changes to the
control system.
Electrical Requirements
To determi ne a PLCs electri cal requi rements, consi der the voltage
and current requi rements for the PLC ( i ncomi ng power) , each output,
and the i nputs.
Unti l recently, mi cro PLCs operated on 24V dc only. T hi s li mi tati on
often necessi tated i nstalli ng a dc power source, especi ally when the
other control system components operated on 120V ac. Newer mi cro
PLCs, however, offer users standard voltage opti ons: 24V dc, 120V ac, or
240V ac. For the parki ng garage, a PLC usi ng 24V dc may be the best
choi ce for the stated safety reasons. However, i f the PLC i s not located
i nsi de the ti cket machi ne, usi ng 120V ac may be acceptable.
67
NOT
USED
DC
24V- 0/11 0/10 0/9 0/8 0/7 0/6 0/5 0/4 0/3 0/2
DC
24V+ 0/1
VAC
VDC 0/0
VAC
VDC
DC IN
+ 24 -
Isolated relays Shared common relays
Output terminal strip
Fi g. 5-3 Di agram of a mi cro PLCs output termi nal. Note that output termi nals O/0 and
O/1 are i solated relays.
68
5
For appli cati ons requi ri ng control of di fferent output voltages, the PLC
selected needs to have i solated output termi nals to keep the voltages
separated. [Note: Power from di fferent sources or of di fferent voltages
must be i solated from each other.] I n the parki ng garage example, the
120V ac gate controller si gnal must be i solated from the other output
si gnals, whi ch are 24V dc. Some mi cro PLCs now offer i ndi vi dually
i solated outputs, wi th other outputs on di fferent commons ( Fi g. 5-3) .
A mi cro PLC accepts si gnals for all i ts i nputs at the same voltage level,
usually 120V ac or 24V dc. T he appli cati on requi rements and the power
avai lable di ctate whi ch voltage i s selected. Recall that for the parki ng
garage, the i nputs operate on 24V dc for safety reasons. T he chart below
summari zes the electri cal requi rements for the parki ng garage:
Incoming power Output voltages Input voltage
24V dc 120V ac ( 2 devi ces) 24V dc ( 7 devi ces)
24V dc ( 4 devi ces)
Output Circuits
Recall from secti on 3.2 that mi cro PLCs are avai lable wi th di fferent
types of outputs to sui t di fferent si tuati ons. For the parki ng garage,
relay outputs wi ll work best. Relays can swi tch both dc and ac current,
have adequate response ti mes, and wear i s not a si gni fi cant i ssue. I n
addi ti on, mi cro PLCs wi th relay outputs usually cost less than those
wi th soli d state outputs.
For appli cati ons requi ri ng fast response or havi ng a hi gh cycle rate
( such as a hi gh-speed cut-to-length li ne) , a mi cro PLC wi th soli d state
output ci rcui ts ( transi stor, FET or tri ac) mi ght be the opti mum choi ce.
69
5
T hese ci rcui ts respond faster and do not wear out because there are no
movi ng parts.
Memory Requirements
To qui ckly esti mate the memory an appli cati on requi res, a general
rule i s to add the number of I /O and then multi ply by 10, where 10 i s
the words of memory needed per I /O. T he parki ng garage control
system has 13 I /O, plus one extra for expansi on, yi eldi ng a total of 14.
14 x 10 words = 140 esti mated words of memory requi red.
Today, nearly all mi cro PLCs have at least 1/2K of memory avai lable
for appli cati on programs ( 1/2K equals 512 words) . For the parki ng
garage control system, as well as most low I /O count appli cati ons, mi cro
PLCs usually have more than suffi ci ent memory. Typi cally, appli cati ons
wi ll exceed a mi cro controller I /O capaci ty before i ts memory capaci ty.
Once the logi c requi red for an appli cati on has been developed, PLC
users can calculate how much memory a program wi ll consume by refer-
ri ng to the PLC operators manual, whi ch typi cally li sts memory use for
all of the i nstructi ons. See the worksheet i n Appendi x D for an example.
Speed of Operation
I f appli cati on requi rements i ndi cate the need for a PLC wi th hi gh-
speed operati on, look for a PLC wi th the followi ng features:
Adj ustable i nput fi lters ( see secti on 3.1) .
Transistor, FET or triac outputs ( not relays see section 3.2) .
Hi gh-speed counter, hi gh-speed i nterrupts, and i mmedi ate outputs.
5
Hi gh-speed counters, hi gh-speed i nterrupts and the abi li ty to
i mmedi ately update outputs allows PLCs to meet the demands of
most hi gh-speed appli cati ons. On user-speci fi ed condi ti ons, hi gh-
speed i nterrupts and i mmedi ate output i nstructi ons di rect the PLC
to i mmedi ately process the logi c and update the I /O i ndependently
of the normal program scan. T hi s can substanti ally i mprove speed
and performance.
Si mpli fyi ng the program also i ncreases performance, because program
length di rectly i mpacts scan ti me. Every i nstructi on i n a program takes
ti me to execute, and reduci ng or si mpli fyi ng the program reduces ti me.
PLC users can calculate program executi on ti me by referri ng to the
PLC operators manual, whi ch should li st executi on ti mes for all of the
i nstructi ons. See the worksheet i n Appendi x D for an example, as well
as a li sti ng of typi cal i nstructi on executi on ti mes i n Appendi x C.
5.4
Pr ogr am Devel opment Pr ocedur es
Even the si mplest programs rarely go di rectly from the programmers
head to the PLC. I n fact, attempti ng thi s ti me savi ng step often prolongs
the process. I nstead, begi n by wri ti ng out the operati on sequence
both sentences and flow charts work well. T here are three steps to
developi ng a sequence of operati on:
Defi ne the rules of operati on for each control poi nt.
I denti fy and label i nputs and outputs.
Convert the rules of operati on to ladder logi c.
70
71
5
Define Rules of Operation
What condi ti ons permi t or prevent responses from the control system?
Defi ni ng these condi ti ons i s known as developi ng the rules of operati on.
To begi n, carefully descri be the control system at i ts most basi c level.
Recall from secti on 5.1 that the parki ng garage control system was
descri bed li ke thi s:
T he dri ver approaches an automated ti cket machi ne at a gate.
T he dri ver pushes a button on the ti cket machi ne to recei ve a ti cket.
T he machi ne should not provi de a ti cket i f the lot i s full or the gate
i s up.
Removi ng the ti cket rai ses the gate and turns on a green li ght.
After the car clears the gate, the gate lowers and the green li ght
shuts off.
T he vehi cle populati on i s known at any ti me.
I f maxi mum capaci ty i s reached ( 500 cars) , a Full si gn i s
i llumi nated, the ti cket machi ne wi ll not provi de a ti cket and the gate
wi ll not rai se.
An alarm sounds when the gate i s obstructed.
Outputs Inputs
Provi de ti cket T i cket request pushbutton
Rai se gate T i cket taken li mi t swi tch
Lower gate Vehi cle cleared gate photo sensor
Garage Full si gn Car departed garage photo sensor
Green ( enter) li ght Gate obstructed ( motor overload contact)
Alarm Gate up proxi mi ty sensor
Gate down proxi mi ty sensor
5
72
To control any machi ne or process, fi rst i denti fy each acti on, or
control poi nt. Ask, What acti on i s the system controlli ng? T hen, create
a si mple descri pti on of the condi ti ons that control each acti on. Start wi th
the control poi nt and work back to defi ne the condi ti ons ( i nputs) that
produce the desi red acti on. Noti ce that each control poi nt corresponds
to an output on a rung of the ladder program.
When carefully wri tten, the rules of operati on convert easi ly to a
ladder logi c program, as the parki ng garage example shows:
Rules of Operation
Control poi nt: T he ti cket machi ne wi ll provi de a ti cket
Condi ti ons: I f the dri ver presses the ti cket request pushbutton
AND the Full si gn i s NOT on
AND the gate i s lowered
Rung 0
Ticket
Request PB
Garage is
Full
Gate is
Lowered
Provide
Ticket
Solenoid
( ) ] [ ] [ ] [
Control poi nt: Rai se the gate unti l fully up
Condi ti ons: After the dri ver takes the ti cket
AND the gate i s NOT up
AND the Full si gn i s NOT on
Rung 1
Ticket has
Been Taken
Limit Switch
Gate
is Up
Garage is
Full Raise Gate
Raise Gate
] [ ] [ ] [
] [
( )
5
73
Rung 2
Vehicle
Photo
Sensor
(gate)
Vehicle is
Clear of
Gate
Vehicle
Present
Latch
Vehicle
Present
Latch
( ) ] [
] [
] [
Rung 3
Vehicle
Photo
Sensor
(gate)
Vehicle
Present
Latch
Vehicle is
Clear of
Gate
Vehicle is
Clear of
Gate
Ticket
Request PB
] [ ] [ ] [
] [
( )
Control poi nt: Vehi cle present latch
Condi ti ons: Vehi cle has been detected
AND the vehi cle has NOT cleared the gate
Control poi nt: Vehi cle clear of gate
Condi ti ons: Vehi cle present latch i s on
AND a vehi cle i s NOT detected
AND the ti cket request pushbutton i s NOT pressed
5
74
Rung 5
Gate
is Up
Green (GO)
Light
( ) ] [
] [
Rung 6
Lower Gate
CTU
Count Up
Counter C5:10
Preset 500
Accum 0
(CU)
(DN)
Number of
Vehicles
in Garage
Rung 4
Gate
is Up
Vehicle is
Clear of
Gate
Lower
Gate
Lower Gate
Gate is
Lowered
Gate is
Obstructed
] [ ] [
] [
] [ ] [ ( )
Control poi nt: Lower the gate unti l fully down
Condi ti ons: I f the gate i s up
AND the car has cleared the gate
AND the gate i s NOT down
AND the gate i s not obstructed
Control poi nt: Turn on the green li ght
Condi ti on: I f the gate i s up
Control poi nt: Count cars enteri ng/turn on full si gn at 500th car
Condi ti ons: I f the gate has been lowered
I f accumulated counter value preset value of 500
5
75
] [
Rung 9
Gate is
Obstructed
( )
Alarm
Sounded
Control poi nt: Decrement the counter ( count departi ng vehi cles)
Condi ti on: I f a vehi cle departs the garage
Control poi nt: Sound alarm
Condi ti on: I f the gate i s obstructed
] [
Rung 8
CTD
Count Down
Counter C5:10
Preset 500
Accum 0
(CD)
(DN)
Number of
Vehicles
in Garage
Vehicle
Photo Sensor
(Departing Garage)
Programming Tips
When programmi ng condi ti on i nstructi ons, refer back to Fi g. 4-8
to determi ne i f a normally open or a normally closed i nstructi on
produces the desi red acti on.
Control poi nt: Turn on the Full si gn
Condi ti on: I f accumulated counter value preset value of 500
( )
Rung 7
] [
C5:10
DN
Garage is Full
5
When defi ni ng the rules of operati on, the text should use language
that helps convert the operati ng characteri sti cs to ladder logi c.
Recall from Chapter 4 that AND logi c connects i nstructi ons i n
seri es on a ladder di agram rung, whi le the OR logi c connects
i nstructi ons i n parallel.
I f an output needs to remai n on after the condi ti on that ori gi nally
energi zed i t i s no longer present, use an auxi li ary holdi ng contact
or a latched output.
A condi ti on i nstructi on can be used more than once i n a program
because i t exi sts i n the software ( a benefi t over hardwi red relays) .
Also, remember that the status of an output can be used as a
condi ti on i nstructi on.
Only program a speci fi c output i nstructi on once. I f an output
i nstructi on wi th the same address i s programmed more than once,
the last occurrence of the i nstructi on i n the user program wi ll
determi ne the actual output state.
When each I /O ( fi eld devi ce) i s wi red to a termi nal on the PLC, i t
then has a uni que address whi ch corresponds to that termi nal.
Follow the i nstructi on manual! Each PLC manufacturer uses sli ghtly
di fferent terms and techni ques. T hese should be noted and followed
carefully.
Addressing
All elements of a ladder di agram are labeled wi th a letter/numeri cal
desi gnati on. Because every PLC manufacturer has a vari ati on of thi s
desi gnati on, be sure to follow the addressi ng conventi ons outli ned i n
the operators manual.
76
5
T he parki ng garage example uses I to i ndi cate i nputs, O for
outputs. All i nput and output termi nals i n thi s example are numbered
starti ng wi th zero ( 0) . T he program for the parki ng garage has i ts
i nputs and outputs addressed as such:
Input address
I /0 T i cket request pushbutton
I /1 T i cket taken li mi t swi tch
I /2 Car cleared gate photoelectri c sensor
I /3 Car departed garage photoelectri c sensor
I /4 Gate obstructed ( motor overload contact)
I /5 Gate up proxi mi ty sensor
I /6 Gate lowered proxi mi ty sensor
Output address
O/0 T i cket provi ded solenoi d
O/1 Gate up motor controller
O/2 Gate down motor controller
O/3 Garage Full si gn
O/4 Green li ght
O/5 Alarm horn
Counter address
T he program for the parki ng garage also needs two counters ( noti ce
that the counter uses an i nternal address) :
C5:10 Count Up ( CT U) , for cars enteri ng
C5:10 Count Down ( CT D) , for cars departi ng
Wi th the addresses i nserted, the program for the parki ng garage i s
complete and looks li ke thi s ( see next page) :
77
78
5
Rung 0
Ticket
Request PB
Garage is
Full
O/3
Gate is
Lowered
Provide
Ticket
Solenoid
O/0
Rung 1
Ticket has
Been Taken
Limit Switch
Gate
is Up
Garage is
Full
O/3
Raise Gate
O/1
Raise Gate
O/1
Rung 2
Vehicle
Photo
Sensor
(gate)
Vehicle is
Clear of
Gate
B/2
Vehicle
Present
Latch
B/3
Vehicle
Present
Latch
B/3
Rung 3
Vehicle
Photo
Sensor
(gate)
Vehicle
Present
Latch
B/3
Vehicle is
Clear of
Gate
B/2
Vehicle is
Clear of
Gate
B/2
Ticket
Request PB
( )
( )
( )
( )
] [ ] [
] [
] [
] [
] [
] [
] [
] [ ] [
] [
] [ ] [
] [
I /0 I /6
I /1 I /5
I /2
I /2 I /0
79
5
Rung 4
Gate
is Up
Vehicle is
Clear of
Gate
B/2
Lower
Gate
O/2
Lower Gate
O/2
Gate is
Lowered
Gate is
Obstructed
Rung 5
Gate
is Up
Green (enter)
Light
O/4
Rung 6
Rung 7
Lower Gate
O/2
CTU
Count Up
Counter C5:10
Preset 500
Accum 0
(CU)
(DN)
Number of
Vehicles
in Garage
C5:10
DN
Garage is Full
O/3
Rung 8
CTD
Count Down
Counter C5:10
Preset 500
Accum 0
(CD)
(DN)
Number of
Vehicles
in Garage
Rung 9
Gate is
Obstructed
Alarm
Sounded
O/5
] [ ] [
] [
] [
] [
] [
] [
] [
] [ ] [ ( )
( )
( )
( )
Vehicle Photo
Sensor
(Departing Garage)
I /5 I /6 I /4
I /5
I /3
I /4
80
5
5.5
Inst al l at i on Requi r ement s
A PLC users manual contai ns detai led i nstallati on i nstructi ons
perti nent to that parti cular model, and they should be followed carefully.
As wi th any product bei ng i nstalled, proper planni ng assures smooth
start-up. When i nstalli ng mi cro PLCs, consi der the physi cal and
electri cal envi ronments and requi rements for power, mounti ng and
wi ri ng. T he followi ng are some suggesti ons for i nstalli ng PLCs.
Physical Environment
Whether the mi cro PLC i s mounted wi thi n a machi ne or i n a separate
enclosure, i t requi res protecti on agai nst temperature extremes, humi di ty,
dust, shock, vi brati on, or corrosi ve envi ronments.
Be careful about locati ng the PLC i n an enclosure wi th other
heat-generati ng sources; 55