Introduction to Programmable Logic

Figure 1 PLC
PLC Background
A programmable logic controller is unit of hardware used to control and automate
industrial processes. Programmable Logic Controllers (PLCs) are often defined as
miniature industrial computers that contain hardware and software that is used to perform
control functions. TheThe first PLC was developed to help General Motors eliminate
traditional rela!based machine control sstems. "n large applications where thousands of
realrelas ma e#ist$ wiring and troubleshooting could be %uite complicated &'(.
"n )*+, -edford Associates$ a compan in -edford$ MA$ developed a device
called a Modular .igital Controller for General Motors. The M/."C/0$ as it was
1nown$ was an electronic device$ not a mechanical one$ it was perfect for GM2s
re%uirements$ as well as for man other manufacturers and users of control e%uipment.
3ith less wiring$ simpler troubleshooting$ and eas programming$ PLC technolog
caught on %uic1l &'(.
A PLC has three main
aspects4 the inputs and outputs and
the control program. The inputs are
connected to sensors that inform
the PLC about the environment.
The program uses a set of logical
instructions that drives the outputs
based on the inputs. The outputs
are connected to the devices
that need to be controlled. "n
figure 5 above$ the PLC has
eight inputs and four outputs.
There are two basic tpes of Programmable Logic Controllers4 a single bo# tpe
and a modular or rac1 tpe. The bo# tpe is smaller and used for simpler control
situations. "t is supplied as an integral compact pac1age$ compete with power suppl$
processor$ memor and input output units. &6'( 7ome of the most basic of theses onl
have ' outputs. The
tpicall can have from ' to
'8 inputs and outputs.
.epending on si9e and
functionalit the can cost
between :)88 and :)888.
-o# tpe PLCs have
limited e#pansion
The modular tpe consists of a central rac1 that house various hand pic1ed
modules that are appropriate for each control situation. A large variet of modules e#ist
that satisf man needs such as power supplies$ processors$ analog input and outputs$
digital input and outputs$ and communications. ";/ modules can alwas be added after
the unit it installed to suit new needs. Power supplies can be upgrade to meet new power
Figure 2
re%uirements. Also the ";/ modules can be much more speciali9ed than that of the bo#
tpe PLCs. <or e#ample$ there are modules that serve as P". control or TTL logic inputs.
Modular PLCs are used for larger and more comple# operations. Tpicall the have
from 58 to )88 inputs and outputs and up. Tpical configurations of modular controllers
can cost from :688 to :)8$888. The cost$ however$ can sometimes be much more.(wea1
phrase. Can ou find an upper bound=)

Control processes need devices to monitor events or measure needed values.
These devices are genericall called inputs to the PLC. <or e#ample$ input devices can be
pro#imit switches$ photoelectric sensors$ temperature sensors$ push buttons$ or pressure
sensors. An input is anthing that can sense the status of the environment and then
convert that information in to a signal. /ften the signal can simpl be a voltage that is
either on or off. /utputs are anthing that would need to be controlled based on the
inputs li1e motors$ indicator lights$ fans$ warning sirens or heating elements.
Relay Control Example
/ften industrial e%uipment will use three phase power for various reasons such as
cost$ si9e and durabilit. 7uppose some industrial woodwor1ing e%uipment is installed at
a residential home. "n order to use the e%uipment$ the normal two phase power into the
house needs to be converted into three phase power via a converter. Above is a picture of
a popular phase converter4 the Phase!/!Matic. 7ome of the e%uipment is located in the
garage and some in the basement. Therefore$ the three phase power needs to be available
at both locations. Conse%uentl$ the converter needs to have start and stop controls at
both locations.
The converter has three contacts. Two are connected to the 558 >AC source. The
other is connected to a starting capacitor and a push button. 3hen the power is switched
on nothing immediatel happens. The ?!phase converter has a motor that needs to be
started via a starting capacitor. After the motor has started onl the 558 >AC source is
re%uired for continued operation. 3hen ?!phase power is no longer needed$ the process is
stopped b disconnecting power.
@owever$ this is onl the basic concept of operation. The process should simpl
have one button for start and one button for stop at each location. This means that a timed
rela will ta1e the place of the momentar push button$ and a rela latching sstem is
need instead of a the power switch. "n this wa$ the sstem can operate using push
PL7 relate this figure to the previous one
A rela is a device that responds to a voltage change b activating a switch. 3hen
the input is energi9ed with a voltage a current will flow thought the coil and cause it to
become magneti9ed. Magnetic force will pull the contact close and thus close the circuit.
3hen the input voltage ta1en awa the magnet will de!activate and the contact will open
again. A rela and a contactor basicall serve the same function. The name contactor is
simpl used for high current.
-elow is a picture of the main control bo# for the converter with the components
labeled. This is how the control mechanism is put together without a PLC. The power
switch and momentar push button have been replaced with start and stop buttons. The
operational logic is performed b the start rela and a time dela rela.
-elow is a bloc1 diagram that shows the manner in which each device is
connected to each other. The wiring should loo1 a little comple# and confusing. The
bloc1s in ellow represent ABela logicC. The light blue bloc1s are output devices. The
wiring would be much simpler with a PLC. The 5!pole contactor controls the power
suppl to the converter. The )!pole contactor controls the starting capacitor. The Bemote
lamp is a indicator light at the remote location. 3hen lit it indicate that the converter is
-elow is a schematic of how devices would be connected if a PLC was used for
control. 0ote how simple the wiring becomes. 3hen using a PLC$ phsical wiring poses
much less difficult. Conse%uentl$ this helps avoid problems and speeds installation. The
inputs are on the left and the outputs are on the right. 0otice how the PLC too1 the place
of two relas$ the start rela and the timed rela. - replacing these two components the
PLC has alread almost paid for itself. <urthermore$ b using a PLC additional timers$
relas and other devices can be added for logical control at no cost.
/ne aspect that is not shown here is the program that the PLC must run to control
the process correctl. At each point$ an input and output are connected to the PLC there
is an address. This address is used in the software to 1eep trac1 of the different devices.
(7hould this e#ample be deleted= Moved to appendi#=)
PLC Process Example
7o wh are PLCs so useful= 3ell for e#ample$ s7uppose there is a process where
there is a pressure build up. A solenoid is powered to 1eep a valve shut. Dver time a
pressure sensor is tripped$ a solenoid
is de!activated for )8 seconds. That
in turn allows the valve to open and
the pressure to be released. After )8
seconds$ power is restored to the
solenoid and the valve is closed. (A
solenoid is solenoid is a magnetic switch that closes a circuit. "t is often used as a another
tpe of rela.) Also suppose that the process needs to count how man times the solenoid
is de!activated. 3ithout a PLC the process would follow this diagramthe diagram above.
The pressure sensor would feed information in a timer and a counter (two separate unites
of hardware). -ut what if the process included )8 sensors and )8 solenoids= 3eCd need
)8 timers and )8 counters. ThatCs a lota large amount of hardware that ta1es up room on
the factor floor. And Moreover$ if a manual release button and other safet sensors were
also needed$ the situation can become comple# and involve a large amount of hardware.
"f an one unit failed the whole sstem would have to be shut down$ the fault found and
then fi#ed. -efore PLCs$ however$ this is how it was done.
"nstead of a large amount of
devices and the resulting complicated
wiring$ one piece of hardware$ a PLC
can ta1e the place of all 58 the timers
and counters. "t can simulate all the
necessar logic within its
programming. And if the PLC brea1s$
it is easil replaced.
PLCs replace all the wiring and individual pieces of hardware li1e counters$
timers and relas. -efore PLCs were used the wiring$ configuring and troubleshooting all
these components would often get ver complicated. 3ith a PLC$ all wiring is done in
software where it is drawn clearl and much easier to understand. This adds an additional
benefit were if a change was needed to be made$ no disconnecting of hardware would be
re%uired. 0o one would have to disconnect wires and move around hardware. That can be
ver time consuming and tedious. /nl the PLCCs program would need to be updated and
then loaded into the PLCCs memor.
Typical PLC Applications
PLCs are implemented in a variet of control operations from large to small.
Carwashes are a popular use for PLCs because it involves intricate use of sensors and
motors$ but also has the need for relativel comple# logic. Carwashes have several wash
tpes that use or doesnCt use certain features. Dach car wash can be a ver uni%ue and
involved process$ but it is greatl simplified when done in the PLCCs software as opposed
to a hardware implementation.
PLCs are used for sorting pac1ages on a conveor b operating a diverter. /ne
conveor can move man tpes of pac1ages. A sensor can detect a pac1age tpe and a
series of diverters can sort them at the end of the belt. "n this wa$ one conveor can be
used instead of man. -ut the PLC is fle#ible$ it can be reprogrammed if and when the
sorting tas1 changes or if enhanced operation is needed.
PLCs are used to operate greenhouse irrigations sstems. "t can be used to control
how often and the amount of water distributed to certain areas. "t can control a large
amount of valves to certain areas and is fle#ible as the greenhouseCs needs change.
Lumber mills use PLCs to control the main saw and loading of wood while
various sensors ensure safe operation so that people and e%uipment are not harmed. A
lumber mill saw is ver e#pensive and man precautions must be ta1en to ensure that
nothing goes wrong when moving lumber through the mill.
PLCs can withstand the hash condition desert conditions while controlling an oil
recover process. Temperatures can get higher than )58 degrees <ahrenheit in the desert$
et a PLC can read sensors and control the motors necessar for oil e#traction. These tin
computers are meant to be rugged. Beferences to more application=== Ees
Basic PLC Structure
A PLC has four maFor internal
components. The CPG contains the
microprocessor$ registers$ control cloc1 and
various other processing units. The memor
contains userCs program$ program data storage
and PLCCs operating sstem. 7ome memor is
B/M (read onl memor) wish gives permanent
storage for the operations sstem and fi#ed data for the CPG. /ther memor is BAM
(random access memor) which stores data for the userCs program and values of timers$
counters and other internal devices. /ften some of the PLCCs BAM has batter bac1ups
so that if the PLCCs power is une#pectedl turned off it can resume normal operation
when the power is restored b referring to the batter bac1ed bits. The input and outputs
provides the interface between the sstem and the outside world. &65( The PLCCs
program is stored on DDPB/M (electricall erasable programmable read!onl memor)
that is a permanent part of the PLC. As memor costs drop new tpes of memor such as
flash are being used. &)(
"nputs to$ and outputs from$ a PLC are necessar to monitor and control a process.
-oth inputs and outputs can be categori9ed into two basic tpes4 logical or continuous.
Consider the e#ample of a light bulb. "f it can onl be turned on or off$ it is logical
control. "f the light can be dimmed to different levels$ it is continuous. Continuous values
seem more intuitive$ but logical values are preferred because the allow more certaint$
and simplif control. As a result most controls applications (and PLCs) use logical inputs
and outputs for most applications &)(.
@ere are some tpical input voltage values for PLCs &)(4
• )5!5' >dc
• )88!)58 >ac
• )8!+8 >dc
• )5!5' >ac;dc
• 6 >dc (TTL)
• 588!5'8 >ac
• ', >dc
• 5' >ac
There are man trade!offs when deciding which tpe of input cards to use &)(.
• .C voltages are usuall lower and therefore safer (i.e.$ )5!5'>).
• .C inputs are ver fast$ AC inputs re%uire a longer on!time. <or e#ample$ a
+8@9 wave ma re%uire up to );+8sec for reasonable recognition.
• .C voltages can be connected to larger variet of electrical sstems.
• AC signals are more immune to noise than .C$ so the are suited to long
distances$ and nois (magnetic) environments.
• AC power is easier and less e#pensive to suppl to e%uipment.
• AC signals are ver common in man e#isting automation devices.
/utputs are often specified as being of rela tpe$ transistor tpe or triac tpe
&65(. 3ith rela tpe$ the signal from the PLC output is used to operate a rela and so is
able to switch currents of the order of a few amperes in an e#ternal circuit &65(. Bela
outputs are suitable for AC. and .C switching. The can withstand high surge currents
and voltage transients &65(. The transistor tpe of output uses a transistor to switch
current through the e#ternal circuit. This gives a considerable faster switching action
&65(. Triac outputs can be used to control e#ternal loads which are connected to the AC
power suppl. "t is strictl for AC. operation &65(.
Tpical output voltages are listed below$ and roughl ordered b popularit4 &)(
• )58 >ac
• 5' >dc
• )5!', >ac
• )5!', >dc
• 6>dc (TTL)
• 5?8 >ac
The PLCs CPG is protected
b /ptoisolators. That is it is
electricall isolated from its inputs
and outputs. The /ptoisolators
uses a LD. and photo sensor to
conve voltage information. 3hen a
digital pulse passes through the
LD.$ a pulse of infrared radiation is
produced &65(. This pulse is detected b the phototransistor and gives rise to a voltage in
that circuit. The gap between the LD. and the phototransistor give electrical isolation
&65(. This wa if there is a large voltage spi1e$ the PLC will not be damaged.
The terms sourcing and sin1ing are used to describe the wa in which .C devices
are connected to a PLC &65(. An input or output said to be sourcing when it uses a PLC as
its power source. PLCs often provide power for the output devices connected to it. An
input or output said to be sin1ing when it provides its own power for operation. /ften
sensors are used as sin1ing inputs. 3hen discussing sourcing and sin1ing we are usuall
referring to the output of the sensor that is acting li1e a switch &)(. "n fact$ the output of
the sensor is normall a transistor that will act li1e a switch (with some voltage loss). A
P0P transistor is used for the sourcing output$ and an 0P0 transistor is used for the
sin1ing input &)(. 3hen discussing these sensors the term sourcing is often interchanged
with P0P$ and sin1ing with 0P0 &)(.
7ome PLC haves communications inputs and outputs. This can be serial or
parallel cables or even the abilit to communicate on an Dthernet. "s useful in large
controls situations where man PLCs in remote locations are controlled b one master
Basic PLC Operation …maye a sususection
A PLC wor1s b continuousl running a
program that chec1s the inputs and then updates
the outputs. The process of the PLC running
thought its program is called scanning. 7canning
speed depends on the program si9e and e#ecution
time. The total time for a PLC to chec1 the inputs$
run the program and update the outputs is called
the ccle time. Tpical ccle times are )8 ms to
)88 ms. Dver ccle the inputs are chec1 and
saved to memor. Then the program is run using
the status of the saved inputs. After the program is done the outputs are updated and the
ccle starts again.
PLC Programming
Programming Introduction
The main method for PLC programming is called ladder logic. "tCs not the usual
tpe of programming such as -A7"C$ C or assembl. "t is a graphical programming
language that uses graphical smbols to provide the PLC with the logical instructions
needed to perform control operations. Learning how to use and implement PLCs is
basicall learning ladder logic. 3hen PLCs first arrived the were made to replace rela
hardware. "t was preferred that a minimum about of retraining would be necessar for the
engineers and trades people to operate and implement the PLCs. As a result$ ladder logic
was developed to mimic rela logic. Ladder logic programs resemble rela logic
schematics. -elow is the rela logic diagram for the ?!phase controller. (7hould " redraw
this with Autoshapes as "Cve done in the PowerPoint presentation=) 0o. Leave it as is. "t
is the perfect e#ample of how ideas get started
-elow is the ladder logic for the PLC implementation of the ? phase converter
controller. The two diagrams have man similarities.
3hen PLCs first arrived the were made to replace rela hardware. "t was
preferred that a minimum about of retraining would be necessar for the engineers and
trades people to operate and implement the PLCs. As a result$ ladder logic was developed
to mimic rela logic. Ladder logic programs resemble rela logic schematics.
LetCs start the introduction to ladder logic b comparing it to a circuit diagram.
@ere is a simple circuit for operating an electric motor. 3hen the button is pushed the
circuit will close and cause the rela to activate to the
motor. 3hen the button is released$ the circuit will open
and the motor will stop. "n the lower part of the figure is
the same operation in ladder logic. Power is said to
flow from the left power rail to the right rail. This
small diagram is actuall a ver small ladder logic
program where A-uttonC is assigned a PLCs input and
AMotorC is assigned to the PLCs output. "t is important to note that ladder logic is not a
circuitCs schematic and ladder logic does not show the relative positions of components to
each other as a circuits diagram does. An important distinction is that a ladder logic
program is a set of logical instructions and not a wa to phsicall connect components.
Terms and Symols
Ladder logic is so named because the
diagram loo1s li1e a ladder. Dach step in the
program is called a rung. The vertical lines on
the left and right are the power rails. Dach
rung defines one operation in the control
process. The ladder diagram is read from left
to right and from top to bottom. Dach rung
starts with one or more inputs and ends with at
lease one output.
There are %uite a few manufacturers of PLCs. Dach has its own brand of ladder
logic programming. Though the are all ver similar and if ou can program in one
manufactureCs ladder logic language it is eas to use
them all. @ere are a few standard smbols. The
power rails$ the open and closed contact and the
output device. Power is alwas said to flow from left to
right. Power flows though an open or closed contact
depending on input conditions. And if power can get to
an output device it turns on. Contacts are alwas on
the left side of the ladder and output devices are
alwas on the right side.
The contacts and the output device can either be real input and output connections
on the PLCs or the can be special functions in the ladder program. A contact is assigned
to a device that is part of the control process through an address. "t alwas follows the
state of the device it is assigned too. "t can be assigned to an input$ an output or even a
variable in the PLCs memor. A contactCs assigned device can be a push button$ a
temperature sensor$ a motor or even a bit mar1er or counter that onl e#ists in the PLCs
3hen programming in ladder logic$ the snta# for the address of contacts and
output devices depends on the particular brand of ladder logic being used. "n the figure
bellow are some e#ample of addressing schemes for various PLC brands and models.
<urther e#amples will either use words for addresses or the 7iemens (b) addressing
scheme where A"C are used for inputs and AHC are used for outputs.
A contact is assigned to either an input of the PLC or some other element that is
part of the control program. A contact alwas follows the state of the device it is assigned
to. "t can be assigned to an input$ an output or even a variable in the PLCs memor. <or
e#ample$ a contactCs assigned device can be a push button$ a temperature sensor$ a motor
or even a bit mar1er or counter that onl e#ists in the PLCs memor. Power onl flows
through a normall open contact when the device assigned to the contact is in its on state.
Power onl flows through a normall closed contact when the device assigned to the
contact is in its off state.
As an e#ample$ consider a motor operated b a button. <or as long as the button is
held down the motor will be on. 3hen the motor is off a lamp indicating that the motor is
off must be lit. 3hen the motor is on$ an on light must be activated. This is an e#ample of
how contacts can follow the state of an input as well as an output device. The contact
labeled button follows the state of a button wired to the PLC. The contact labeled Motor
follows the state of the Motor output device.
The e#ample above was written using Pico7oft$ a Microsoft 3indows ladder logic
development tool b Allen!-radle. This specific software was made for a brand of PLCs
called Pico Controller. Pico7oft is a free tool that can be used to write and simulate ladder
logic. Pico7oft can be found at http4;;;plclogic;pico;picosoft.html. "n the
ladder logic$ the A")C is the address to the input ) on the PLC. AH)C$ AH5C$ AH?C are the
addresses to output )$ 5$ ?$ respectivel. The words below each element such as AmotorC
or Aon lampC are comments and onl on function to e#plain the diagram.
Basic Logic
-elow is a ladder logic rung called a seal!in!circuit. 3hen A is activated it will
cause the output - to turn on. - will remain on regardless of an further input$ thus it is
7ometimes ou need a machine to 1eep running even after the start button has
stopped being depressed. This re%uired a method called latching. Consider a PLC with
two buttons wired to its inputs and a motor wired to on of its outputs. "f the PLC is
programmed with the ladder logic in
the figure on the right it will wor1 as
follows. 3hen the start button is
pressed the motor will turn on and
will sta on if the button is released.
The contact labeled motor will
follow the state of the output device labeled motor. Therefore b pressing the start button$
the Motor contact will also activate. 3hen the start button is released$ the motor will sta
active because of the motor contact on the lower rung will still be in the on state. The stop
button must be used to turn the motor off b causing its contact to open. This is ver
similar to a seal!in!circuit but with the additional option of deactivating the circuit. 0ote
that if both buttons are pressed simultaneousl the motor will not turn on.
Latching an also be done
b using more advanced ladder
logic commands. The figure to
the right is a ladder logic program that uses the set and reset commands to achieve
latching. This ladder logic is e%uivalent to the previous figure. 3hen the on button is
press it will all power flow through the motor device with the A7C in the center. The A7C
stands for set. This will cause the motor to sta active unless power is allowed to flow
though the motor device with the ABC in the center. The ABC stands for reset. As before$ in
the event that both buttons are pressed simultaneousl the motor will not be active.
There are man control situations re%uiring outputs to be activated based on
certain conditions. <or e#ample a conveor belt ma onl need to be run if it is loaded
A0. there is capacit to receive its load at the end of the belt. This is an e#ample when a
logic A0. is needed. The truth table and the ladder logic for an A0. gate is below. A
and - are the inputs and K is the output. The truth table is a method for showing all
possible outputs based on an possible inputs.
A!" #ate
/ther gates such as /B$ 0/T and K/B can also be constructed. Gsing these
game -oolean algebra can be calculated in ladder logic.
OR #ate
!OT #ate
$OR #ate
The following figure shows a conveor belt that can be activated electricall.
There are two push button switches at the beginning of the belt4 7) for 7TABT and 75 for
7T/P. There are also two push button switches at the end of the belt4 7? for
7TABT and 7' for 7T/P. "t is possible to start or stop the belt from either end.
Also$ sensor 76 stops the belt when an item on the belt reaches the end.
The following is the ladder logic need to control the belt from either end. The ladder logic
is in shorthand notation where the right power rail is implied but not drawn. The two
ladder logic sections can be Foined together for the complete program. 0otice /B gates
are being used.
Internal Relays
Bela logic was so named because instead of relas being used for remote
switching of large current devices$ the were used for logical operations. A PLC replaces
these logical relas with internal relays that e#ist onl in the PLC software. A variet of
other terms are often used to describe these elements$ e.g. auxiliary relays, markers,
flags, coils, bit storage &5'(. "n the Allen -radle Pico Controllers$ the term marker is
used and its address uses the notation M)$ M5$ etc. "nternal relas addressed differentl
to distinguish them from e#ternal relas or an other element in the ladder logic program.
Consider the ladder logic program below. A sstem is to activated when two
different sets of input conditions are reali9ed. This could be programmed as an A0.
logic gate sstemL however$ if a
number of inputs have to be
chec1ed in order that each of the
inputs conditions can be reali9ed$ it
ma be simpler to use an internal
rela. Also if the result of M)
needs to be used more than once
in the ladder program$ an internal
relas would be more succinct.
"nternal relas can also be used with the set and reset commands.
"f the power suppl is cut off from a PLC while it is being used$ all the output
relas and internal relas will be turned off. Thus when power is restored$ all the
contacts associated with those relas will be set differentl from when the power was on.
Thus$ if the PLC was in the middle of some se%uence of controls action$ it would resume
at a different point in the se%uence. To overcome this problem$ some internal relas have
batter bac1!up so that the can be used in circuits to ensure a safe shutdown of plant in
the even of a power failure and so enable it to restart in an appropriate manner. 7uch
batter!bac1ed relas retain tier state of activation$ even when the power suppl of off.
The relas is said to have been made retentive. 7uch a feature on a PLC will be in its
documentation where it will specif that batter bac1ed internal relas lie in a certain
address range$ i.e. M)8!M)6$ etc &5'(.
The following figure shows a conveor belt that is e%uipped with two
photoelectric barriers (PD-) and PD-5) that are designed to detect the direction in which
a pac1age is moving on the belt. Dach photoelectric light barrier functions li1e a normall
open contact.
As part of its CPG$ a PLC has a control cloc1 that can be used to time events and
deliver output when certain timer parameters are met. The timers can be represented in
ladder logic as output devices with corresponding contacts or as bloc1 functions. 0otice
that the ladder logic programs on the left and rightbelow are them same perform the same
function. The left one uses output devices or coils and the right one uses bloc1 functions.
The e#actl stle of timer will depend on the manufacturer and brand of the PLC that the
ladder logic development program is used for.
"n Pico7oft$ the output device and contact method is emploed. There are man
tpes of timers for PLCs. The two most basic tpes are the on-delay and the off-delay
timer. 3ith an on!dela timer$ once the timer coil gains power$ its corresponding contact
will not turn on immediatel. "nstead a timer will start and once it is complete onl then
will the timer contact be in its active state. Antime the timer coil looses power$ the timer
is reset and the timer contact also loose power.
<or e#ample$
consider a motor control
process where a motor is
controlled b a button$ but
the motor onl starts after a
warning siren has sounded
for 6 seconds.when a
button is pressed and held a 6 second on!dela timer will start. 6 seconds later the motor
will then activate. As soon asAn time the button is released the motor will stop. The
ladder logic for this operation is below. An on!dela timer is used because it delays motor
from turning on.
An off!dela timer wor1s
b delaing the deactivation of a
device. Consider a motor that is
activated b a button. 3hile the
button is held the motor starts
immediatel and runs until the
button is released$. when it is
released the motor stops. "t is
re%uired that two lamps
indicating the status of the motor
be lit. @owever it ta1es a few
seconds for the motor to stop
spinning so the on lamp should
remain lit for a set amount of time after the button is released. /ne lamp indicates the
motor is off$ the other indicates it is on. @owever$ when the button is released the motor
still spins for a few seconds. The on!lamp should sta on during this time. Therefore$ an
off!dela is needed for the AonC lamp so that it stas illuminated a few seconds after the
on button is releasedis delaed in turning off. The ladder logic for this operation is above.
0otice in rung '$ the off lamp is programmed to simpl do the opposite of the on lamp. "n
this e#ample$ as soon as the timer output device$ T)$ has power flow$ its associated
contact goes into the on state. 3hen the output device T) loose power however$ the T)
contact remains in the on state for a few second while the timer is counting down.
"n addition to these two basic tpes of timers there are others. A retentive timer
retains its timer even after its coil loose power flow. <or e#ample$ a button controls a
motor and a retentive timer such that when ever the button is pressed the motor and the
timer are active. Thus$ the retentive timer will 1eep trac1 of the total time the motor has
been powered. Pulse timers or one-shot timers produce an output for a fi#ed duration not
dependent on an other input. As soon as a pulse timer gains power$ its associated contact
will become active for a set time after which it will deactivate. This occurs regardless of
what happens to the pulse timer coil.
Eou can use a cloc1 pulse generator or flasher rela when ou need to produce a
signal that repeats periodicall. A cloc1 pulse generator is common in a signaling sstem
that controls the flashing of indicator lamps. The e#ample shown in the following ladder
logic program$ however$ illustrates the use of timer functions to generate a cloc1 pulse.
The sample program shows how to implement a freewheeling cloc1 pulse generator b
using a timer.
A counter is
used to count and store
the number of
occurrences of an input
signal. Li1e a timer$ a
counter can be
represented b an
output device and contact pair or a bloc1 function. A counter is set to some preset
number value and when this value of input pulses has been received it will operate its
associated contacts. There are two tpes of counters4 up!counters and down!counters. An
up!counter starts a 9ero and count up to a preset limit. A down!counter starts a preset
limit and counts down to 9ero. 3hen the counter reaches the set value$ its contacts are
activated. Counters also have a reset coil that when activated re!initiali9ed the current
count value. <or up!counters it is set to 9ero. <or down counters a reset would set the
current count value to the preset limit.
"n the picture below there is a process where a counters counts )8 pulses then
activates an output. A pulse is the action of the counter output device going from the
powered state to the un!powered state. "n ) controls the counter reset and "n 5 supplies
the counter with impulse to count. The plot on the right indicates the status of the
elements with respect to time. After ten pulses the counter reaches its limit and activates
it contacts thereb activating /ut ).
Consider the problem of the control of a machine which is re%uired to direct + tins
along one path for pac1aging in a bo# and then )5 tins along another pat the pac1aging in
another bo#. A deflector plate might be controlled b a photocell sensor which gives an
output ever time a tin passes it. Thus the numb rod pulse from the sensor has to be
counted and used to control the deflector. /n rung )$ each time the photo sensor is
triggered it causes C)Cs count to increase. 3hen C)$ the si# tin counter$ reaches si# it
causes the deflector to activate. /n rung ?$ while the deflector is activated C5$ the )5 tin
counter$ and starts counting tins. /n rung '$ after )5 tins are counted the counters are
reset and the process starts again. The process can also be reset at antime using the start
Comparison Instructions
Ladder logic for PLCs often includes instructions that can compare two values
and operate a contact based on the result. "f the two values are "0) and "05 the can be
compared as follows4
• MM "0) is e%ual to "05
• NO "0) is not e%ual to "05
• O "0) is greater than "05
• N "0) is less than "05
• OM "0) is greater than or e%ual to "05
• NM "0) is less than or e%ual to "05
"n this case$ function bloc1s are used as the graphical smbol in the ladder logic.
The input values "0) and "05 can be programmed directl in to the comparer or the
can be ta1en form other elements in the ladder program such as timers and counters.
The following figure shows a sstem with two conveor belts and a temporar
storage area in between them. Conveor belt ) delivers pac1ages to the storage area. A
photoelectric barrier at the end of conveor belt ) near the storage area determines how
man pac1ages are delivered to the storage area. Conveor belt 5 transports pac1ages
from the temporar storage area to a loading doc1 where truc1s ta1e the pac1ages awa
for deliver to customers. A photoelectric barrier at the end of conveor belt 5 near the
storage area determines how man pac1ages leave the storage area to go to the loading
doc1. A displa panel with five lamps indicates the fill level of the temporar storage
0otice in this e#ample a bloc1 counter$ C)$ is used. 3hen the counter has reached its
limit the output H on the bloc1 will activate. A comparer can use values from C> and
-C. from the counter to compare values. C> is the values of the counter and -C. is the
counter value in binar coded decimal.
PLC Example
<rom the earlier e#ample$ here is a ver simple ladder logic program and its
wiring schematic. A wiring diagram is alwas needed because the PLC program isnCt a
wiring schematic and lac1s the
information about how sensors are
wired. "t is important to 1now under
what circumstances a sensor forms a
closed circuit or an open circuit.
Ladder logic loo1s much li1e a
schematic of phsical components
but remember itCs Fust a graphical
<rom the preceding e#ample$ it is desired that when the pressure is too high the
pressure sensor is tripped. The PLC detects this and deactivates the solenoids for )8
seconds to open the release valve. Also a count of the event is made. 3hen the pressure is
high enough$ the sensor will close the contacts and form an electrical connection.
Current will flow from the PLC to the ground and this will inform the PLC that the
sensor is in its /0 state. 7ince the sensor is programmed as normall open according to
the programming$ power onl flows when its assigned device is in its /0 state. /nce the
sensor it in the /0 state$ the counter will increase and the timer will turn on. The dela!
off timer will remain in the /0 state for )8 seconds regardless of the state of theafter
Pressure 7ensor contact opens again. The timer contact is programmed as normall
closed$ therefore when the output Timer is /0$ the timer contact will de!activate. This
will cause the 7olenoid to de!activate and the pressure release valve will open.
As before a Mmanual shut off can
be added to the sstem as well as a safet
sensor. 0otice that the manual release and
safet sensor are programmed as normall
open. This is so if there is an problem
with the sstem or the safet sensor or
shut off the solenoid will lose power and
the pressure release valve will open
causing the process to fail safe.
Ladder logic is alwas drawn in the
wa the device is preferred to fail. @ere if the
7safet 7sensor or Mmanual shut off
components fail or if the PLC fails the
7solenoid will be de!activated. This is the
safest wa for the process to fail because the
pressure value will open if there is an
problem. @ere is the/n the right is the wiring
schematic for the PLC. 0otice that the safet
sensor and manual shut off are wired such that the are usuall in an on state. 3hen these
two devices are activated the cause an open and the PLC detects that these devices are in
the off state. This is so if there is an problem with these input devices$ it is more li1el
that the will fail open and thus de!activate the solenoid and vent pressure. 3hen
programming a PLC$ contacts should alwas be programmed to be normall in the state
ou want them to fail in.
And of course as before the process can become large if more sensor and
solenoids were re%uired. The PLC program would have to be repeated for each sensor!
solenoid pair and more input and output device would be wired to the PLC.
%ixer Example
As an e#ample$ cConsider an industrial mi#er a where a drum is to be filled with
li%uid. After it is full$ a heater is used to heat the li%uid until it reaches a certain
temperature. Then the drum is to rotated for )8 minutes$ then the process stops
@ere -elow is the se%uential function
chart for this process. 7<Cs are useful when the
control process involves a series of steps. The
process stas in the current state until a
condition is satisfied.
@ere is/n the right is the wiring diagram
for the mi#er. As alwas all the inputs and
output are wired directl to the PLC. The
operating logic is all stored in the PLC as a
ladder logic program. 7o based on the inputs of
the start button$ the level full floater and the
temperature sensor the PLC will decide when to
turn on the pump$ heater and motor.
@ere /n the right is the ladder
logic for the pump and the heater. /nce
the start button is pressed the pump will
sta on until the li%uid is at the re%uired
level. This is done through latching with
the Pump contact. 3hen the floater is
activated$ it will stop the pump at the
re%uired level. /nce the level switch is
active the pump will be shut off and the
heater will be activated. The li%uid will be
heated until the temperature switch is
triggered. There the heater is latched so
even if the li%uid level goes down it will
still be heated until the re%uired temperate
is reached. The Atemperature reachedC
contact is not assigned to an input or
output of the PLC. -ut instead to an
internal output devicerela that onl e#ists
in the PLCs memor. "n total$ the ladder logic program has five rungs. 0otice for 7tate ?$
at the top$ once the ATemperature sensorC is tripped it will activate the ATemperature
reachedC output device. This device onl e#ists in the PLCs memor and acts as a
variable. /nce active it latches its self to the on state. This insures that the timer is onl
activated once and the heater doesnCt turn bac1 on if the li%uid cools. /nce the timer is
activated it will cause the )8 minutes timer
contact to close and the mi#ing motor to
turn on. The motor will operate for )8
minutes and then stop.
Program "esign
7ince Ladder ladder logic is essentiall a computer program it is subFect to bugs
and faults. "n the industrial environment process and operator safet are primar conerns.
Therefore an program needs to be tested for accurac and robustness. 3hen writing
programs a fail!safe design should be emploed. Programs should be designed so that
the chec1 for problems$ and shut down in safe was. Most PLCCs also have imminent
power failure sensors. These sensors should be used to shut down the sstem safel
whenever danger is present. Proper programming techni%ues and modular programming
will help detect possible problems on paper instead of in operation. Careful effort should
be ta1en to write modular well designed programs that are predictable. The program
should also be inaccessible to unauthori9ed persons. Programs should also chec1 for
sstem /P at start!up. PLCs have built in functions for error and failure detection that
should be used to 1eep the sstem safe. &)(
Time chec1s can also be built into the ladder logic program. This is where
additional ladder rungs might be includes so that when a function starts a timer is started.
"f the function does not complete when the timer finishes a fault is signaled. The function
might be the moving of a piston or filling a drum with li%uid. Man PLCs have a simulate
mode where the installed program can be run and inputs and outputs simulated so that
the can be chec1ed. PLC ladder logic software can test against programming snta#
7tatus lamps can be used to indicate the last output that has been set during a
process which has come to a halt. This techni%ue is called last output set. 7uch lamps are
built into the program so that as each output occurs a lamp comes on. The lamps on thus
indicate which outputs are occurring. The program has to be designed to turn off previous
status lamps and turn on a new status lamp as each new output is turned on. &65(
3here there is concern regarding safet in the case of a fault developing$ chec1s
ma be constantl used to detect faults. /ne techni%ue is replication checks which
involves duplicating$ i.e. replicating$ the PLC sstem. This could mean that the sstem
Fust repeats ever operation twice and if it gets the same result it is assumed there is no
fault. This procedure can detect transient faults. A more e#pensive alternative is to have
duplicate PLC sstems and compare the results given b the two sstems. "n the absence
of a fault the two results would be the same$ a fault showing up as a difference. &65(
/ne method of testing is called forcing. This is where input states are forced to
certain states in software. Programming errors can sometimes be found b forcing inputs
at various stages in the ladder program. Most PLCs will allow a user to force inputs and
outputs. This means that the can be turned on$ regardless of the phsical inputs and
program results. This can be convenient for debugging programs$ and$ it ma1es it eas to
brea1 and destro thingsQ 3hen forces are used the can ma1e the program perform
erraticall. The can also ma1e outputs occur out of se%uence. "f there is a logic problem$
then these donCt help a programmer identif these problems. &)( <orcing can be used to
test the safet chec1s in the software to see if the wor1 when une#pected conditions
Time chec1s can also be built into the ladder logic program. This is where
additional ladder rungs might be includes so that when a function starts a timer is started.
"f the function does not complete when the timer finishes a fault is signaled. The function
might be the moving of a piston or filling a drum with li%uid. Man PLCs have a simulate
mode where the installed program can be run and inputs and outputs simulated so that
the can be chec1ed. PLC ladder logic software can test against programming snta#
errors.After a program has been written it is important to verif that it wor1s as intended$
before it is used in production. "n a simple application this might involve running the
program on the machine$ and loo1ing for improper operation. "n a comple# application
this approach is not suitable. A good approach to software development involves the
following steps in appro#imate order4
). 7tructured design ! design and write the software to meet a clear set of obFectives.
5. Modular testing ! small segments of the program can be written$ and then tested
individuall. "t is much easier to debug and verif the operation of a small
?. Code review ! review the code modules for compliance to the design. This should
be done b others$ but at least ou should review our own code.
'. Modular building ! the software modules can then be added one at a time$ and the
sstem tested again. An problems that arise can then be attributed to interactions
with the new module.
6. .esign confirmation ! verif that the sstem wor1s as the design re%uires.
+. Drror proofing ! the sstem can be tested b tring e#pected and une#pected
failures. 3hen doing this testing$ irrational things should also be considered. This
might include unplugging sensors$ Famming actuators$ operator errors$ etc.
R. -urn!in ! a test that last a long period of time. 7ome errors wonCt appear until a
machine has run for a few thousand ccles$ or over a period of das. &)(
Program testing can be done on machines$ but this is not alwas possible or desirable.
"n these cases simulators allow the programs to be tested without the actual machine.
The use of a simulator tpicall follows the basic steps below.
). The machine inputs and outputs are identified.
5. A basic model of the sstem is developed in terms of the inputs and outputs. This
might include items such as when sensor changes are e#pected$ what effects
actuators should have$ and e#pected operator inputs.
?. A sstem simulator is constructed with some combination of speciali9ed software
and hardware.
'. The sstem is verified for the e#pect operation of the sstem.
6. The sstem is then used for testing software and verifing the operation. &)(
Ladder logic can do much more than what has been shown so far. "t can utili9e
registers and bits to store and move data. There are data comparison functions such as
chec1ing for e%ual to$ less than or greater than. There are arithmetic operations such as
addition$ subtraction and multiplication. There are functions that can transform number to
different bases or formats. 7ome PLCs can provide P". (proportional integral derivative)
calculations to control a variable simpl b being provided the necessar parameters.
At this point (ma1e it impersonal) should reali9e how PLCs can solve man
problems in industr. PLC7 are fle#ible and can be reapplied to control other sstems
%uic1l and easil. The are cost effective for controlling comple# sstems. The posses
high computational abilit that allows more sophisticated control through ladder logic.
Trouble shooting aids ma1e programming easier and reduce downtime. Beliable
components ma1e PLCs li1el to operate for ears before failure. &)(
Eou should also reali9e that right now$ if ou had a PLC and enough ladder logic
1nowledge ou could construct a sophisticated machine with little problem as far as
operational logic is concerned.
Number Description
1 PLC book!ackh/books/plcs
" PLC #ebsite
$ PLC tutorial
% &uick PLC description
' PLC (istory
* +nline ,ncyclopedia
. PLC online /orum
1 Course e2ample!ackh/eod/egr%'3.html
4 Course e2ample"$.htm
13 Course e2ample,,6""3.htm
11 Course e2ample$$.3/,,6$$.37"3Class7"3Schedule7"3".htm
1" Course e2ample
1$ PLC simulation so)t#are
1% PLC simulation so)t#are
1' 9itsubishi;C6S/de)ault
1* 6oshiba<)amily=PLCs
1. Siemens<Nr="1%3
11 Sprecher > Schuh
14 ?llen @radley
"3 PLC book Programmable Logic Controllers ?n Antroduction 6hird ,dition B. @olton "33$ Ne#nes Publications
"1 PLC application #ebsite http://###.)<menu=$
"" Ceri)ication o) PLC ?pplications,9+S/AP?"331.ppt
"$ PLC ?pplications
"% PLC help thread<s=>threadid=1""$'
"' PLC 6utorial site http://###.)
"* PLC 6utorial site
". PLC in)o and tutorial
"1 9odicon
"4 PLC history,S/historyo)plc.html
$3 PLC primer
$1 PLC in)ormation"3and7"3related7"30uestions.
$" PLC e2ample".htm
$$ Siemens PLC primer<plcs:1:":1
$% ?@ Pico Solutions
$' ?pplications e2amples<+pen?gent>prod=nanocus
$* 6SE PLC manual<+pen?gent>prod=nanoproD
$. @+:S oil application'"'*?,133*D.1?@/all/?/@3111D,?44C3?C1'"'*@/?33%/*3/$F+penDocument
$1 PLC overvie#
$4 PLC intro!html/plcs18%.html
%3 :6; vs PLC;vsPLC.htm
%1 Ladder Logic Adeas
%" Ladder Logic editor
%$ Ladder Logic e2amples*.html
%% PLC tutorial site
%' Antro to A,C *11$1*11$181.htm
%* A,C *11$18$ /?&*'b#g.t)$/html/)a0.htm
%. 6hread on PLC Scan time<t=1""3>highlight=scanGcycleGtime
%1 Seamans on scan time<plcs:.:1:1
%4 PLC operation
'3 An)o on 5ra)cet http://###.lurpa.ens8cachan.)r/gra)cet/generalites/presentation-uk.html
'1 PLC )ailure in)o<AD=$'%
Programmable Logic Controllers 6hird
B. @olton Linacre (ouseH Iordan (ill +2)ord "33$
'$ picture o) industrial mi2er,0uipment/ind-cake-mi2er.!pg
'% PicoSo)t*L.e2e
'' 5E8Developer<S6ype=3>Doc6ype=3$'>SessionNum=>;serAD=>Division=3331'>+pt1=Jes>submit1=Search>/amily=3331'"3313>Series=3331'"3313"33$3
'* picture o) relay timer!oye/###/ebay/:elay6imer/
'. picture o) relay counter
'1 picture o) bo2 PLC http://###.controltech.cK/images/clanky/image$3.!pg
'4 picture o) optoisolator
*3 plc shipment article$'".htm
*1 (oney#ell contactor<De)inition=Product>Catalog=(omes>Category=DP"3$3-13113>Product=DP"3$3@'311>ChannelAD=L",@"/1.18"3,D8%%,384./@8
*" Price on start relay/mounting N"3"?'1%.html
*$ Price on timed relay8N%18N.3'JO1*.html
*% $ phase po#er converter e2ample
*' ladder logic manual
** $ phase converter data sheet"33'8C.pd)
*. PLC presentation'Plc.ppt