Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Programmable Logic Controllers

Nilesh J. Vasa
References
• 1) Programmable Logic Controllers:
Programming methods and Applications, John
R. Hackworth, Frederick D. Hackworth Jr.,
Pearson Education, New Delhi, 2004
• 2) Exploring Programmable Logic Controllers
with Applications, Pradeep Kumar Srivastava,
BPB Publications, New Delhi, 2004
Internal • A programmable logic
Memory controller (PLC) is a special
Power
CPU form of microprocessor-
Supply
User based controller that uses a
Memory programmable memory to
store instructions and to
implement functions such as
logic, sequencing, timing,
counting and arithmetic in
Analog Digital Analog Digital order to control machines
Input Input Output Output and processes.
Module Module Module Module • Instead of hardwiring each
control circuit for each
Processor, Controller, or CPU control situation we can use
It consists of following blocks the same basic system for
- Arithmetic Logic Unit (ALU)
different situations
- Program memory and Internal memory
- Internal timers and counters • By changing the instructions
- Flags or temporary registers in the program
PLC Hardware
• Typically a PLC system has five basic components
– Processor unit or Central Processing Unit (CPU)
– Power supply (5/24 V DC)
– Programming device
– Memory unit
– Input and output sections

• PLC manufacturers
– Siemens, Mitsubishi, Toshiba, Allen-Bradley,
Sprecher+Schuh, Telemecanique
PLC Programming
• Use of ladder diagrams
• The ladder diagram consists of two vertical
lines representing the power rails
• Circuits are connected as horizontal lines, i.e.
the rungs of the ladder, between the two
verticals
AND PB1 • PB2

OR
PB1 + PB2

AND-OR (PB1 • PB3)+(PB2 • PB4)

OR-AND (PB1+PB2) • (PB3+PB4)


Latch
Occasionally, it is necessary to have a relay “latch” ON so that if the device that activated the
relay is switched OFF, the relay remains ON.
For example, the pushbutton that switch a machine on and off.
This type of contact configuration is knows as a sealing contact, seal-in contact, or latching
contact.
4) The circuit is de-energized by
1) When we press the START switch S1, pressing the STOP switch S2.
the current flows through S1, S2 and
energizes CR1.

2) As soon as CR1 energizes, the N/O 3) When the relay contact closes, we no
CR1 contact in parallel with S1 closes. longer need switch S1 to maintain a path
for current flow through the rung because
it is provided by the N/O CR1 contact and
N/C pushbutton S2. The N/O CR1 contact
“seals” or “latches” the circuit ON.

Important safety feature: when the power fail when the machine is on, the latch rung will de-energize.
However, when the power is restored, the machine will not automatically restart. This must be manually
restarted by pressing S1.
Single cycle circuit
In some applications, the machine must perform only one cycle and then stop, even if
the operator is still depressing the run switches.
Therefore, circuitry is usually needed to assure that once the machine has completed
one cycle of operation, it stops and waits for the RUN switch(es) to be released and
then pressed again.

In order for the circuitry to be able to determine where the machine is in its cycle, a
cam-operated limit switch must be installed on the machine.

The cam is aligned on the shaft


so that when the machine is at
the stopping point in its cycle
(i.e. between cycles), the switch
roller in the cam detent.
When the machine is between
cycles, the N/O terminal is open
and the N/C terminal is
LS1A connected to C. While the
LS1B machine is cycling, the N/O is
connected to C and the N/C is
open.
Single cycle circuit: Continued
Initial state: Assuming that the machine is mechanically positioned so that the cam switch
is sitting in the cam detent (N/O contact (LS1A) is open and N/C contact (LS1B) is closed.
Start switch S1 has not been pressed but the rail has been energized.

CR1: OFF
(as S1: OPEN)

2) CR3: CR2: OFF


CLOSED (as CR1 is OFF, LS1A:
(as CR3 coil is OPEN)
energized)

CR1: Operates CAM


CR2: Operates machine

1) CR3: ENERGIZED
(as LS1B: CLOSE)

Machine is in stop condition but ready to cycle.


Single cycle circuit: Continued
Start switch S1 has been pressed.

As the m/c cycle begins,


LS1A: CLOSES, and LS1B: OPENS
LS1A seals CR2: ON

CR1: ENERGIZE
(as S1: CLOSE)

CR2ENERGIZE
(as CR1: CLOSES, CR3: already CLOSE)
As a result the machine cycle begins

CR3: DE-ENERGIZE
(as LS1B: OPENS)

Machine continues in its cycle since CR2 is still ON.


Single cycle circuit: Continued
If the operator does release the SRART switch before the machine finishes its cycle.

CR1: DE-ENERGIZE
(as S1: OPEN)

CR2 Still ENERGIZE


(CR1: OPENs, CR3: OPEN)
But LS1A: CLOSE

CR3: DE-ENERGIZE
(as LS1B: OPEN)

Eventually, the m/c finishes its cycle and the cam switch rides into the cam detent.
Single cycle circuit: Continued
If the operator does not release the SRART switch before the machine finishes its cycle.

CR1: remains ENERGIZE


(as S1: CLOSE)

CR2 Still DE-ENERGIZE


(CR1: CLOSE, but CR3: OPEN
and LS1A: OPEN

Eventually, the m/c finishes its cycle and the cam switch rides into the cam detent.

CR2: DE-ENERGIZE: stopping the machine. Then, when the operator releases S1, CR1
turns OFF, and CR3 turns ON.
The circuit is now back in its original state and ready for another cycle.
Single cycle circuit: Continued

There are some speed limitations to this circuit.

1) If the machine cycles so quickly that the cam switch “flies” over the detent in the
cam. The machine will cycle endlessly.
2) If the machine has high inertia, it is possible that it may “coast” through the stop
position. In this case, some type of electrically actuated braking system must be
added that will quickly stop the machine. The brakes could be actuated by a N/C
contact on CR2.
• In a chemical plant a tank will be
Examples filled with two chemicals, mixed
and then drained. When the start
button is pressed at input I0, the
program starts pump 1 controlled
by output O0.
• Pump 1 runs for 5 s, filling the
tank with first chemical, then
shuts off.
• The program then starts pump1,
controlled by output O1. Pump
runs for 3 s filling the tank with
the second chemical. Then shuts
off.
• The program starts the mixer
motor, connected to output O2
and mixes the two chemicals for
60 s.
• The program then opens the
drain valve controlled by output
O3 and starts pump 3 controlled
by the output O4.
• Pump 3 shuts off after 8 s and the
process stops.
• A manual stop switch is also
provided at the input I1.
• In the ladder diagram, I0 is a pushbutton
switch to start the process and I1 is a push
button switch to stop the process at any
instant. O0, O1, O2 and O4 are the four
outputs to run the pump1, pump2, drain valve
and pump3, respectively. Four timers T1, T2,
T3 and T4 are suitably chosen to have time
base 100 ms each. The ladder diagram is
written to fulfill the need of chemical process.
I0 I1 CR2 CR1
1 When I0: CLOSE
CR1: ENERGIZE
CR1
TDR3,
CR1 ON 5s
2 TDR: ON-Delay: 5S
CR1 CR3 O0
3 ( ) Pump 1 runs for 5s
TDR4,
CR1 CR3 ON 3s
4 TDR: ON-Delay: 3S

CR1 CR3 CR4 O1


5 ( ) Pump 2 runs for 3s
TDR5,
CR1 CR4 ON 60s
6 TDR: ON-Delay: 60s
CR1 CR4 CR5 O2
7 ( ) Mixer motor runs for 60s

CR1 CR5 O4
8 ( ) Drain valve opens
TDR6,
CR1 CR5 ON 8s
9 TDR: ON-Delay: 8s

CR1 CR5 CR6 O5


10 ( ) Pump 3 runs for 8s

CR1 CR6 CR2


CR2: ENERGIZES
11 As CR6: CLOSES
CR1: DE-ENERGIZES
The process stops
Counter
• A counter allows the PLC to increment or decrement a
number each time the control logic for the rung switches from
false to true
• Two control logic lines:
– One that causes the counter to count each time the count
control becomes true
– One that causes the counter to reset when the reset
control line is true
IN1 CTR1
ACTUAL ( )

IN2
RESET

In some cases ACTUAL value is set to PRESET value (rather than reset it to zero)
Counter
• Two separate rung counters: these have an advantage in that
the reset rung can be located anywhere in the program does
not need to be located immediately following the count rung
1) IN1 (rung 1) causes the
counter C1 to increment (or
decrement, if it is a down
counter) IN1 C1 (CTR)
2) IN2 (rung 2) causes the ( )
counter C1 to reset to zero
(or reset to the preset value IN2 C1 (RESET)
if it is a down counter)
( )
C1 OUT1 (OUT)
( )

C1 is a contact of counter C1. It is


energized when counter C1 reaches
OUT1 will be energized,
its preset value
(If it is a down counter, it will
energize when C1 reaches a count
of zero.)
Bi-directional Counter
• Can be used to maintain a running tally

IN1 C2 (UPCTR)
( )

IN2 C2(DOWNCTR)
( )
IN3 C2 (RESET)
( )

A bi-directional counter can be incremented when a part enters and decremented


when a part exits
Sequencer
• Some machine control applications require that a
particular sequence of events occur and, with each
step of the controller, a different operation be
performed
• The programming element for this type of control is
called a sequencer
• For example, the timer in a washing machine is a
mechanical sequencer and the machine performs
different operations (fill, wash, drain, spin) in a
predetermined sequence
• Although a washing m/c timer is a timed sequencer,
sequences in a PLC are not necessarily timed.
Sequencer
• Unlike counters, sequencers have contacts that actuate at any specified
count of the sequence
• For example, if we have an up-counting sequencer SEQ1 with a preset
value of 10 and we would like to have a rung switch ON when the
sequencer reaches a count of 8. In this case,
• We would simple put a N/O contact of SEQ1 = 8 (or SEQ1:8) in the rung.
For this contact, when the sequencer is at a count of 8, the contact will be
ON. The contact will be OFF for all other values of sequencer SEQ1.

IN1
N/O contact IN1 advances SEQ1
SEQ1 ( )

N/O contact IN2 resets IN2 SEQ1 (RESET)


SEQ1 ( )
SEQ1:8 OUT1 (OUT)
In rung 3, output OUT1
( )
energizes when SEQ1 is
in state 8
Sequencer
• It is possible to use as many contacts of a sequencer as desired of either
polarity N/O or N.C and of any sequence value.
• For example, SEQ1 should switch on an output OUT1 whenever the
sequencer is in count 3 or 8 of its sequence.

IN1
SEQ1
( )

IN2 SEQ1 (RESET)


( )
SEQ1:3 OUT1 (OUT)
( )
SEQ1:8
Timers
• A timer is a special counter ladder function that allows the
PLC to perform timing operations based on a precise internal
clock, generally 0.1 or 0.01 s per clock pulse.
• Retentive and non-retentive timers
• Non-retentive timer: when this type of timer is stopped, it is
automatically reset
• Retentive timer: this type of timer may be started, stopped,
and then restarted without resetting

IN1 IN1 TIM1


TIM1
( ) ACTUAL ( )
ACTUAL
IN2
PRESET
RESET

Non-retentive timer
Retentive timer
Timers
• When the control line becomes true (IN1 closes), the timer
ACTUAL value is incremented each 0.1 or 0.01 s. When the
actual value is equal to the PRESET value, the coil associated
with the timer (in this case TIM1) is energized and the ACTUAL
value incrementing ceases.
• The PRESET value must be set so that the timer counter
ACTUAL value will increment from zero to the required using
a0.1 or 0.01 s rate timer.
• For instance, suppose a timer of 5.0 s is required using a 0.1 s
rate timer. The PRESET value would need to be 50.

IN1
TIM1
( )
ACTUAL
PRESET
Example
• Design a ladder network that will provide a delayed-on
sequence TIM1, TIM2, and TIM3. The sequence will be
initiated by IN1. In operation, when IN1 is activated, TIM1 will
switch ON 3 s later. Then 1 s later TIM2 will switch ON,
followed by TIM3 2.5 s afterwards. All signals will be reset
when IN1 is switched OFF.

IN1 IN1 TIM1 Preset


TIM1
( )
Pr = 30 TIM2 Preset
TIM1
TIM1
TIM2
( )
Pr = 10 TIM2 TIM3 Preset

TIM2
TIM3
( )
Pr = 25 TIM3
The sequence is initiated by energizing IN1, which starts timer TIM1.

3 s later, the TIM1 coil activates, which starts TIM2 timing.

1s later, the TIM2 coil activates, which starts TIM3 timing.

Finally, 2.5 s later, the TIM3 coil activates.

Then IN1 is switched OFF, all timers in the sequence reset and the
network is immediately ready to start again.

IN1 IN1 TIM1 Preset


TIM1
( )
Pr = 30 TIM2 Preset
TIM1
TIM1
TIM2
( )
Pr = 10 TIM2 TIM3 Preset

TIM2
TIM3
( )
Pr = 25 TIM3
Example
• A machine’s electrically operated automatic
oiler is connected to dispense oil when OUT1
of the PLC is ON. It has been determined that,
because it is over-oiling the machine, the
operator wishes to reduce the amount of oil
dispensed by periodically cycling it ON and
OFF. Design a PLC program that will operated
the oiler connected to output OUT1 when
input IN1 is ON. When ION1 is ON, the output
OUT1 is to cycle continuously ON for 0.5 s and
OFF for 1.0 s.
Solution
• We will need two non-retentive timers: 0.5 s and 1.s
• The timers will be connected such that the first enables the second, and the second disables
the first.
• Flasher operation:
– In rung 1 of this network, IN1 activates TIM1.
– In rung 2: after TIM1 times out (0.5 s after IN1 is switched ON), TIM2 is started timing.
– Then 1 s later, when TIM2 times out, the N/C TIM2 contact in rung 1 opens which resets
and restarts TIM1.
– Since TIM1 is restarted, this will consequently reset TIM2 in rung 2.
– Therefore, when IN1 is ON TIM1 will continuously cycle OFF for 0.5 s and ON for 1.0 s.
– Rung 3 of our program is enabled by IN1. As long as IN1 is ON, OUT1 is simply the
inverse of TIM1.
– Hence, OUT1 will be ON for 0.5 s and OFF for 1.0 s.

IN1 TIM2 TIM1

TIM1 Pr=5
TIM2

IN1 TIM1 Pr=10


OUT1
( )
Timed One Shot
• It is also possible to construct a timed one shot in which a
contact may be triggered by a contact closure and the contact
will remain ON for some time period.

When IN1 is activated,


TIM1 begins timing and When TIM1 times out 3.5 s
OUT1 switches ON TIM1 later, the N/C TIM1 contact
IN1 TIM1
opens which switches OFF
the network and opens the
OUT1
sealing contact OUT1
The N/O OUT1
Pr=35
switches contact
OUT1
seals IN1 and ( )
keeps the network
active

Notice that the network has two coils: TIM1 and OUT1, in parallel.
PLC: Location in the control
architecture
Enterprise Network
Engineer Operator Supervisor
gateway
station station Station

Control Bus
(e.g. Ethernet)

PLC
large

COM1

COM 2
COM1 Control Station
COM 2
COM1

CPU
PLC
CPU
CPU

I/O
with Field Bus gateway
PLCs

I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O

direct I/O
Field Bus Field Bus

COM
COM

COM

COM
CPU

CPU

CPU
COM
I/O
I/O
I/O
I/O

I/O
I/O
I/O
directly connected
I/O
Field Stations FB
gateway Field Devices
small PLC
data concentrators,
not programmable,
but configurable
Sensor Bus (e.g. ASI)

You might also like