PROGRAMMABLE LOGIC CONTROLLER (PLC)
EE 6314/13
Course Tutor: Eng. Phocas Sebastian
Tutorial Assistant
(BEng: Telecommunication Systems)
[email protected]
Office no: 109A
Department of Electronics and Telecommunication Engineering
(ETE)
College of Information and Communication Technology (CoICT)
Mbeya University of Science and Technology (MUST)
Mbeya-Tanzania,
PLC’s Programming
i. Ladder Programming
ii. Conditional Logic
iii. Ladder Diagrams
iv. Outputs and latches
v. Internal relays
vi. Timers
vii.The Pulse Generator
viii.Counters
ix. PLC’s Ladder Diagram Examples
PLC Connections
Ladder Programming
Conditional Logic
• The PLC scans its inputs and, depending on the program,
switches on or off various combinations of outputs. The logic
state of the output depends on the input conditions; so the term
conditional logic is used.
A simple example of conditional logic could be stated as follows:
“A machine switches on if either of two start switches are closed
and all of three stop switches are closed.”
Conditional Logic,,,cont
The conditions could be realized by a hard wire solution as shown,
• The two start switches are connected
in parallel.
• Current will flow if one or the other or
both are closed.
• The start switches are normally open.
• This means that the contacts are apart
and no current flows when the
Machine relay Hard-Wire Conditional Logic Example switches are in their normal (or
unoperated or rest) state.
Conditional Logic,,,cont
• The three stop switches are
connected in series.
• Current can only flow if the first and
the second and the third are closed.
• The stop switches are normally
closed.
• This means that the contacts are
Machine relay Hard-Wire Conditional Logic Example
connected and current can flow when
the switches are in their normal state.
Conditional Logic,,,cont
• The relay is a switch with multiple
contacts that is operated when its
coil is energised.
• The contacts are usually capable of
carrying a larger current than A Relay
push- button or limit switches.
• Large relays for motor starting are
called contactors.
• The schematic diagram for a typical
relay and contactor is shown
A Contactor
Ladder Diagram,,,cont
To realize the
conditional logic
statement from the left
figure using ladder
logic we connect the
switches to a PLC as
shown On the right
Fig 2b PLC Wiring Diagram
Fig 2a Machine relay Hard-Wire
figure
Conditional Logic
Ladder Diagram,,,cont
To avoid later confusion regarding the concept of
normally open (n/o) and normally closed (n/c) it is
worth looking again at Fig 2b and remembering that
the plc scans each input and asks “Is it on or is it
off?”.
• The five switches shown are external devices and
the PLC knows nothing about them.
• As far as the PLC is concerned, at the moment, inputs Fig 2b PLC Wiring Diagram
X1 and X2 are off and X3, X4 and X5 are on.
Outputs and Latches
Output states (on or off) can be used in programs as conditions for other actions.
• Fig a is the wiring diagram for the program shown in Fig b.
Figure b.
Switching on the input S1 switches on the output DCV
Figure a. which in turn switches on the red light.
When the output DCV is off the green light is on.
Introduction PLC,,,,cont
Example 1
Write a PLC program to implement the conditional logic statements (a),
(b) and (c) below.
(a) A PLC output is to switch on if any of three inputs is switched on.
(b) A PLC output is to switch on if any one of three inputs is switched on but
not two or more.
(c) A PLC output is to switch on if any two outputs are switched on, but not
the third.
Solution 1 (a)
Solution 1 (b)
This program can be read:
“The output switches on if Input 1 is on AND the other two are off, OR
input 2 is on AND the other two are off, OR input three is on AND the
other two are off.”
Latches
• The push button and limit switches most commonly
used in industrial automation are the momentary
contact type.
A spring action reverts the switch to the normal
state as soon as the button or roller is released.
• These are obviously not the same as the self- NC
latching switches used, for example, in domestic
circuits.
NO
• The fact that the majority of control switches are not
self-latching is not as inconvenient as it sounds.
We can easily program in, a latch in the ladder diagram.
Latches,,,,
Operation: When the start push button switch in is pressed, the
output Y1 is to switch on and stay on until the stop button is pressed.
When the output Y1 is energised we use a normally open contact
of it in parallel with the start button to hold (or latch) it on.
The output can only be de-energised by pressing of the stop
button.
Note that we have used a normally closed switch as a stop button as
explained early.
Internal Relays
• These have the same properties as outputs but they only exist in software.
They have many uses. Fig below shows an internal relay being used to
implement the logic function NAND.
This is the inverse of the result of X1 AND X2. We will be making extensive
use if internal relays later.
Note: Most PLCs include a
function called a Set and
Reset or a flip-flop which
latches and delatches an
output or an internal
relay.
Timers
The delay-on timer introduces a delay between the
start of one event and the start of another.
• For example, when a start push button is pressed,
the pneumatic cylinder shown in Fig 3 extends,
remains extended for 5 seconds and then returns.
Draw the PLC wiring diagram and the appropriate ladder
logic.
Fig 3
The delay-off timer causes a delay between its input
switching off and its contacts reverting to their
normal states.
Timers,,,,
• The start button and the end-
of-stroke limit switch a+ are
the PLC inputs and the
solenoid Y1 is the output.
• Any other components needed
for the program can be
created in software.
Timers,,,,
Pressing the start button latches on an internal relay called start_latch.
The start_latch relay switches on the output Y1 which energizes the solenoid, and the cylinder
extends.
The cylinder rod closes the limit switch a+ which starts the timer in software.
When the timer set value time has elapsed the normally-closed contact Timer_1 in the first line
of the program de-energizes the Start_latch relay and the cylinder returns.
Timers,,,,
Example 2.
We can do another example using the same hardware with the addition of an
alarm as a second output:
• When the start push button
is pressed and released
there is a 5s delay before
the cylinder extends and
returns.
• An alarm sounds during the
5s delay.
Timers,,,,
Example 2 soln.
• When the start button is pressed the start_latch relay is energised.
• The Start_latch relay switches on the timer input and the alarm.
• When the timer set value has elapsed the alarm switches off and the solenoid Y1 is
energised.
• When the cylinder is fully extended the limit switch a+ de-energizes the start_latch relay
which de-energizes the solenoid and resets the timer.
Timers,,,,
Note that:
The input to the delay-on timer must remain on for the duration
of the timer set value otherwise the timer will not operate.
• If the signal to start the timer is only momentary then a latch is
used to sustain it.
When the input to the timer switches off, the timer contacts
revert immediately to their normal states.
Timers,,,,
• In some PLC models a timer function block can be located in the center of
a rung as shown in fig below.
When the timer set value has elapsed the timer output switches on
allowing a software signal to energize an internal relay coil or an output.
In this course all timer function blocks are located at the right hand side of
the ladder diagram and their contacts, normally-open or normally closed,
have the same label as the timer.
The Pulse Generator
• Two counters can be combined to make a pulse generator.
• The figure d. below shows the best illustrated by an example.
Fig d
The Pulse Generator
• When the Start button in Fig
d is pressed the cylinder in
Fig f oscillates,
Extending for 2s and
• Returning for 1s until the
Stop button is pressed.
Write a plc ladder program
Fig f
The Pulse Generator
PLC ladder program soln
Figure g. Pulse Generator Flowchart
• It can take a while to figure out how the pulse generator works but it is
time very well spent. The flow chart in Fig g. should help.
Counters
A counter allows a number of occurrences of input signals to be
counted.
The counter is set to a preset number value and when this value
of input pulses has been received, it will operate its contacts.
A second input or software coil is provided to reset the current
value of the counter to zero.
Consider the cam shaft
Counters
• When a start button has been
pressed the shaft is to make 10
revolutions and then stop.
• Pressing the start button also
resets the counter.
• The PLC wiring diagram is shown
on the left
The PLC wiring diagram
Counters
The PLC Ladder diagram
PLC’s Ladder Diagram Examples
1. Water level control • The Inlet valve opens when the water level
goes to the lower level of the underground
tank and gets closed when the underground
tank gets full.
• The pump starts only when the water level
in the overhead tank goes to the lower level
of the overhead tank.
• The pump stops when the overhead tank
gets full or the water level in the
underground tank goes to the lower level.
I.e. The pump should not dry run.
PLC’s Ladder Diagram Examples
1. Water level control; Input and Output devices list
PLC’s Ladder Diagram Examples
1. Water level control SOLUTION
PLC’s Ladder Diagram Examples
2. Milk bottle filling and capping application
PLC’s Ladder Diagram Examples
2. Milk bottle filling and capping application
• Start the conveyor in auto mode.
• When a bottle present sensor 1 detects the bottle, the conveyor gets stopped and
the controller turns on the valve. The milk starts pouring into the bottle up to a
certain level, then the valve gets off and the conveyor starts again.
• When a bottle present sensor 2 detects the bottle, the conveyor gets stopped, and
the capping piston operates, when a cap is detected by a sensor, the capping piston
stops and the conveyor starts again.
• When a bottle present sensor 3 detects the bottle, the conveyor gets stopped, and
the labeling piston operates, when a label is detected by a sensor, the labeling
piston stops and the conveyor starts again.
• This cycle continues until a stop PB is pressed.
PLC’s Ladder Diagram Examples
2. Milk bottle filling and capping application Input and Output devices list
PLC’s Ladder Diagram Examples
2. Milk bottle filling and capping application solution