Unit IV Programmable Logic Controller
Unit IV Programmable Logic Controller
UNIT IV
PROGRAMMABLE LOGIC CONTROLLER
INTRODUCTION TO PLC
A programmable Logic Controller (PLC) is defined as a digital electronic device that uses a
programmable memory to store instructions and to implement functions such as logic, sequencing,
timing, counting and arithmetic in order to control machines and processes.
BASICSTRUCTURE
The fig. shows the basic internal structure of a PLC. It consists essentially of a central processing unit
(CPU), memory and input/output (I/0) circuitry. The CPU controls and processes all the operations
within the PLC. It is supplied with a clock of frequency typically between 1 and 8 MHz. This frequency
determines the operating speed of the PLC and provides the timing and synchronization for all
elements in the system. A bus system carries information and data to and from the CPU, memory
and input/output units. There are several memory elements: a system ROM to give permanent
storage for the operating system and fixed data; RAM for the user's program, and temporary buffer
storage for I/0 channels. The programs in RAM can be changed by the user. However, to prevent the
loss of these programs during power failure, a battery is likely to be used in the PLC to hold the RAM
contents for a period of time.
3
ME 8791 Mechatronics Mechanical Engineering
After a program has been developed in RAM, it may be loaded into an EPROM memory chip and so
made permanent. The I/0 unit provides the interface between the system and the outside world.
Programs are entered into the system through input devices like key pad or sometimes through
Personal Computer (PC) which is loaded with an appropriate software package. The I/0 channels
have signal conditioning and isolation units, so that sensors and actuators can be generally directly
connected to them without the need for any other circuitry. The figure shows the basic form of an
input channel. Common input voltages are 5V and 24VCommon output voltages are
24V and 240V.
4
ME 8791 Mechatronics Mechanical Engineering
1) RelayType
Withrelaytype,thesignalfromthePLCoutputisusedtooperatearelayandsoisable to switch currents of the
order of few amperes in an external circuit. The relay isolates the PLC from the external circuit and
can be used for both d.c and a.c switching Relays are relatively slow to operate.
2) Transistor type
The transistor type of output (fig) uses a transistor to switch current through the external circuit. This
provides a faster switching action. Optoisolators are used with transistor switches to provide isolation
between the external circuit and the PLC. The transistor output is only for D.C. switching.
5
ME 8791 Mechatronics Mechanical Engineering
3) Triactype:
Triac outputs can be used to control external loads which are connected to the a.c. power supply.
Opto isolators are again used to provide isolation.
There are two methods that can be used for I/O processing:
1. Continuous updating
In this method, the CPU scans input channels as they occurring the program instructions. Each input
is examined individually and its effect on the program determined. there involves a time delay,
typically about 3 ms, when each input is scanned in order to ensure that only valid input signals are
read by the microprocessor. This delay enable CPU to avoid counting an input signal twice, A
number of inputs may have to be scanned, each with a 3ms delay, before the program has the
instruction for a logic operation to be executed and an output to occur. The outputs are latched so
that they retain their status until the next update. The 3ms built-in delay for each input is, for
ensuring the signals read by the CPU is the valid one. or more frequently, if there is contact bounce at
a switch.
6
ME 8791 Mechatronics Mechanical Engineering
PROGRAMMING
Ladder diagram
PLC’sareprogrammedusingladderdiagramtechniques.Aspecialstandardschematic representation of
the physical components arrangement (hardware) and its way of connections made between them is
called as ladder diagram. These are line diagram the represent both the system hardware and the
processcontroller.
A ladder diagram consists of two vertical lines called power power rails are connected along with I/O
devices and other components as horizontal lines between the two vertical lines known as rungs.
3. A ladder diagram must read from left to right and from top to bottom. whenthe scanning of first
rung is completed then the second rung starts from left toright.
4. Each rung must start with an input and must end with anoutput.
5. Each rung must have more than one input but only oneoutput.
6. The input must always located at the rung left and the output at the right end of the rung.
7. Electrical devices are shown in their normalcondition.
Ladder diagram can be entering from a monitor screen by using mouse. When entered, they
translated by the PLC into machine language for microprocessor to understand it. The nature of input
determines whether the output is to be energized or not.
The Ladder programming is one of the basic forms of programming commonly used with
PLC’s. In this type of programming, each program task being specified as though a rung of ladder.
Circuits are connected between these two vertical lines as horizontal lines, i.e. the rungs of the
ladder. Fig. shows the basic symbols that are used in the ladder diagram.
7
ME 8791 Mechatronics Mechanical Engineering
Ladder Symbols
Precede outputs and depending on, the different PLC manufacturer, different notations are used. For
example, the Mitsubishi F series of PLC’s precedes inputs elements by an X and output elements by
a Y and uses the following numbers: Numbering schemes are followed for inputs and outputs and
depending on, the different PLC manufacturer, different notations are used. For example, the
Mitsubishi F series of PLC’s precedes inputs elements by an X and output elements by a Y and uses
the following numbers:
Inputs X300 - 307,310 -313
8
ME 8791 Mechatronics Mechanical Engineering
X600 - 607,610 - 61 3
Y 430 - 437
(1 6 possible outputs)
To illustrate the drawing of a ladder diagram, consider a situation where the output from the PLC is to
energies a solenoid when a normally open start switch connected to the input is activated by being
closed (Fig. (a)). the program required is shown in Fig.(b).
Starting with the input, we have the normally open symbol 11. This might have an input addressX400.
The line terminates withthe output, the solenoid, with the symbol
0. This might have the output address Y430. To indicate the end of the program the end rung is
marked. When the switch is closed the solenoid is activated. This might, for example, be a solenoid
valve which opens to allow water to enter avessel.
LOGIC FUNCTIONS
Logic functions may be obtained through various combinations of switches. Also it is explained how
one can write ladder program using such combinations.
9
ME 8791 Mechatronics Mechanical Engineering
1. And function
2. OR function
Consider a situation shown in Fig.
If either one of the switch A or B is closed, then the lamp will be lit. If both switches are opened
simultaneously, then lamp will be put off. This situation Corresponds to an OR system. The ladder
diagram representing the OR function is shown in fig.(b) The switches A and B are represented as
output.
3. Nor function
Consider a situation show in Fig. (a) When neither A nor B have an input (i.e., neither switch A nor
switch B is opened) the lamp will be lit. When there is input to A or B (i.e., if switch A or B is opened)
the lamp will be put off. This situation corresponds to a NOR system. The ladder diagram
representing NOR function is shown in Fig. (b) Switch A and B are represented as input 1 and input
10
ME 8791 Mechatronics Mechanical Engineering
2; and lamp is represented as output. In this case the switches A and B are normally closed. When
input occurs, the corresponding switch is opened. There will be output if neither of the input occurs.
There will not be output if any of the input occurs.
4. NAND Function
Consider a situation show in Fig. (a)
The lamp will not be lit, when both A and B have input simultaneously (i.e., when both are opened
simultaneously the lamp will be lit if both inputs did not occur simultaneously (i.e., when both are not
opened simultaneously). The ladder diagram is shown in Fig. (b)
11
ME 8791 Mechatronics Mechanical Engineering
5. EXCLUSIVE-OR (XOR)function
Consider a situation shown in Fig. (a) In this system, there will be output (i.e., the lamp will be lit) if
any one of the input occurs. There will not be output if both inputs occur or if both do not occur. The
ladder diagram is shown in Fig (b) Note that, it is represented, each input by two sets of contacts, one
normally open and one normally closed.
LATCHING
There are often situation where it is necessary to hold a coil energized, even when the
input which energized it ceases. The term latch circuit is used for the circuit used to carry out such
and operation. It is a self-maintaining circuit in that, after being energizedher input is received. It
remembers its last state.
An example of a latch circuit is shown in Fig (a) when input 1 is energized and closes,
there is an output. However, when there is an output, a set of contacts associated with the output is
energized and closes. These contact OR the input 1 contacts. Thus, even if input 1 contact open, the
circuit will still maintain the output energized. The only way to release the output is by operating the
12
ME 8791 Mechatronics Mechanical Engineering
normally closed contact input 2.As an example of the use of a latching circuit, consider the
requirement for a PLC to control a motor so that when the start signal button is momentarily pressed
the motor starts and when the stop switch is used the motor switches off, signal lamps indicating
when the motor is off and when on. Figure shows a possible program. With no inputs, the signal lamp
for the motor indicates that it is off.
The motor contacts which are normally closed have the off lamp on. When the start button is pressed,
the normally open contacts are closed and the motor switched on. This is latched on by the motors
contact in parallel with the start contacts. Also, other motor contacts which are normally closed opens
and the off lamp goes off and motor contacts which are normally open closes and the on lamp goes
on. The motor is stopped by the stop switch which opens the previously closed contacts.
SEQUENCING
There are often control situations where sequences of outputs are required, with the switch from one
output to another being controlled by sensors.
13
ME 8791 Mechatronics Mechanical Engineering
Consider the requirement for a ladder program for a pneumatic system (Fig) with double solenoid
valves controlling two double-acting cylinders A and B if limitswitches a-, a+, b-, b+ are used to detect
the limits of the piston rod movements in the cylinders and the cylinder activation sequence A+, B+,
A-, B- is required. Fig. shows a possible program. A start switch input has been included in the first
rung. Thus cylinder extension for A, i.e., the solenoid A+ energized, only occurs when the start switch
is closed and the b- switch is closed, this switch indicating that the B cylinder is retracted. When
cylinder A is extended, the switch a+, which indicates the extension of A, is activated. This then
leads to an output to solenoid B+ which results in B extending. This closes the switch indicating the
extension of B, i.e. the b+ switch, and leads to the output to solenoid A-. and the retraction of cylinder
A. This retraction closes limit switch a-and so gives the output to solenoid B- which results in B
retracting. This concludes the program cycle and leads to the first rung again, which await the closure
of the start switch before being repeated.
14
ME 8791 Mechatronics Mechanical Engineering
MNEMONICS
Each horizontal rug on the ladder in a ladder program represents a line in the program and
the entire ladder gives the complete program in 'ladder language'. The programmer can enter the
program into the PLC using a keyboard with the graphic symbols for the ladder elements, or using a
computer screen and a mouse to select symbols, and the program panel or computer then translates
these symbols into machine language that can be stored in the PLC memory.
There is an alternative way of entering a program and that is to translate the ladder program
into mnemonics, each code corresponding to a ladder element, and then enter these into the
programming panel or computer. These are then translated into machine language. The mnemonics
used by different PLC manufacturers differ.
15
ME 8791 Mechatronics Mechanical Engineering
The following examples show how individual rungs on a ladder are entered.
An AND System
An OR System
An NAND System
16
ME 8791 Mechatronics Mechanical Engineering
An NOR System
An XOR System
TIMERS
When timer circuits are activated, they result in closing or opening of input contacts after
some preset time. Fig. shows part of a program involving a delay-on timer. When input occurs, the
timer is activated, and after some preset time, the contacts associated with timers close and output
occurs. When we want to introduce larger time delays, it may not be possible with one timer circuit,
hence we may cascade more timers as shown in Fig.
17
ME 8791 Mechatronics Mechanical Engineering
Normally PLC’s are provided with delay-on timer. The diagram shown in Fig. Explains how a
delay-off timer can be devised. When the input contacts are momentarily closed, the output is
energized and the timer is activated. The outputs contacts and latch the input and keep the output on.
After the reset time of the timer, the timer contact breaks the latch circuits and hence the output is put
off.
INTERNAL RELAYS
The terms internal relay, auxiliary relay and marker is considered as internal relay in the PLC.
In reality they are not Relays. However they are simulated by the software within the PLC. They are
useful in implementing switching sequences. Internal relays are used in a situation where occurrence
of output depends on two different input arrangements. Fig. shows the ladder diagram for such an
arrangement. In the diagram, first rung shows one input arrangement used to control the internal
relay IR1. The second rung shows the other input arrangement used to control the
internal
18
ME 8791 Mechatronics Mechanical Engineering
relay IR2. The contacts of the two relays are to control the output. Another use of internal relays is for
the starting of multiple outputs.
Another example of use of internal relay is resetting a latch. Fig. shows the ladder diagram.
When the input 1 is momentarily pressed, the output occurs. Then the output is latched. The output
can be unlatched by opening the internal relay contact. This can happen by the close of input
2contacts.
19
ME 8791 Mechatronics Mechanical Engineering
COUNTERS
As the name implies, counters are used for counting operations. It is an in-built operation in
any PLC. For example, in a packaging section of an industry, assume that the finished products are
passing along a conveyor into boxes. The counters can be used to count how many products have
passed into one box, so that the next box can be replaced after a particular count.
Two types of counters are possible, namely, up-counter and down-counter. In the down
counter the counter counts down a preset value to zero, whereas in the up counter the counter starts
from zero and count up to a preset value. In both the cases, as tie counter operation comes to an
end, its 'contact' changes state, i.e., it may close or open.
The counter is basically represented by a rectangle spanning two lines. (Refer fig.) One line is
used to reset the counter. The other line is used as 'OUT' line and the symbol K10 indicates that the
counter contact will change state on the 10th count. When the input 1 closes momentarily, the
counter is reset to the set value, in this case '10'. Now the counter starts counting as the input 2
closes and opens. When the input 2closes and opens for 10 times, then the counter contact close
and the output is switched on. In case, before 10 pulses are received from input 2, if input 1
momentarily closes, then the counter will reset back to10.
20
ME 8791 Mechatronics Mechanical Engineering
Example: Draw a ladder diagram to direct 6 items along path 1 for packaging in a box and then 12
items along path 2for packaging in another box. Two counters are used. One counter is used to count
six and another to count twelve. When input1 momentarily closes, both counters are reset and preset
to their respective counts 6 and 12. As items pass up to the junction in the paths, input 2contacts can
be made to close and open. After 6 items pass into one box, counter 1 contact closes and activates
the output which in turn closes one path and opens another. Counter 1also has contacts which close
and enables counter 2 to start counting. When counter 2 has counted 12 items it resets both counters
and opens counter 1 contacts which deactivates the output and the items will start falling into 6 items
box.
SHIFT REGISTERS:
Anumberofinternalrelayscanbegroupedtogethertoformaregisterwhichcanprovide a storage area for a
series of sequence of individual bits. Registers are used to store a bit sequence, for example a4-bit
sequence 1101 can be stored using 4 internal registers. Similarly an eight-bit sequence can be stored
using eight internal registers. A number of internal relays can be grouped together to form a
register
21
ME 8791 Mechatronics Mechanical Engineering
array. In shift registers the bits are shifted along the register array by one bit when there is a suitable
input fed to the register. Consider a 4 bit shift register with its bit sequence as
Assume. a 0 is fet to this shift register, then the bits are shifted along the register by one bit and
the
When the 'shift register' function is selected at the control panel of a PLC, then a number of
auxiliary registers are automatically grouped together to form a shift register. In Mitsubishi PLC a
programming function 'SFT' is to be used against the auxiliary relay number, which is the first in the
register array. For example if it is a 4- bit register to be formed, and if we select M 140 to be the first
relay number then automatically, the 4consecutive relays fromM140 will be assigned to form a 4-bit
shift register, i.e. M140, MI41, MI42 andMI43. A shift register has three inputs, namely OUT SFT1
and RST. OUT is used to load data into the first element of the shift register. SFT in used to shift the
bits by one bit and RST (Reset) in used to clear all the bits of the shift register to 0.
When contact input 2 close then master relay MC2 is activated and simultaneously the block
program rungs controlled by the relay MC2 follows. If there are no inputs to input 1 &2, then the next
input to be checked is for input 9 whose controlled output is OUT 6. Therefore this branching
program operates as -there is input I, then branch to follow MC1
22
ME 8791 Mechatronics Mechanical Engineering
controlled path, input 2, then branch to follow MC2 controlled path, otherwise neither input occurs
follow the rest of the program & ignore the branches.
Jumps
Conditional Jump is a function provided in PLCs. If a certain condition exists, then a section of the
program is ignored and the program control is jumped. In the ladder diagram shown, program A is
followed by input1 and the conditional jump relay CJP. If input 1 is OFF,theprogram B follows. The
end of program B is indicated by EJP end of jump relay coil. If input 1 is ON, then the program jumps
to the program 'C' skipping program B.
23
ME 8791 Mechatronics Mechanical Engineering
DATA HANDLING:
In some cases, it may be required to deal with related group of bits, i.e. a block of eight inputs
and operate on them as data word. The operations that may be carried out with a PLC on data words
normally include.
1. Datamovement
2. Datacomparison
3. Arithmeticoperations
4. Conversions between BCD, binary &octal.
We know that the individual bits are stored in memory locations specified by unique
addresses. These addresses are preceded by the letter 'A'. The PLC memory locations allocate for
data storage are called data registers. Each data register can store either 8 bits or 16 bits & its
address may be specified as DO, Dl, D2 etc. Every instruction has three parts-one specify the source
data register, second to specify the
destinationdataregisterandthirdtospecifythe'operation'tobeperformedonthedata.
Data movement
Data movement instruction has move instruction, source address of the data and destination
address of the data. For example, to move from Dl to D2.
ME 8791 Mechatronics Mechanical Engineering
Data Comparison:
Data comparisons include less than (<or LES), equal to (=orEQU), less than or equal to (or
LEQ), greater than (> or GRT), greater than or equal to ( or GEQ) and not equal to (# or <> orNEQ)
For example to compare the data available in Dl & D2, the ladder program rung would be of
the form shown in fig.
Example: Draw a ladder diagram that the alarm keeps sounding when the sensor temperature is
above 80°C and stops sounding when the temperature falls below 70°C. The sensor temperature is
fed as input data to the source address. The destination address has the set value, here it 80°C.
When the input temperature rises to 80°C or above, the source data becomes greater than or equal
to destination data and output alarm sound which in turn is latched in the input. When the
temperature falls to 70°C or lower, the source data is less than or equal to destination data (shown in
second rung of the ladder) and IR output occurs. Now in the first line (the ladder, the IR contact opens
and alarm is switched off.
ME 8791 Mechatronics Mechanical Engineering
Arithmetic Operations:
Addition and subtraction operations are commonly found in all PLCs. Even more arithmetic
operations are possible in some PLCs. ADDISUB instruction contains address of the addend, augend
and the result registers along with the arithmetic operation to be performed. These operations may be
used to change the preset values of the timers orcounters.
ANALOG INPUT/OUTPUT:
In PLCs, analog signals might be given as inputs and the actuators at the output might also
require analogue signals. in such cases, an analog-to-digital converters & digital-to-analog converters
may be used at the input & output channelrespectively.
Example : Draw a ladder diagram to show the speed of motor increasing at a steady rate from zero to
its maximum value:
SELECTION OF A PLC:
The factors to be considered in selecting a PLC for a particular task are:
1. Input/output capacity and its expansion capability for future needs.
2. Types of inputs/outputs required, i.e. isolation, on-board power
supply for I/O, signal conditioning, etc.
3. The size of memory required.
The speed and power of the CPU. This is related to the number of instructions
that can be handled by a PLC. As the types of I10 increases or/and the number of I/0
increases, the faster CPU is required.