05 PLCs
05 PLCs
Introduction
Programmable logic controllers (PLC) are logic industrial controllers that were developed primarily to control
sequencing systems. Each step in an event sequencing system occurs only when certain conditions are met
and certain steps have occurred. This is equivalent to each output signal being active only when certain input
sensor states exist and/or certain event steps are in progress or have occurred.
A PLC receives signals from sensors, performs logic operations that define the outputs and then writes the
output signals to the actuators. Figure 5.1 illustrates connection of sensors and actuators to the PLC.
Inputs
Outputs
Sensing devices
PLC Actuating devices
36
The bus lines mimic the power supply rails (24V and 0V) and each ladder rung mimics a relay switching
circuit. Each rung in a ladder program has input contacts and at least one output. Input contacts are
generally of the normally open (NO) and the normally closed (NC) types. The NO is normally open and closes
when the contact is activated. The NC is normally closed and opens when activated. Symbols used for the
normally open contact, the normally closed contact and the output are shown in figure 5.3.
Figure 5.3
An output on a ladder rung (mimicking a coil on a relay circuit circuit) is energized only when there exists a
path from the positive supply rail (bus line) through the input contacts and the coil to the negative supply rail
(bus line).
The inputs in a rung are connected together in such a way to give a logic condition that in turn turns on or
off the output(s) connected in the rung. The logic conditions may be series, parallel or series-parallel
connections of the contacts. Figure 5.4 shows examples of ladder rungs.
(a)
(c)
(b)
1. In (a) the output Y goes high (active) when input signals to X1 and X2 go high and input signal to X3
goes low. In Boolean logic, 𝑌5 = 𝑋1 ∙ 𝑋2 ∙ 𝑋3
2. In (b) the output Y goes high when any of the inputs X1, X2 and X3 go high. In Boolean logic, 𝑌 =
𝑋1 + 𝑋2 + 𝑋3
3. In (c) the output Y goes high when {C and Z are low, X is high} and either A and B are high or D is
high. In Boolean logic, 𝑌1 = ((𝐴 ∙ 𝐵) + 𝐴) ∙ 𝐶 ∙ 𝑋 ∙ 𝑍
37
The input contacts can be input points on PLC or internal bits in the PLC memory. Likewise, output coils can
be output points on the PLC or internal memory bits. Sensors connected to input points close or open the
contacts when they sense the objects they are designed to sense. Likewise, output points turn on actuators
when they are energized.
The relay circuit that may be used is shown in figure 5.5 (a). In a PLC application of the system, the sensors
are all connected to input points on the PLC and the lamp to an output point as shown in figure 5.5 (b). The
circuit between the sensors and the actuator is implemented by a software program running on the PLC. The
program can be represented in the form of a ladder rung as shown in figure 5.5 (c).
(a)
(b)
(c)
Figure 5.5
38
Figure 5.7
The above set of steps is known as a PLC scan. The PLC will continuously go through scans. For each scan, the
outputs are updated as necessary. In the process, a control function can be achieved. Figure 5.7 illustrates a
PLC scan.
Scan rate
Scan rate is the speed at which a PLC scans the memory. It is expressed in terms of the number of seconds
(or milliseconds) it takes to scan a given amount of memory, usually 1kB. The actual time to scan a program
depends on the scan rate, the length of the program and the types of functions used in the program. The
faster the scan rate the more often the inputs and outputs are checked.
Phasing errors
The CPU under the control of the operating system, scans the input image rather than the inputs
themselves. The input memory is not changed while the CPU is scanning it. Thus it is possible for an input
39
port to change its state from, say, off to on and back to off before the input image is updated. A phasing
error is said to have occurred when the CPU scan misses a change in the state of an input port.
(a) (b)
Figure 5.7. (a) PLC program scan cycle (c) PLC memory organization
Architecture of a PLC
A PLC is a microprocessor-based or microcontroller-based device. Figure 5.8 shows the general architecture
of a PLC.
Figure 5.8
The CPU
The CPU is in form of a microcontroller or a microprocessor. Its role is to control all operations in the PLC by
executing a program (or set of programs) stored in the memory.
40
PLC software
PLC programs consist of an operating system (OS) and a user program. The OS is a program that manages all
functions and all other programs in the PLC. The user program is a program that performs the logic
operations to switch outputs based on states of inputs.
Memory
Memory is used to store programs and data. It can be a mixture of ROM, RAM, EPROM, EEPROM flash RAM
and battery backed RAM. Memory is divided into the following groups that are used as follows:
1. Executive memory which is used to store the OS. Since the OS rarely needs changes after
development, this memory section is usually implemented as ROM.
2. System memory which is used to store system data. Mainly, system data is used by the OS. System
memory is implemented in RAM.
3. I/O status memory which is used to store input and output images. An image can be defined as a
copy of the states of the inputs or outputs on the PLC. I/O status memory is implemented in RAM.
4. Data memory which is used to store data associated with the user program. Functionalities like
timers, counters, numerical calculations, data storage and auxiliary relays require memory. This
memory is implemented in RAM.
5. User program which is used to store the user program. It can be implemented in EPROM, EEPROM,
flash RAM or battery backed RAM. The memory is required to be involatile because the program is
required as is until there is probably need to change the process being controlled. However, the
flexibility of changing the program is still required.
The address bus enables addressing of the memory and the I/O unit by the CPU. The data bus allows
exchange of data between the CPU and memory and I/O unit. The control bus is used to carry the necessary
control signals.
The I/O unit, the system I/0 bus and I/O devices
The I/O unit is used to interface the system I/O bus to the main system bus. The system I/O bus in turn
provides a link for communication between the I/O unit and the input devices and output devices.
Input devices are used to interface to input sensors. Output devices are used to interface to actuators. Once
connected, the sensors and actuators are mapped to some addresses by the I/O unit.
The input and output devices provide signal conditioning and isolation functions between the delicate
internal circuitry and the harsh industrial environment. They are also known as interface modules.
Interface Modules
Interface modules are constructed as standard devices that allow the PLC to be directly connected to a wide
range of sensors and actuators. Different types of interface modules are available. Each module type is
suited for a particular function.
41
1. 0/24V DC
2. 0/110V DC
3. 0/220V AC
4. 0/5V TTL
A digital input module has a number of input points - typically 8, 16 or 32 input points.
Input isolation
The main function of the digital input modules is to provide input isolation. Optical isolation is exploited.
Figure 5.9 illustrates optical isolation on a PLC input point.
(a)
(b)
(c)
Figure 5.9 Optical isolation of inputs: (a) opto isolator (b) DC input (c) AC input
The plant sensor (plain switch, sourcing or sinking type) applies a current signal to the input point. The
photodiode part of the opto isolator transfers this signal as light to the phototransistor part. The transistor in
turn switches internal PLC circuitry and hence transfers in the signal without a physical electrical connection.
42
The reasons for use of optical isolator are:
The PLC operates at TTL levels while the plant operates at higher voltages. Input isolation is used to
protect the delicate internal PLC circuitry from the harsh plant voltages.
Separating the plant supplies from plant supplies ensures that the PLC is not adversely affected by noise
signals in the plant. Electrical noise may result from voltage spikes on signal lines, or from load currents
flowing in AC neutral or DC return lines. The differences in earth potential between the PLC cubicle and
outside plant can also cause problems.
A digital output module has a number of input points - typically 8, 16 or 32 input points.
Inputs are also isolated using opto isolators. Figure 5.10 shows output isolation.
(a)
(b)
Figure 5.10 DC output circuits: (a) DC output circuit, current sourcing; (b) effect of current suppression diode
The opto isolator transfers signals from the PLC internal circuitry to the switch on the output point with no
physical electrical contact. Diode D1 is used to clip spikes due to noise. Noise interference can be more of a
problem on outputs because of the higher currents that are being controlled by the cards and the loads
themselves that are often inductive (e.g. solenoid and relay coils).
43
Figures 5.11 and 5.12 show the two basic types of output card, one with common supply and the other with
separate supply for each output.
(a)
(b)
Figure 5.11 Types of output cards: (a) output card with common supply; (b) output card with separate
supplies
44
Figure 5.12 AC output circuit: (a) AC output stage; (b) effect of triac output
Resolution
Resolution is the smallest change in the analog input that causes a change in the digital output. It is the
amount of analog input corresponding to unity or binary one.
As an example, an 8-bit ADC can represent an integer in the range 0 – 255. If this was used to represent an
analogue signal measuring a flow with a span (range) from 0 to 1800 l/min, the resolution would be
approximately 7 l/min (given by 1800/255).
45
Analog output modules
Analog output modules perform analog to digital conversion of outputs so that they can be sent as analog
signals to actuators needing such signals. Each module has a number of output points – typically 4, 8 or 16
outputs.
where VADC is the value passed to the DAC, N is the output number in engineering units, HR/LR are
the high- and low-range values, n is the number of bits in the input value and Vs is the supply voltage
to the DAC (maximum possible output).
PLC construction
Single unit
Small PLCs are implemented in the form of a single unit. All the PLC components and modules are built into
one unit. Connection points are provided for connecting to the sensors and actuators. Limited expansion can
be achieved by adding a few more I/O modules. Figure 5.13 shows a typical single unit PLC.
Figure 5.13
Modular PLCs
Medium and large PLCs are implemented in modular form. A number of units each for a specific function are
built separately and then connected together to give the PLC. The units are mounted on a rack. Figures
5.14(a) and (b) show typical modular PLC constructions.
46
Figure 5.14 (a)
There can also be other types of cards mounted onto the rack.
47
Remote I/O
This is when I/O cards are mounted on racks that are a distance from the main PLC but local to the sensors
and actuators. The remote I/0 cards are connected to the main PLC using a communication channel, for
example an optic fibre or LAN cable. Sensors and actuators are wired to the remote cards using the usual
conducting wires.
The remote I/O card thus receives signals from sensors and multiplex them for transmission to the main PLC
via the communication channel. The cards also receive signals via the communication channel from the main
PLC, de-multiplex them and send them to the actuators.
Generally, a terminal is provided local to ach remote rack so that plant operation can be monitored local to
the plant devices.
PLC manufacturers offer many facilities to reduce the effect of scan times. Typical are high-speed
independent I/O cards and the ability to sectionalise the program into areas with different scan rates.
Figure 5.15 The effect of program scan and I/O scan cycles
48
PLC Programming
Addressing
PLCs identify I/O devices and memory using some form of addressing. Different PLCs generally use different
ways of addressing. Allen Bradley addressing and Siemens addressing will be briefly explored.
Memory bits
In Allen Bradley PLCS, memory can be addressed as bits or words of certain bit width. Bits are addressed
using a similar approach as for I/O points. The identifier for memory bits is B. The format for a memory bit
address is BM/n where n denotes the bit and M denotes the file containing the bit. For example, B3/25
means bit 25 on file 3.
0 1 2 3 4 5 6 7
PLC
processor
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
O:26/05
I:35/02
49
Siemens addressing
Digital I/O in Siemens PLCs is arranged in groups of 8 bits, called a byte. An I/O signal is identified by its bit
number (0 – 7) and its byte number (0 – 127). Inputs are denoted in the form I<byte>.<bit> and outputs in
the form Q<byte>.<bit>. For example:
I9.4 means input with bit address 4 in byte 9
Q63.6 means output with bit address 6 in byte 63.
Like Allen Bradley, Siemens use card slots in one or more racks. The cards are available in 16-bit (2-byte) or
32-bit (4-byte) form.
Figure 5.16 shows the Siemens card layout and addressing. Figure 5.17 (a) shows fixed slot addressing. In
most systems, however, the user has the ability to assign the byte addresses. This is known as variable slot
addressing and is shown in figure 5.17 (b). The first byte address and the range (2-byte or 4-byte) can be set
independently for each slot by switches in the adaptor module in each rack.
Figure 5.17 Siemens card layout: (a) Fixed slot addressing; (b) Variable slot addressing
Memory addressing
Memory can be addressed as bits, bytes, words or double words.
Words are 16 bits wide while double bytes are 32 bits wide.
Memory bits use the identifier MB for example MB5.6 is bit 5 in memory at address 5.
Memory bytes use the identifier M for example M13 is byte at memory address 13.
50
Memory words use the identifier MW for example MW8 is word at memory address 6. The word
occupies two consecutive addresses, in this case addresses 6 and 7. Addresses of memory words are
therefore multiples of 2.
Memory double words use the identifier MD for example MD12 is word at memory address 12. The
word occupies four consecutive addresses, in this case addresses 12, 13, 14 and15. Addresses of
memory double words are therefore multiples of 4.
I/O can be accessed as bytes, words or double words in a similar manner to accessing bytes, words
and double words in memory. For example, Q7 is a byte output to output byte 7.
PLC programming
There are three main methods that can be used for PLC programming. These are ladder logic, statement list
and logic symbols.
After the program has been written, it is converted into machine language that can run on a PLC. Programs
are loaded into the PLC’s memory using a program loader. These vary from hand held systems incorporating
a small keyboard and LCD to conventional computers.
Ladder programming
As mentioned in an earlier section, ladder programming uses ladder logic to write PLC programs. A program
is entered in a form that mimics relay switching circuits.
Latching
A latch is used to maintain an output state even if the input contact which energised it is turned off. Figure
5.18 shows latching in a ladder rung.
51
Figure 5.18 (b)
Figure 5.18 (a) A latching rung (b) motor starter PLC wiring and PLC ladder diagram
When the Start contact makes, Step-1 is energised thereby making the Step-1 input contact. If Start later
opens, the output Step-1 is kept energised. The closed input Step-1 thus, keeps the output Step-1 energised
even if the input Start opens. In other words, the output latches itself.
Figure 5.18 (b) shows the application of latching in the start/stop control of an electric motor.
Auxiliary relays
These are memory bits that can be used to store single bit information about a process. They may represent
a step or a state in an event sequencing system, for example ‘standby pump running’, ‘system healthy’ and
‘lubrication fault’.
Sequencing of steps
To achieve sequencing states of rung outputs are made to depend on states of other rungs in such a way as
to generate the required sequence. Consider the ladder program for a two-step process shown in figure
5.19. Only one of the two steps is required at any given time. Step-1 and Step-2 are auxiliary relays that are
used to represent (and show the states) of the two steps. Start and stop are NO push to make switches
connected to a PLC input. When Start is momentarily pressed while the process state is 1, process goes into
step 2. If Stop is momentarily pressed while in step 2, the process goes into step 1.
52
Figure 5.18
It can be observed that each subsequent step kills the previous step. Whenever step 2 is switched on, step 2
is automatically switched out. Secondly entering a subsequent step only occurs when the process is in the
preceding step and conditions of entering the new step are satisfied. Step 2 is entered only when the
process is in step 1 and start is pressed. Step 1 is only entered when the process is in step 2 and stop is
pressed.
53
In general, each step on a ladder designed for sequencing consists of:
1. A path with conditions to go into a step.
2. A path to latch the current step as well as to kill the previous step.
Figure 5.19 PLC programming using logic symbols (Siemens notation): (a) an AND gate; (b) truth table for
AND gate: (c) hydraulic healthy lamp of figure 5.11 in logic notation; (d) an inverted input
A test to check if a signal is not true is denoted by a small circle ‘◦’ (this is equivalent to testing a normally
closed contact in ladder diagram notation). Hence the output Z of the AND gate in figure 5.19 (d) is true if
(and only if) A and C are true and B is not true.
Statement lists
A ladder diagram can be translated into a program consisting of instruction lines. Table 5.1 shows typical
instructions for a PLC.
54
Table 5.1 Typical instruction list
Instruction Description
LOAD Load contact
OR Logical OR operation
NOT Inversion
OUT Output
Different manufacturers may use different instructions but the logic is similar.
Figure 5.20 shows a simple operation in both ladder and logic formats for a Siemens PLC. The equivalent
statement list is given in Table 5.2.
55
Figure 5.21 and Table 5.3 show a more complex program in the three notations
07 :) Now at point X
56
Timers
Timers count pulses generated from the CPU’s internal clock. They count these pulses until they get to the
preset value, a point when some delay period would have been realised. Counters enable delay operations
to be implemented in control. The preset value of the timer is the delay period.
Figure 5.22 Different forms of timer: (a) on delay; (b) off delay; (c) fixed width pulse
Timer signals
The following are signals available on a timer:
Enable, EN – is a mimic of the timer input
Timer timing, TT – is energised whilst the timer is running (i.e. preset value hasn’t expired)
Time done, DN – indicates timer has finished (preset value has expired)
Figure 5.23 shows the signals as used on an Allen Bradley delay on timer (TON) and a delay off timer (TOF).
57
Using timers in programs
PLC manufacturers differ on how a timer is programmed. Most use the timer as a terminator for a rung, with
the timer signals being available as contacts for use elsewhere. Others use the timer as a delay block with
the preset being stored in a value block.
Most timers used are non-retentive (accumulated time goes back to zero when the input goes to zero); but
retentive timers (these require reset signal) are also available.
Figure 5.23 Allen Bradley timer notations: (a) TON timer; (b) TOF timer
Figure 5.24 Two types of time in the same application: (a) Allen Bradley notation; (b) Siemens logic notation
58
Counters
Counters are used to count externally generated pulses. A counter is, like a timer, associated with a preset
value. If the count value reaches the preset value, a count complete or count done signal is given. The count
value itself is also available for use in the program. A counter can be reset.
There are two types of counters: up-counters and the down-counters. Up-counters count up to the preset
value while a down-counters count down from the preset value to zero.
Most PLCs allow a counter to count up to 32767. Where larger counts are needed, counters can be cascaded
with the complete (or done) signal from the first counter being used to step the second counter and reset
the first. In a similar way, timers can also be cascaded with counters to get longer timer periods. Figure 5.25
is a variation of the same idea used to give a very long timer.
Numerical applications
Numeric representations
So far we have been primarily discussing single-bit operations. Numbers are also often part of a control
scheme; a PLC might need to calculate a production rate in units per hour averaged over a day, or give the
amount of liquid in a storage tank. Such operations require the ability to handle numeric data.
59
Functions are available to handle numeric data in the form of integers (16-bit words), long integer (two 16-
bit words) or floating point numbers that consist of two 16-bit words, which contain the mantissa (the
numerical portion) and the exponent.
Data movement
Numbers are often required to be moved from one location to another; a timer preset may be required to
be changed according to plant conditions, a counter value may need to be sent to an output card for
indication on a digital display or the result of some calculation may be used in another part of a program.
Functions (or instructions) are available for such data movements (Figure 5.26).
Data comparison
Numerical values often need to be compared in PLC programs: typical examples are a batch counter saying
the required number of items have been delivered, or alarm circuits indicating, say, a temperature has gone
above some safety level.
These comparisons are performed by elements which have the generalised form of Figure C.24, with two
numerical inputs corresponding to the values to be compared, and a binary (on/off) output which is true if
the specified condition is met.
Value 1
Compare Result
Value 2
60
Arithmetic operations
PLCs provide the ability to do mathematical operations such as add, subtract, multiply and divide (Figure
5.28).
GRAFCET
GRAFCET is a tool for describing a sequencing system. It, thus can be used in development of PLC programs
for these sequencing systems.
In the PLC application, a step represents a process state, actions represent the outputs to be turned on in a
particular step and a transition points represent the closing (or opening of) an input contact.
61