You are on page 1of 57


PLC is a digital electronic device to control machines
and processes.
It uses a programmable memory to store instructions &
Implement functions such as logic, sequencing, timing,
counting, arithmetic.
o It is specifically designed to make programming easy.
o Programming is primarily concerned with implementing
logic & switching operation.
I/Ps & O/Ps are connected to PLC and controller
monitors them according to as per the program stored
in PLC by operator.
History: They are originally designed to replace hard wired
relays & timer logic control systems.

Easy to use
Easy to program.
Much faster than relay operated system

Specific features of PLC:

Rugged & designed to withstand vibration, temperature,
humidity & noise.
Interfacing is inside the controller.
They are easily programmed.
PLC In Control Circuits Architecture
Main components
Control & process all the information.
Contain a clock with frequency between 1 & 8 MHz.
It determine operating speed of PLC.
Also provide timing & synchronization for all elements.

Memory: There are many types of memory in PLC, like:

Temporary buffer stores for Input/Output channels.
Input/Output Interfaces:
They provide isolation & signal conditioning.
Input channel: Digital signal generally compatible with
microprocessor of PLC is in range from 5V, 24 V, 110V to
240 V.
Its general form is as shown in fig.
Output channel:
Sinking and sourcing operations
When choosing the type of input or output module for your PLC
system it is very important to have a solid understanding of
sinking and sourcing concepts.
Only applicable to dc load
It refer to electrical configurations of the circuit in the module &
field input devices.
When a device provides current when it is ON it is said tobe
sourcing current.
When a device receives current when it is ON it is said to
besinking current.
There are both sinking & sourcing field devices as well as
sinking & sourcing input module.
But its a common practice to use input module in
sinking current mode.
Sinking and sourcing operations
Inputting Programs
Writing program
Program Step
Forms of PLC
Rack mounted/Modular
Single PLC
Box/Integrated/Compact PLC
Input/output processing
PLC is continuously running through its program and
updating it as a result of the input signals, each such loop is
called a cycle.

Continuous updating: The CPU scanning the input

channels as they occur in the program instructions.
Each input is examined individually (delay time 3 ms).
The output is latched so that they retain their status
until the next update
Mass input/ output copying:
It works in the following
1. Scan all the inputs and
copy into RAM
2. Fetch and decode and
execute all program
instruction in sequence,
copying output instruction
to RAM
3. Once the program is
executed, the CPU performs
diagnostics and
communication tasks
4. update all outputs Repeat
the sequence
Input/ Output address
The inputs and outputs are identified by their addresses.
the notation used depends on the PLC manufacturer.
For small PLC, it is just a number preceded by a letter to
indicate whether it is an input or an output
With large PLCs having several racks of input and output
channels and a number of modules in each rack, the rack
and modules are numbered and so an input or output is
identified by its rack number followed by the number of the
module in that rack and then a number to show its terminal
in the module.
E.g.The Allen-Bradley PLC-5 has I: 012/03 to indicate an
input in rack 01 at module 2 and terminal 03
Ladder programming
The form of programming commonly use with PLC is ladder programming.
Each program task is specified as though a rung of a ladder.
Thus a rung could specify that the state of switches A and B be examined and if both
A and B are closed then a solenoid, the output is energized.
Sequence followed by PLC when carrying out a
program is
Ladder diagram
The ladder diagram consists of two vertical
lines representing the power rails. Circuits
(rung) are connected as horizontal lines.
Ladder Symbol
Example of a ladder diagram
a) Switch controlling a solenoid

The output from the PLC is to energize a solenoid

when a normally open start switch connected to the
input is activated by being closed This might be a
solenoid valve which opens to allow water to enter
a vessel.
Example of a ladder diagram
b) Temperature control system

The input goes from low to high when the temperature sensor
reaches the set temperature. The output is then to go from ON
to OFF
Logic Functions
The logic Functions can be obtained by
combinations of switches.
The Figures shows how ladder programs can be
written for such combination
Logic Functions
Example 0 0 0 0
a) Switches controlling a solenoid
0 0 1 0
Consider a situation where a 0 1 0 0
normally open switch A 0 1 1 0
must be activated and 1 0 0 0
either of two other, normally 1 0 1 1
open switches B and C must
1 1 0 1
be activated for a coil to be
energized. 1 1 1 1
Truth table
b) Shop door system

Truth table

Shop open switch Customer Solenoid output

ng sensor
off off off
off on off
on off off
on on on
Instruction List
Each horizontal rung on the ladder represents a line in the
program and the entire ladder gives the complete program
in the ladder language.
Using a graphic interface, a programmer can build his
program, then translate these symbols into machine
language that can be stored in the PLC memory.
Alternatively, the ladder program can be translated into
an instruction list and entered into the programming panel
or computer.
Instruction lists consist of a series of instruction with each
instruction being on a separate line.
An instruction consists of an operator followed by one or
more operand
e.g. LD A (*load input A*)
The mnemonics codes used by different PLC manufactures
differ but an international standard (IEC 1131-3) has been
proposed and is widely used.
Table below shows core mnemonics. For the rest of the
instructions, Mitsubishi mnemonics will be used
Instruction List and Logic Function
Figures show how individual rungs on a ladder are entered using the
Mitsubishi mnemonics where logic functions are involved in a) AND
b) OR c) NOR d) NAND logics
When two parallel arms are involved, Mitsubishi treats the
situation by using an ORB instruction to indicate OR
together parallel branches as shown in Fig. Line 3 describe a
new line since it starts with LD/LDI instruction

Fig. XOR
Latching and internal relays
The term latching is used for the circuit that able to hold the output
energized even though the input which energizing it ceases. So the
output remember its last state.

Fig. A latch circuit

Latching: Examples
It is required for the PLC to control a motor so that when the
start signal button is momentarily pressed the motor starts
and when the stop button is pressed, the motor switches OFF

Fig. Stop system

Internal relays
The term internal, auxiliary relay or marker is used for what
can be considered as internal relay in PLC.
It behaves like relays with their associated contacts, but in reality
are not actual relays but simulation by the software of the PLC.
Internal can be very useful aids in the implementation of
switching sequences.
They are often used when there are programs with multiple input
Some have battery back up so that they can be used in circuits to
ensure a safe shut down of plant in event of a power failure.
Internal relays (Example)

An output controlled by two Starting of multiple

input outputs
Use of internal relay to reset a latch contact
Battery backed Internal Relay

In many control tasks there is a need to control time. For example, a
motor or a pump might need to be controlled to operate for a
particular interval of time, or perhaps be switched on after some
time interval. PLCs thus have timers as built-in devices.
Timers count fractions of seconds or seconds using the internal CPU
clock. considered.
A common approach is to consider timers to behave like relays with
coils which when energized result in the closure or opening of
contacts after some preset time.
The timer is thus treated as an output for a rung with control being
exercised over pairs of contacts elsewhere
Treatment of timer

Fig.a) Treatment of timer as an

output for a rung with control being
exercised over pairs of contacts

Fig.b) Treatment of timer as a

delay block which when inserted in
a rung delays signals in that rung
reaching the output
Classification of timer
On delay timer (TON)(T0):

*Generally TON timers are used in PLCs

Sequencing by timers

When the input In 1 is on, the output Out 1 is switched on.

Sequenced outputs
Cascaded timers
Timers can be linked together, the term cascaded is used, to
give longer delay times than are possible with just one timer.

Timer 1 with a delay time of 999 s. This timer is started when there is a
On-off cyclic timer
on-delay timers can be When there is an input to In 1 and its co
used to produce an on-
off cycle timer.
The timer is designed
to switch on an output
for 5 s, then off for 5 s,
then on for 5 s, then off
for 5 s, and so on.
Off-delay timers
when there is a momentary input to In
Counters are provided as built-in elements in PLCs and allow
the number of occurrences of input signals to be counted.
This might be where items have to be counted as they pass
along a conveyor belt, or the number of revolutions of a shaft,
or perhaps the number of people passing through a door.
Forms of counter:
o down-counters: Down-counters countdown from the preset value to
zero, i.e. events are subtracted from the set value. When the counter
reaches the zero value, its contacts change state
o up-counters: Up-counters count from zero up to the preset value,
i.e. events are added until the number reaches the preset value.
Forms of representation of counters.
Different PLC manufacturers deal with counters in slightly different ways.
Some count down (CTD), or up (CTU), and reset and treat the counter as
though it is a relay coil and so a rung output.
In this way counters can be considered to consist of two basic elements: one
relay coil to count input pulses and one to reset the counter, the associated
contacts of the counter being used in other rungs.

(b) the IEC 1131-3 representation, CD is count

down input, LD is for loading the input, PV is for
(a) RST is reset. the preset value, CV the current count value, CU
is count up input, and R is for the reset input.
Basic counter programming

When there is a pulse input to In 1, the counter is reset.

Consider the problem of the control of a machine which is required to direct 6
tins along one path for packaging in a box and then 12 tins along another path
for packaging in another box
A deflector plate might be controlled by a photocell sensor which gives an
output every time a tin passes it.
Thus the number of pulses from the sensor has to be counted and used to
control the deflector.
When there is a pulse input to X400, both the counters are reset

X401: input which is counted

,might be an input from a photocell
sensor which detects the presence
of tins passing along the conveyor.
Y430:This might be a solenoid
which is used to activate a deflector
to deflect items into one box or
Shift registers
The shift register is a number of internal relays
1 2 3 4 5 6 7 8
grouped together which allow stored bits to be
(a) 8 bit shift register
shifted from one relay to another.
Registers can be used for storing data that 1 0 1 1 0 0 1 0
originate from input sources other than just
(b)Bit stored in shift register.
simple, single on-off devices such as switches.
With the shift register it is possible to shift Input
1 0 1 1 0 0 1 0
stored bits. Shift registers require three inputs (c) Input Bit given to shift
bit 1 register.
one to load data into the first location of the
register(OUT) , one as the command to shift
data along by one location(SFT) and one to
1 1 0 1 1 0 0 1
reset or clear the register of data(RST). Output
(d) Last bit out of shift register.
Therefore, if we have eight internal relays in bit 0
the register we can store eight 0/1 states and
each relay might store an on-off signal such
that the state of the register at some instant.
Shift registers

The grouping together of internal relays to form a shift register is done automatically

by a PLC when the shift register function is selected.

With the Mitsubishi PLC, this is done by using the programming code SFT(shift) against

the internal relay number that is to be the first in the register array. This then causes a

block of relays, starting from that initial number, to be reserved for the shift register.

e.g. Consider a 4-bit shift register and how it can be represented in a ladder program

The input In 3 is used to reset the shift register, i.e. put all the values at 0.

The input In 1 is used to input to the first internal relay in the register.

The input In 2 is used to shift the states of the internal relays along by one.

Each of the internal relays in the register, i.e. IR 1, IR 2, IR 3 and IR 4, is connected to

an output, these being Out 1, Out 2, Out 3 and Out 4.

Shift registers
Master control relay
When large numbers of outputs have to be controlled, it is
sometimes necessary for whole sections of ladder diagrams to be
turned on or off when certain criteria are realized. This could be
achieved by including the contacts of the same internal relay in
each of the rungs so that its operation affects all of them.
An alternative is to use a master control relay.
To program an internal relay M100 to act as master control relay
contacts the program instruction is: MC M100
To program the resetting of that relay, the program instruction is:
MCR M100
Master control relay
With no input to input 1,
A function often provided with PLCs is the conditional jump.
Such a facility enables programs to be designed such that if certain
conditions are met then certain events occur, if they are not met then
other events occur.
for example, we might need to design a system so that if the
temperature is above 60oC a fan is switched on, and if below that
temperature no action occurs.
Thus, if the appropriate conditions are met, this function enables part of
a ladder program to be jumped over.
The jump instruction is denoted by CJP (conditional jump) and the place
to which the jump occurs is denoted by EJP (end of jump).
We can describe this as:
IF (some condition occurs) THEN
perform some instructions
perform some other instructions.
When there is an input to In 1,
Data Handling
The operations that may be carried out with a PLC on data words include:
Moving data
Comparison of magnitude of data
Arithmetic operations
Conversion between number system
Data instructions require memory addresses, so data registers are used to stored binary
words (8 or 16 bits) and is given an address such as D0, D1, D2
Each instruction has to specify the form of the operation, the source of the data used in
terms of its data register and the destination data register of the data
Data Movement Data Comparison

Temperature alarm
example: Code Conversion