Unit Iv Programmable Logic Controller (PLC)
Unit Iv Programmable Logic Controller (PLC)
BASIC STRUCTURE
The figure below 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.
1) Relay Type
With relay type, the signal from the PLC output is used to operate a relay
and so is able 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. Opto isolators are
used with transistor switches to provide isolation between the external circuit
and the PLC. The transistor output is only for D.C. switching.
3) Triac type:
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/0 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 3 ms 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 3 ms 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
2. Mass I/O Copying
In the above method, with 3 ms delay on each input, the time taken to
examine several hundred I/0 points can become comparatively long. To allow
a more rapid execution of a program, a specific area of RAM is used as a
buffer store between the control logic and I/0 units. Each I/0 have and
address in this memory. At the start of each program is executed the stored
input data is read, as required, from RAM and the logic operations carried
out. The resulting output signals are stored in the reserved I/0 section
RAM. At the end of each program cycle, all the outputs are transferred
from RAM to the output channels. The outputs are latched so that they retain
their status until the next update.
7
from left to right.
4. Each rung must start with an input and must end with an output.
5. Each rung must have more than one input but only one output.
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 normal condition.
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.
8
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.
9
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. This might
have an input addressX400. The line terminates with the output, the
solenoid. 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 a vessel.
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.
7
1. And function
Only when both the switches are closed simultaneously, the lamp will be lit,
otherwise it is put off. Thus, this situation corresponds to an AND logic
function. The ladder diagram representing the AND function is shown in
Fig.(b). The switches A and B are represented as input 1 and input 2 and
lamp is represented as an output.
2. OR function
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.
8
3. Nor function
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 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
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
9
not occur simultaneously (i.e., when both are not opened simultaneously).
The ladder diagram is shown in Fig. (b)
LATCHING
1
0
An example of a latch circuit is shown in Figure above 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 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 B
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
1
1
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.
Figure below 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.
MNEMONICS
OUT An output
SHF Shift
K Insert a constant
An AND System
An OR System
An NAND System
An NOR System
An XOR System
TIMERS
When input contacts close, timer 1 is activated; after its time delay, its
contacts close and timer 2 is activated; after its time delay, its contacts
close and output occurs.
Normally PLC’s are provided with delay-on timer. The diagram shown in
figure 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. How ever 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
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.
When start contacts are closed, the internal relay is activated and latches the
input. It also starts output 1 and makes it possible for outputs2 and 3 to be
activated.
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 2 contacts.
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 K10indicates 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 to 10.
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 input 1 momentarily closes, both counters are reset and
preset to their respective counts 6and 12. As items pass up to to the
junction in the paths, input2 contacts 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:
Assume. a 0 is fed to this shift register, then the bits are shifted along the
register by one bit and the last bit overflows:
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 4 consecutive relays
from M140 will be assigned to form a 4-bit shift register, ie 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.
Master Relay:
More than one output or a block outputs arranged in each output rung
can be simultaneously turn off or on by using one internal relay contact. If
this single relay contact is switched on or off, then it affects every one of the
rungs. When the contact input 1 close then master relay MC1 is
activated and simultaneously the block program rungs controlled by the
relay MC1 follows. In the ladder shown, OUTI, OUT2 & OUT3 also
simultaneously activated. The end of master relay controller section is
indicated by the reset MCR.
When contact input 2 closes 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 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
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. Data movement
2. Data comparison
3. Arithmetic operations
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 destination data register and third to
specify the 'operation' to be performed on the data.
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,
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 <> or NEQ)
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 it80°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.
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 or counters.
Code Conversions:
In a PLC, all the internal operations are carried out in binary form only.
However, it may be required to handle decimal or octal numbers at the input
or output in which case a conversion from binary to decimal to octal or a
conversion from decimal/octal to binary is required. For example to convert
a BCD number in the source register to a binary number and store the result
in destination register, refer the fig.
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 channel respectively.
Example 1: Draw a ladder diagram to show the speed of motor
increasing at a steady rate from zero to its maximum value:
An on/off switch is used at the input. When the switch is in OFF position, the
data register has 'OO', as its contents and hence DAC output is zero & so
the motor is at zero speed. But as the switch closes, the data register is
incremented. As the program loops through these two rungs of the ladder,
the data register keeps incrementing by one, &the DAC output increases
steadily and hence the motor speeds up at a steady rate. The motor
reaches its full speed when the data register contents has the word
11111111.
SELECTION OF A PLC: