8) Programmable Logic Controllers
Programmable Logic Controllers
Sequential Control (Discrete-State Process Control or On/Off Control): Process has
to follow a predefined sequence by turning On or turning Off the actuators. Sequential
control can be solved by Boolean logic [Combinational Boolean Logic + Sequential
Boolean Logic].
Relay Logic
− Conventional method of implementing Sequential Control using array of relays
and switches
− Special kind of relays/switches e.g. timer relay (for delays), Limit switches, Level
switch (to detect level), thermal switch (to detect temperature)
Relays /Switches
Relay Logic: OR
Using two switches, a logical “OR” operation can be constructed. An example is
given below:
Switch 1 “OR” Switch 2 = Coil
Switch 1 off “OR” Switch 2 off = Coil off
1/21
8) Programmable Logic Controllers
• Switch 1 on “OR” Switch 2 off = Coil on
• Switch 1 off “OR” Switch 2 on = Coil on
• Switch 1 on “OR” Switch 2 on = Coil on
Example 1: On/Off push button of a motor
Motor OFF
Relay OFF
Stop pressed Start pressed
Motor ON
Relay ON
State Diagram of On/Off push button
2/21
8) Programmable Logic Controllers
Relay Contact a1
(Normally Open)
+VCC
Start Push Button Relay Contact a2
(Normally Open) (Normally Open)
Stop Push Button
(Normally Closed)
Motor
M M
Relay Coil
A
PLC System
Software solution to Relay Logic.
1. CPU: Central Processing Unit, generally consists of
i) Microprocessor: mathematical and logical operation
ii) Memory: stores data and program. Generally basic PLC programming in
ROM and user program and data in EEPROM (Electrically Erasable
Programmable Read–Only Memory)
iii) Power Supply: DC supply to CPU and modules
2. Programmer/Monitor: device to program and monitor PLC. PC also used.
3. I/O Modules: Interface with process to be controlled. E.g. Digital I/O, Analog I/O,
Encoder interface, PWM output etc.
4. Special Modules: for special purpose. E.g. PID controller module, Interrupt handling
module
5. Racks and Chassis: to enclose CPU and different modules. The CPU and modules
are attached by a bus system within the racks.
Programmer/
Monitor
CPU
Microprocessor
Input Memory Output
Module Module
Power
Supply
Rack and Chasis
3/21
8) Programmable Logic Controllers
Power Supply CPU I/O Modules
Power to PLC Communicating Ports
to PM or PC
Ladder Diagram
− Graphical Programming Language for PLC
− Based on Relay Logic
Basic Components of Ladder Diagram
Normally Open (NO) Contact
Coil/Output
Normally Closed (NC) Contact
ISO Standards for Logic Gates Symbols [Combinational Logic]
Commonly used logical gate symbols (page 247, Olsson and Piani)
1
NOT Y=A
&
AND Y= A × B
OR Y= A + B
≥1
Y = A× B = A + B
&
NAND
4/21
8) Programmable Logic Controllers
NOR Y = A + B = A× B
≥1
=1
XOR Y = A× B + A× B
RS Flip flops [Sequential Logic]
S R Yn Yn+1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 X Y=
n +1 R ( S + Yn )
1 1 1 X
Yn SR 00 01 11 10
0 0 0 X 1
1 1 0 X 1 Reset
Y=0
S = 0; R=1 S = 1; R = 0
Set
Y=1
State Diagram of RS-Flip Flop
5/21
8) Programmable Logic Controllers
Example 1: On/Off push button of a motor
Input Connection
Start Push Button
Stop Push Button
Program
Connection
Motor
M
Output
Connections to Input Module
6/21
8) Programmable Logic Controllers
Connections to Output Module
Basic Instruction Set
Ladder Diagram is compiled into Assembly Code (Instruction Set) and then into Machine
Code.
LD, LDI Load (LD)/Inverted Load (LDI) to accumulator
AND, ANI AND/ANI between accumulator and input
OR, ORI OR/ORI between accumulator and input
OUT Stores accumulator to memory
Value remains in accumulator
LD X1
OR Y1
AND X2
AND X3
OUT Y1
OUT Y2
LDI X2
OUT Y3
ANB Operates on last element in the stack and accumulator and stores result in
ORB accumulator
7/21
8) Programmable Logic Controllers
LD X1
OR X2
LD X3
OR X4
ANB
OUT Y1
LDI X2
AND X4
LD X3
AND X5
ORB
OUT Y2
Process Scan of Programmable Logic Controllers
OUTPUT SCAN
INPUT SCAN
PROGRAM SCAN
INPUT INPUT USER OUTPUT OUTPUT
T STATUS PROGRAM STATUS T
E TABLE TABLE E
R R
M M
I I
N N
A A
L L
S S
INPUT OUTPUT
PROGRAM SCAN
SCAN SCAN
Example 2: Water Tank
Simple water tank
• Level sensors, wires.
• If water level is less than LDown, NO contact of LDown is opened
• If water level is less than LUp, NO contact LUp is opened
8/21
8) Programmable Logic Controllers
P1 (Pump) Lup
LDown
Timers and Counters in PLC
• Timers: used to time an event for desire length of time
1. Timer Status Bits
2. Timer Current Values
3. Types of Timers in DL230/ DL240
• Counters: used to count the events
1. Counter Status Bits
2. Counter Current Values
Timers:
1. Timer Status Bits
• Timer status bit will be on when current value is equal or greater than the preset
value i.e. 3 sec.
• When input X0 turn on, timer T1 will start and when timer reaches the preset
value of 3 sec. (K of 30) timer status contact T1 turns on.
• When T1 is ON o/p Y0 turns on.
2. Timer Current Values
• Current value associated with timer is automatically stored in variable memory.
e.g. V1 hold current value of T1.
9/21
8) Programmable Logic Controllers
3. Types of Timers in DL230/ DL240
i. single input timer :
• will time as long as the input is on.
• i/p change from on – off timer is reset to 0.
ii. Accumulating timer
• two inputs required
• start/stop i/p start or stop timer.
• when timer is stops elapsed time is maintained.
• When timer starts again the timing continues from elapsed time
• when reset s turn on the elapsed time is cleared and the timer will start at 0 when
restarted.
Counters:
1. Counter Status Bits
• counter status bit will be on when current value is equal or greater than the preset
value i.e. 10 counts.
• Each time X0 transitions from off to on, the counter increments by one. If X1 is
on counter is reset to 0.
• when counter reaches the preset value of 10 sec. (K of 10) counter status contact
CT3 turns on and o/p Y12 turns on.
10/21
8) Programmable Logic Controllers
2. Counter Current Values
• Current value associated with counter is automatically stored in variable memory.
e.g. V1003 hold current value of CT3.
3. Types of Counters in DL230/ DL240
i. up counters
ii. 2. up/down counters
Example 3: Automation of Product Packaging
• System consists of two conveyer belts, one for feeding apples and one for feeding
packaging boxes.
• Sensors:
• Apple Sense: detects apple
• Box Sense: detects box
11/21
8) Programmable Logic Controllers
• Actuators:
• Apple Convey: Moves the conveyer belt of apples
• Box Convey: Moves the conveyer belt of boxes
Apple Convey
Apple Sense
Box Convey
Box Sense
When apple is not present When apple is present
Opens Closes
Closes Opens
When box is not positioned When box is positioned
Opens Closes
Closes Opens
12/21
8) Programmable Logic Controllers
Grafcet Diagram (Sequential Function Chart/ IEC 848 Standard)
– Graphical technique for writing concurrent control programs.
Basic Elements of Grafcet
Initial step: the first step
Initial Step
Step: basically a state of operation. A state often has an associated action
Step Action
Macrostep: a collection of steps (basically a subroutine)
13/21
8) Programmable Logic Controllers
Transition: causes a shift between steps, acts as a point of coordination
Flowlines: connects steps and transitions (these basically indicate sequence)
Step I
Transitions
Flowlines
Step II
Selection branch: an OR - only one path is followed
Step I
Step II Step III
Simultaneous branch: an AND - both (or more) paths are followed
Step I
Step II Step III
Example 2: Water Tank
14/21
8) Programmable Logic Controllers
Tank filling
do/Pump On
tank filled tank empty
[Lup] [Ldown]
Idle
do/Pump Off
Statechart for Water Tank
Stage Programming for Water Tank
Initial
Step
Tank Filling
1 Action
Pump On
Transition LUp
Idle
2
Pump Off
LDown
Step
Grafcet Diagram Explained
Example 3: Automation of Product Packaging
15/21
8) Programmable Logic Controllers
System OFF
Stop Start
Position New Box
Stop do/Box Convey
Box Positioned [Box Sense]
Apple Counter ≥ 10
& NOT (Stop)
& not (Stop)
Fill Apple
do/Apple Convey;
Apple Count
Statechart for Automation of Product Packaging
1 System OFF
Start
Position New Box
2
Box Convey
Box Sense
Stop & NOT (Stop)
Fill Apple
3
Apple Convey;
Apple Count
Stop
Apple Counter ≥ 10
& NOT (Stop)
Grafcet diagram for Automation of Product Packaging
16/21
8) Programmable Logic Controllers
Stage Programming for Automation of Product Packaging
17/21
8) Programmable Logic Controllers
Example 4: Bottle Filling Plant
Buffer Tank
Valve Control (V)
Level Sensor
bottle_present (BP) bottle_filled (BF)
Motor (M)
Conveyer belt
Conveyer belt is moved by Motor (M), Bottle is filled from a buffer tank by opening
the valve (V). Bottle filled is detected by the level sensor, bottle_filled (BF). Correct
positioning of the bottle is detected by limit switch, bottle_present (BP).
Assume both Normally Open and Normally Closed contacts of the sensors BF and BP
are available.
Process cycle is described as follows
1) Move the conveyer belt until bottle is in correct position.
2) Open valve (V) and fill the bottle until bottle_filled is detected.
3) Move the conveyer belt until next bottle is in position.
4) Repeat from step 2.
Assuming the contacts BF and BP closes when bottle is filled and bottle is positioned
respectively i.e. the contacts BF and BP opens when bottle is not filled and bottle is
not positioned respectively.
Position New Bottle
do/Move Conveyer M ON
Bottle Present (BP) Bottle Filled (BF)
Fill Bottle
do/Open Valve V ON
Statechart for Automation of Product Packaging
18/21
8) Programmable Logic Controllers
Position New Bottle
1
Move Conveyer M ON
BP
Fill Bottle
2
Open Valve V ON
BF
Grafcet diagram for Automation of Product Packaging
Stage Programming for Bottle Filling Plant
19/21
8) Programmable Logic Controllers
Example 5: Elevator System
Shown in the figure is an Elevator System. M1 (For Up Motion)
The elevator is operated by two motors.
M1 for Up Movement LS1 (Down)
M2 for Down Movement
Start Stop
Two Limit Switches, LS1 (for Down Limit)
and LS2 (for Up Limit) are Normally Closed X0 X1
contacts. The contacts open when the hatch Up Down
reaches corresponding position.
X2 X3
Four Controls buttons is also provided.
LS2 (Up)
STOP button is Normally Closed and
START, UP, DOWN buttons are Normally
Open. M2 (For Down Motion)
The required Sequence of Operation are given below
• When START button is pushed, the platform should be in the DOWN Position.
• When STOP button is pushed, the platform is halted at whatever position it occupies
at that time.
• When UP or DOWN push buttons are pushed the platform should move accordingly.
Note the platform should move when push button is pushed and halt when the button
is released.
20/21
8) Programmable Logic Controllers
Figure: Ladder Diagram for Elevator System
• Example 6: Garage Door Controller
The behavior of the garage door controller is as follows,
– There is a single button in the garage, and a single button remote control.
– When the button is pushed the door will move up or down.
– If the button is pushed once while moving, the door will stop, a second push will
start motion again in the opposite direction.
– There are top/bottom limit switches to stop the motion of the door.
– There is a light beam across the bottom of the door. If the beam is cut while the
door is closing the door will stop and reverse.
– There is a garage light that will be on for 5 minutes after the door opens or closes.
21/21