plc training ladder,rs232
TRANSCRIPT
-
8/10/2019 PLC Training Ladder,RS232
1/64
http://www.plcs.net/chapters
What is a PLC?
A PLC (i.e. Programmable Logic Controller) is a device that was invented to replace the
necessary sequential relay circuits or machine control. !he PLC wor"s by loo"ing at its inputs
and depending upon their state# turning on/o its outputs. !he user enters a program# usually
via sotware# that gives the desired results.
PLCs are used in many $real world$ applications. % there is industry present# chances are
good that there is a plc present. % you are involved in machining# pac"aging# material
handling# automated assembly or countless other industries you are probably already using
them. % you are not# you are wasting money and time. Almost any application that needs
some type o electrical control has a need or a plc.
&or e'ample# lets assume that when a switch turns on we want to turn a solenoid on or
seconds and then turn it o regardless o how long the switch is on or. *e can do this with a
simple e'ternal timer. +ut what i the process included ,- switches and solenoids *e would
need ,- e'ternal timers. *hat i the process also needed to count how many times the
switches individually turned on *e need a lot o e'ternal counters.
As you can see the bigger the process the more o a need we have or a PLC. *e can simply
program the PLC to count its inputs and turn the solenoids on or the speciied time.
!his site gives you enough inormation to be able to write programs ar more complicated
than the simple one above. *e will ta"e a loo" at what is considered to be the $top -$ plc
instructions. %t can be saely estimated that with a irm understanding o these instructions one
can solve more than 0-1 o the applications in e'istence.
!hats right# more than 0-12 3 course well learn more than 4ust these instructions to help
you solve almostALLyour potential plc applications
PLC History
%n the late ,56-s PLCs were irst introduced. !he primary reason or designing such a devicewas eliminating the large cost involved in replacing the complicated relay based machine
control systems. +edord Associates (+edord# 7A) proposed something called a 7odular
8igital Controller (738%C39) to a ma4or ; car manuacturer. 3ther companies at the time
proposed computer based schemes# one o which was based upon the P8P
-
8/10/2019 PLC Training Ladder,RS232
2/64
a limited lietime which required strict adhesion to maintenance schedules. !roubleshooting
was also quite tedious when so many relays are involved. 9ow picture a machine control
panel that included many# possibly hundreds or thousands# o individual relays. !he si>e could
be mind boggling. ?ow about the complicated initial wiring o so many individual devices2
!hese relays would be individually wired together in a manner that would yield the desiredoutcome. *ere there problems @ou bet2
!hese $new controllers$ also had to be easily programmed by maintenance and plant
engineers. !he lietime had to be long and programming changes easily perormed. !hey also
had to survive the harsh industrial environment. !hats a lot to as"2 !he answers were to use
a programming technique most people were already amiliar with and replace mechanical
parts with solid
-
8/10/2019 PLC Training Ladder,RS232
3/64
The Guts Inside
!he PLC mainly consists o a CP# memory areas# and appropriate circuits to receive
input/output data. *e can actually consider the PLC to be a bo' ull o hundreds or thousands
o separate relays# counters# timers and data storage locations. 8o these counters# timers#
etc. really e'ist 9o# they dont $physically$ e'ist but rather they are simulated and can be
considered sotware counters# timers# etc. !hese internal relays are simulated through bit
locations in registers. (more on that later)
What does each part do?
%9P! FELA@;
they can be programmed to count pulses. !ypically these counters can count up#
down or both up and down. ;ince they are simulated they are limited in their counting
speed. ;ome manuacturers also include high
-
8/10/2019 PLC Training Ladder,RS232
4/64
typically be used to store data when power is removed rom the PLC. pon power
-
8/10/2019 PLC Training Ladder,RS232
5/64
Ater the third step the PLC goes bac" to step one and repeats the steps continuously. 3ne
scan time is deined as the time it ta"es to e'ecute the B steps listed above
!esponse Ti$e
!he total response time o the PLC is a act we have to consider when shopping or a PLC.
Iust li"e our brains# the PLC ta"es a certain amount o time to react to changes. %n many
applications speed is not a concern# in others though...
% you ta"e a moment to loo" away rom this te't you might see a picture on the wall. @our
eyes actually see the picture beore your brain says $3h# theres a picture on the wall$. %n this
e'ample your eyes can be considered the sensor. !he eyes are connected to the input circuit
o your brain. !he input circuit o your brain ta"es a certain amount o time to reali>e that your
eyes saw something. (If you have been drinking alcohol this input response time would be
longer!) Eventually your brain reali>es that the eyes have seen something and it processes
the data. %t then sends an output signal to your mouth. @our mouth receives this data and
begins to respond to it. Eventually your mouth utters the words $Dee# thats a really ugly
picture2$.
9otice in this e'ample we had to respond to B things:
INPUT< %t too" a certain amount o time or the brain to notice the
input signal rom the eyes.
EECUTION< %t too" a certain amount o time to process the
inormation received rom the eyes. Consider the program to be: %
the eyes see an ugly picture then output appropriate words to the
mouth.
OUTPUT< !he mouth receives a signal rom the brain and
eventually spits (no pun intended) out the words $Dee# thats a really
ugly picture2$
!esponse Ti$e Concerns
-
8/10/2019 PLC Training Ladder,RS232
6/64
9ow that we "now about response time# heres what it really means to the application. !he
PLC can only see an input turn on/o when its loo"ing. %n other words# it only loo"s at its
inputs during the chec" input status part o the scan.
%n the diagram# input , is not seen until scan . !his is because when input , turned on# scan
, had already inished loo"ing at the inputs.
%nput is not seen until scan B. !his is also because when the input turned on scan had
already inished loo"ing at the inputs.
%nput B is never seen. !his is because when scan B was loo"ing at the inputs# signal B was
not on yet. %t turns o beore scan = loo"s at the inputs. !hereore signal B is never seen by
the plc.
!o avoid this we say that the input should be on
or at least % input de&ay ti$e ' one scan
ti$e.
+ut what i it was not possible or the input to be on this long !hen the plc doesnt see the
input turn on. !hereore it becomes a paper weight2 9ot true... o course there must be a way
to get around this. Actually there are ways.
Pu&se stretch (unction)!his unction e'tends the
length o the input signal until the plc loo"s at theinputs during the ne't scan.( i.e.it stretches the
duration o the pulse.)
-
8/10/2019 PLC Training Ladder,RS232
7/64
Interrupt (unction) !his unction interrupts the scan
to process a special routine that you have written. i.e.
As soon as the input turns on# regardless o where the
scan currently is# the plc immediately stops what its
doing and e'ecutes an interrupt routine. (A routinecan be thought o as a mini program outside o the
main program.) Ater its done e'ecuting the interrupt
routine# it goes bac" to the point it let o at and
continues on with the normal scan process.
9ow lets consider the longest time or an output to actually turn on. Lets assume that when a
switch turns on we need to turn on a load connected to the plc output.
!he diagram below shows the longest delay (worst case because the input is not seen until
scan ) or the output to turn on ater the input has turned on.
!he ma'imum delay is thus * scan cyc&es + % input de&ay ti$e)
!e&ays
9ow that we understand how the PLC processes inputs# outputs# and the actual program we
are almost ready to start writing a program. +ut irst lets see how a relay actually wor"s. Ater
all# the main purpose o a plc is to replace $real
-
8/10/2019 PLC Training Ladder,RS232
8/64
9otice in the picture that we have separate circuits. !he bottom(blue) indicates the 8C part.
!he top(red) indicates the AC part.
?ere we are using a dc relay to control an AC circuit. !hats the un o relays2 *hen the switch
is open no current can low through the coil o the relay. As soon as the switch is closed#
however# current runs through the coil causing a magnetic ield to build up. !his magnetic ield
causes the contacts o the relay to close. 9ow AC current lows through the bell and we hear
it. Lunch time2
A typical industrial relay
!ep&acin, !e&ays
9e't# lets use a plc in place o the relay. (9ote that this might not be very cost eective or
this application but it does demonstrate the basics we need.) !he irst thing thats necessary
is to create whats called a ladder diagram. Ater seeing a ew o these it will become obvious
why its called a ladder diagram. *e have to create one o these because# unortunately# a plc
doesnt understand a schematic diagram. %t only recogni>es code. &ortunately most PLCs
have sotware which convert ladder diagrams into code. !his shields us rom actually learning
the plcs code.
-irst step< *e have to translate all o the items were using into symbols the plc understands.
!he plc doesnt understand terms li"e switch# relay# bell# etc. %t preers input# output# coil#
-
8/10/2019 PLC Training Ladder,RS232
9/64
contact# etc. %t doesnt care what the actual input or output device actually is. %t only cares that
its an input or an output.
&irst we replace the battery with a symbol. !his symbol is common to all ladder diagrams. *e
draw what are called bus bars. !hese simply loo" li"e two vertical bars. 3ne on each side othe diagram. !hin" o the let one as being J voltage and the right one as being ground.
&urther thin" o the current (logic) low as being rom let to right.
9e't we give the inputs a symbol. %n this basic e'ample we have one real world input. (i.e. the
switch) *e give the input that the switch will be connected to# to the symbol shown below.
!his symbol can also be used as the contact o a relay.
A contact symbol
9e't we give the outputs a symbol. %n this e'ample we use one output (i.e. the bell). *e give
the output that the bell will be physically connected to the symbol shown below. !his symbol
is used as the coil o a relay.
A coil symbol
!he AC supply is an e'ternal supply so we dont put it in our ladder. !he plc only cares about
which output it turns on and not whats physically connected to it.
Second step< *e must tell the plc where everything is located. %n other words we have to
give all the devices an address. *here is the switch going to be physically connected to the
plc ?ow about the bell *e start with a blan" road map in the PLCs town and give each item
an address. Could you ind your riends i you didnt "now their address @ou "now they live in
the same town but which house !he plc town has a lot o houses (inputs and outputs) but we
have to igure out who lives where (what device is connected where). *ell get urther into the
addressing scheme later. !he plc manuacturers each do it a dierent way2 &or now lets say
that our input will be called $----$. !he output will be called $--$.
-ina& step< *e have to convert the schematic into a logical sequence o events. !his is much
easier than it sounds. !he program were going to write tells the plc what to do when certain
events ta"e place. %n our e'ample we have to tell the plc what to do when the operator turns
on the switch. 3bviously we want the bell to sound but the plc doesnt "now that. %ts a pretty
stupid device# isnt it2
-
8/10/2019 PLC Training Ladder,RS232
10/64
!he picture above is the inal converted diagram. 9otice that we eliminated the real world
relay rom needing a symbol. %ts actually $inerred$ rom the diagram. ?uh8ont worry# youll
see what we mean as we do more e'amples.
.asic Instructions
9ow lets e'amine some o the basic instructions is greater detail to see more about what
each one does.
Load
!he load (L8) instruction is a normally open contact. %t is sometimes also called e'amine i
on.(%3) (as in e'amine the input to see i its physically on) !he symbol or a load instruction
is shown below.
A Loa8 (contact) symbol
!his is used when an input signal is needed to be present or the symbol to turn on. *hen the
physical input is on we can say that the instruction is !rue. *e e'amine the input or an on
signal. % the input is physically on then the symbol is on. An on condition is also reerred to as
a logic , state.
!his symbol normally can be used or internal inputs# e'ternal inputs and e'ternal output
contacts. Femember that internal relays dont physically e'ist. !hey are simulated (sotware)
relays.
Load.ar
!he Loa8+ar instruction is a normally closed contact. %t is sometimes also called Loa89ot or
e'amine i closed. (%C) (as in e'amine the input to see i its physically closed) !he symbol
or a loadbar instruction is shown below.
-
8/10/2019 PLC Training Ladder,RS232
11/64
A Loa89ot (normally closed contact) symbol
!his is used when an input signal does not need to be present or the symbol to turn on.
*hen the physical input is o we can say that the instruction is !rue. *e e'amine the inputor an o signal. % the input is physically o then the symbol is on. An o condition is also
reerred to as a logic - state.
!his symbol normally can be used or internal inputs# e'ternal inputs and sometimes# e'ternal
output contacts. Femember again that internal relays dont physically e'ist. !hey are
simulated (sotware) relays. %t is the e'act opposite o the Load instruction.
K93!E< *ith most PLCs this instruction (Load or Loadbar) 7;! be the irst symbol on the
let o the ladder.
Lo,ic State Load Load.ar
- &alse !rue
, !rue &alse
Out
!he 3ut instruction is sometimes also called an 3utputEnergi>e instruction. !he output
instruction is li"e a relay coil. %ts symbol loo"s as shown below.
An 3! (coil) symbol
*hen there is a path o !rue instructions preceding this on the ladder rung# it will also be
!rue. *hen the instruction is !rue it is physically 3n. *e can thin" o this instruction as a
normally open output. !his instruction can be used or internal coils and e'ternal outputs.
Out/ar
!he 3utbar instruction is sometimes also called an 3ut9ot instruction. ;ome vendors dont
have this instruction. !he outbar instruction is li"e a normally closed relay coil. %ts symbol
loo"s li"e that shown below.
An 3!+ar (normally closed coil) symbol
*hen there is a path o &alse instructions preceding this on the ladder rung# it will be !rue.
*hen the instruction is !rue it is physically 3n. *e can thin" o this instruction as a normally
-
8/10/2019 PLC Training Ladder,RS232
12/64
closed output. !his instruction can be used or internal coils and e'ternal outputs. %t is the
e'act opposite o the 3ut instruction.
Lo,ic State Out Out.ar
- &alse !rue
, !rue &alse
A Si$p&e E0a$p&e
9ow lets compare a simple ladder diagram with its real world e'ternal physically connected
relay circuit and ;EEthe dierences.
%n the above circuit# the coil will be energi>ed when there is a closed loop between the Jand es. Electrical si>es# that is. Always chec" the speciications o your load beore connecting
it to the plc output. @ou always want to ma"e sure that the ma'imum current it will consume is
within the speciications o the plc output. % it is not within the speciications (i.e. draws too
much current) it will probably damage the output. *hen in doubt# double chec" with the
manuacturer to see i it can be connected without potential damage.
;ome types o loads are very deceiving. !hese deceiving loads are called $inducti5e &oads$.
!hese have a tendency to deliver a $back current$ when they turn on. !his bac" current is li"e
a voltage spi"e coming through the system.
A good e'ample o an inductive load that most o us see about 6 months per year is an air
conditioning unit. Perhaps in your home you have an air conditioner. (unless you live in the
arctic you probably do2) ?ave you ever noticed that when the air conditioner $kicks on$ the
lights dim or a second or two. !hen they return to their normal brightness. !his is because
when the air conditioner turns on it tries to draw a lot o current through your wiring system.
Ater this initial $"ic"$ it requires less current and the lights go bac" to normal. !his could be
dangerous to your PLCs output relays. %t can be estimated that this "ic" is about B- times the
rated current o the load. !ypically a diode# varistor# or other $snubber$ circuit should be used
to help combat any damage to the relay. Enough said. Lets see how we can use these
outputs in the $real plc world$.
-
8/10/2019 PLC Training Ladder,RS232
53/64
;hown above is a typical method o connecting our outputs to the plc relays. Although our
diagram shows the output connected to an AC supply# 8C can be used as well.A relay is noned and typically it can switch either AC or 8C. ?ere the common is connected to one
end o our power supply and the other end o the supply is connected to the load. !he other
hal o our load gets connected to the actual plc output you have designated within yourladder program.
!he relay is internal to the plc. %ts circuit diagram typically loo"s li"e that shown above. *hen
our ladder diagram tells the output to turn on# the plc will internally apply a voltage to the relaycoil. !his voltage will allow the proper contact to close. *hen the contact closes# an e'ternal
current is allowed to low through our e'ternal circuit. *hen the ladder diagram tells the plc to
turn o the output# it will simply remove the voltage rom the internal circuit thereby enabling
the output contact to release. 3ur load will than have an open circuit and will thereore be o.
Si$p&e: isn;t it?
Transistor Outputs
!he ne't type o output we should learn about is our transistor type outputs. %t is important to
note that a transistor can only switch a dc current. &or this reason it cannot be used with an
AC voltage.
*e can thin" o a transistor as a solid
-
8/10/2019 PLC Training Ladder,RS232
54/64
*e should also "eep in mind that as we saw beore with the input circuits# there are generally
more than one type o transistor available. Typica&&y a p&c 1i&& ha5e either NPN or PNP type
outputs)!he $physical$ type o transistor used also varies rom manuacturer to
manuacturer. ;ome o the common types available are +I! and 73;&E!. A +I! type
(+ipolar Iunction !ransistor) oten has less switching capacity (i.e. it can switch less current)than a 73;
-
8/10/2019 PLC Training Ladder,RS232
55/64
the ladder tells --- to turn o# the LE8 will stop emitting light and hence the output transistor
connected between --- and C37 will turn o.
3ne other important thing to note is that a transistor typically cannot switch as large a load as
a relay. Chec" the manuacturers speciications to ind the largest load it can saely switch. %the load current you need to switch e'ceeds the speciication o the output# you can connect
the plc output to an e'ternal relay. !hen connect the relay to the large load. @ou may be
thin"ing# $why not ust use a relay in the first place$ !he answer is because a relay is not
always the correct choice or every output. A transistor gives you the opportunity to use
e'ternal relays when and only when necessary.
%n summary# a transistor is ast# switches a small current# has a long lietime and wor"s with
dc only. *hereas a relay is slow# can switch a large current# has a shorter lietime and wor"s
with ac or dc. ;elect the appropriate one based upon your actual application needs.
Co$$unications History
+y ar# the most popular method o communicating with e'ternal devices is by using the $F;