CHAPTER 3
PROGRAMMABLE LOGIC
CONTROL
Reference: Groover, 2015
Content
1. Introduction
2. Open and closed control circuits
3. Edge detection
4. Counter function and timer
5. Programmable logic control system project
INTRODUCTION
• PLC stand for “Programmable Logic
Control”.
• It is a general purpose computer modified
specifically to perform control task.
• These controllers can automate a specific
process, machine function, or even an
entire production line.
• PLC is developed for an electronic
replacement for hardwired relay logic
system for machine control.
• It is a microprocessor-based control
system.
OPEN AND CLOSED
CONTROL CIRCUITS
As explained in Chapter 1
• The main difference between an open-loop system and a closed-loop
system is that the closed-loop system has the ability to self-correct while
the open-loop system doesn't.
Open-loop control system
Closed-loop control system
Open loop system Closed loop system
Definition The system whose control action is free In closed loop, the output depends on the
from the output is known as the open loop control action of the system
control system
Components Controller and Controlled Process Amplifier, Controller, Controlled Process,
Feedback
Construction Simple Complex
Accuracy Depends on calibration Accurate because of feedback
Response Fast Slow
Calibration Difficult Easy
Examples Traffic light, automatic washing machine, Air conditioner, temperature control
immersion rod, TV remote system, speed and pressure control system,
refrigerator, toaster
EDGE DETECTION
• The Edge Detector component samples the connected signal and
produces a pulse when the selected edge occurs.
• Use the Edge Detector when a circuit needs to respond to a state change
on a signal.
• Signal edge detection is a technique widely used in embedded software,
model based development and electronics.
• A signal edge is defined as the transition of the signal from a high state to
a low state or vice-versa. Depending on the type of transition, there are
three different types of edge detection:
• Rising edge / positive edge: when the input signal is transitioning from a low state
(e.g. 0) to a high state (e.g. 1)
• Falling edge / negative edge: when the input signal is transitioning from a high
state (e.g. 1) to a low state (e.g. 0)
• Either edge: when the input signal is changing state, from high to low or from low
to high
• The detection of the edge is done on discrete signals. The edge detection
is represented by an output Boolean signal, which has the value 1 (true)
only during a time step, when the state change has occurred,
• Signal edge detection is useful in for timers, counters or clock resets, for
signal state updates or for triggering a set of functions / algorithms.
COUNTER FUNCTION AND
TIMER
• A PLC is a specialized computer that is used to control and operation of manufacturing
process or machinery.
• It is not possible to control complex systems by using certain logic and it is because
sensors cannot be used to check all the conditions. So during these conditions, events is
used to determine the condition of the system.
• Mostly a PLC would use certain events such as PLC scanning which indicates that the
PLC has just been turned on. The timers and counters (both are of 16 bits) are used in a
PLC for its continuous operation so they are inevitable in a PLC.
• Both the timer and counter would function as output instructions in a PLC program.
• The timer is used to indicate that the input is turned ON/OFF or to create a delay.
• Counters are used to count the set of events that have occurred and the latch or unlatch
is used to lock something ON or to turn it off.
• There is memory space in the PLC to store instructions and it would also do the
functions such as timing, counting, arithmetic, data handling, and sequencing. The timer
would time up to the value set by the user and the counter will count up to the value set
by the user.
Timer
• The PLC timer consists of an internal clock, a count value register, and
an accumulator, and the timer is mostly used for the timing process as
cycle time is really critical in many processes.
• The number of timers that can be used in program is depended on the
amount of memory in the CPU.
• The timers are used in PLC to delay actions, the timer would keep an
output for a specified time after an input turns off and vice versa.
• The major function of a timer is to keep an output ON for a specified
length of time. The timers in PLC are considered as a software module
and it would generate digital timing.
• A timer has certain parts such as time base, accumulated value, timer
address, and preset value.
• Accumulated value - This is a current number of time-based intervals that have
been counted from the moment when the timer is energized.
• Preset value - This value is set by the programmer, if the preset value is less
than or equal to the accumulated value then a status bit is set and this bit is to
control an output device.
Timer
• There are bits that are related to the current state of the timer and it is called the status bits. Each timer is composed
of two status bit:
1. Timer enable-bit – This bit will be set if the rung condition to the left of the timer instruction is true and when this bit is set then
the accumulated value will be incremented on each time base interval till it reaches the preset value.
2. Done bit – This bit will be set if the preset value and the accumulated value are equal and it will be reset if the rung condition is
false.
• The timer will be activated if the execution condition is started and it will be reset if the execution condition stops or
goes OFF.
• If the execution condition keeps ongoing or if it is long enough for the timer to time down to zero. Then the
completion flag will be turned ON and it will remain ON till the execution condition is completed or turn OFF.
• Depending on the PLC type, the bits are either attached to the timer instruction or hidden. The three timer bits that
can be used as rung conditions:
1. .EN (enable) – true when the rung input logic is true
2. .TT (timer timing) – true only when the accumulator value is incrementing and less than the preset value.
3. .DN (done) – true when the accumulator value is equal or greater than preset value
• Types of timer in a PLC:
1. ON-delay timer - this timer would be on after a particular time delay.
2. OFF-delay timer - this timer would delays the turning off.
3. Pulse timer - to generate the pulse and it will be of a specific length.
Counter
• The counters are needed in a PLC to detect the numbers and events, mostly the
controller needs to operate with the counters.
• The counters are used to eliminate the requirement of relays to represent the
events that have occurred.
• The counters are used to index, increment, or decrement the values. The counter
would count from zero to the predetermined value and it is the preset value.
• Mostly the counters are used in PLC to count items an example of this will be
counting the cans which go into a box on an assembly line.
• So the counters are really important, if a box is filled then it needs to be moved
so that another one can be filled.
• Basically a PLC counter is a function block that would count up or down till it
reaches a limit and when the output is set then the limit is reached and it will
trigger the alarm.
Counter
• The counters consist of variables and it is used to store the
numbers in the PLC. All the counter would store a
minimum of two numbers and they would be counter limit
and current counter value. These two numbers will be
saved as word or integer data types.
• Types of counter in a PLC:
1. UP counter- this counter will count from zero up to the preset
value.
2. DOWN counter - this counter will count down before the
preset value is reach.
3. UP DOWN counter - can count in both ways and this could
be useful for certain PLC functions.
PROGRAMMABLE LOGIC
CONTROL SYSTEM PROJECT
NO & NC Contacts and AND Gate Logic
NO & NC Contacts and OR & NOT Gate Logic
Elements of Logic Control
AND gate
• The basic elements of logic control are the logic gates AND,
OR, and NOT.
• In each case, the logic gate is designed to provide a specified
output value based on the values of the input(s).
• For both inputs and outputs, the values can be either of two
binary values: 0 or 1.
• For purposes of industrial control, 0 (zero) is defined as OFF OR gate
and 1 (one) as ON.
• Both the AND and OR gates can be used with two or more
inputs.
• The NOT gate has a single input. The NOT gate reverses the
input signal: If the input is 1, then the output is 0; if the input is
0, then the output is 1.
• The NOT gate can be used to open a circuit upon receipt of a
control signal.
Boolean Logic & XOR Gate
Boolean Algebra and Truth Tables
• The logic elements form the foundation for a special algebra that was developed around 1847 by
George Boole and that bears his name.
• Its original purpose was to provide a symbolic means of testing whether complex statements of
logic were TRUE or FALSE.
• In fact, Boole called it logical algebra.
• It was not until about a century later that Boolean algebra was shown to be useful in digital logic
systems.
• Expression in Boolean algebra:
1. AND function
2. OR function
3. NOT function
4. NAND function (AND + NOT)
5. NOR function (OR + NOT)
• Several of the laws and theorems of Boolean algebra can often be applied to simplify logic
circuits and reduce the number of elements required to implement the logic, with resulting
savings in hardware and/or programming time.
Truth Tables for the Logical (a) AND, (b) OR, and (c) NOT Gates Symbols used for logical gates: U.S. and ISO
Truth Tables for the Logical (a) NAND and (b) NOR Gates
Laws and Theorems of Boolean Algebra
Example 1: Robot Machine Loading
Suppose that in a machine-loading application, the robot is programmed to pick up a raw work
part from a known stopping point along a conveyor and place it in a forging press. Three
conditions must be satisfied to initiate the loading cycle:
1. The raw work part must be at the stopping point
2. The forge press must have completed the process on the previous part
3. The previous part must be removed from the die.
The first condition can be indicated by means of a simple limit switch that senses the presence of
the part at the conveyor stop and transmits an ON signal to the robot controller. The second
condition can be indicated by the forge press, which sends an ON signal after it has completed the
previous cycle. The third condition might be determined by a photodetector located so as to sense
the presence or absence of the part in the forging die. When the finished part is removed from the
die, an ON signal is transmitted by the photocell. All three of these ON signals must be received
by the robot controller to initiate the next work cycle. No previous conditions or past history are
needed.
Determine the Boolean algebra expression and the logic network diagram for this interlock system.
Solution
• Let X1 = whether the raw work part is present at the conveyor stopping point (X1 = 1 for part present,
X1 = 0 for part not present).
• Let X2 = whether the press cycle for the previous part has completed (X2 = 1 for completed, X2 = 0 for
not completed).
• Let X3 = whether the previous part has been removed from the die (X3 = 1 for removed, X3 = 0 for not
removed).
• Finally, let Y = whether the loading sequence can be started (Y = 1 for begin, Y = 0 for wait).
• All three conditions must be satisfied, so the logical AND function is used. All of the inputs X1, X2, and
X3 must have values of 1 before Y = 1, initiating the start of the loading sequence.
• The logic network diagram for this interlock condition:
• The Boolean algebra expression is Y = X1 + X2 + X3.
Example 2: Push-Button Switch
A push-button switch used for starting and stopping electric motors
and other powered devices is a common hardware component in
industrial control systems. It consists of a box with two buttons,
one for START and the other for STOP. When the START button
is depressed momentarily by a human operator, power is supplied
and maintained to the motor (or other load) until the STOP button
is pressed momentarily, which breaks the power to the POWER-
TO-MOTOR. POWER-TO-MOTOR is the output of the push-
button switch, but it also serves as a contact to power the motor.
a. Define the initial values of the variables.
b. Construct the truth table for the push button.
c. Construct the logic network diagram.
Solution
a) The variables are defined as follows:
i. START = 0, normally open contact
ii. START = 1, closed when the START button is pressed
iii. STOP = 1, normally closed contact
iv. STOP = 0, open when the STOP button is pressed to break contact
v. POWER-TO-MOTOR = 0, when the contacts are open
vi. POWER-TO-MOTOR = 1, when the contacts are closed
vii. MOTOR = 0, when off (not running)
viii. MOTOR = 1, when on (running)
Solution
b) The truth table for the push button:
c) The logic network diagram
Ladder Logic Diagrams
• Another diagramming technique that exhibits the logic as well as the
timing and sequencing of the system is the ladder logic diagram.
• This graphical method has an important virtue in that it is analogous to
the electrical circuits used to accomplish logic and sequence control.
• In addition, ladder logic diagrams are familiar to shop personnel who must
construct, test, maintain, and repair the discrete control system.
• In a ladder logic diagram, the various components are displayed along
horizontal lines or rungs connected on either end to two vertical rails.
• The diagram has the general configuration of a ladder, hence its name.
• The components are (1) contacts, representing inputs, and (2) loads, also
known as coils, representing outputs.
• Power (e.g., 120 VAC) to the components is provided by the two vertical
rails.
• In ladder diagrams, the inputs (contacts) are located to the left of each
rung and the outputs (loads) are located to the right.
Ladder Logic Diagrams Symbols
• There are two types of contacts: normally open and normally closed.
• Both types of contacts are used to represent ON/OFF inputs to the logic circuit.
Example 3: Three Lamp Circuits
Create ladder logic diagrams for the three basic logic gates (a) AND, (b) OR,
and (c) NOT.
Solution
Example 4: Push-Button Switch
The operation of the push-button switch of Example 2 can be depicted in a
ladder logic diagram. From the solution (b), let START be represented by S1,
STOP by S2, POWER-TO-MOTOR by P, and MOTOR by M.
Create the ladder logic diagram.
Solution
Example 5: Control Relay
A control relay can be used to control on/off actuation
of a powered device at some remote location. It can also
be used to define alternative decisions in logic control.
Construct the ladder logic diagram of a control relay.
Solution
The relay is indicated by the load C (for control relay),
which controls the on/off operation of two motors (or
other types of output loads) Y1 and Y2.
Example 6: Fluid Storage Tank
Consider the fluid storage tank as illustrated. When the start button
X1 is depressed, this closes the control relay C1, which energizes
solenoid S1, which opens a valve allowing fluid to flow into the tank.
When the tank becomes full, the float switch FS closes, which opens
relay C1, causing the solenoid S1 to be de-energized, thus turning off
the in-flow. Switch FS also activates timer T1, which provides a 120-
sec delay for a certain chemical reaction to occur in the tank. At the
end of the delay time, the timer energizes a second relay C2, which
controls two devices:
(1) It initiates timer T2, which waits 90 sec to allow the contents of
the tank to be drained.
(2) It energizes solenoid S2, which opens a valve to allow the fluid
to flow out of the tank.
At the end of the 90 sec, the timer breaks the current and de-
energizes solenoid S2, thus closing the out-flow valve. Depressing the
start button X1 resets the timers and opens their respective contacts.
Construct the ladder logic diagram for the system.
Example 6: Fluid Storage Tank Solution
Consider the fluid storage tank as illustrated. When the start button
X1 is depressed, this closes the control relay C1, which energizes
solenoid S1, which opens a valve allowing fluid to flow into the tank.
When the tank becomes full, the float switch FS closes, which opens
relay C1, causing the solenoid S1 to be de-energized, thus turning off
the in-flow. Switch FS also activates timer T1, which provides a 120-
sec delay for a certain chemical reaction to occur in the tank. At the
end of the delay time, the timer energizes a second relay C2, which
controls two devices:
(1) It initiates timer T2, which waits 90 sec to allow the contents of
the tank to be drained.
(2) It energizes solenoid S2, which opens a valve to allow the fluid
to flow out of the tank.
At the end of the 90 sec, the timer breaks the current and de-
energizes solenoid S2, thus closing the out-flow valve. Depressing the
start button X1 resets the timers and opens their respective contacts.
Construct the ladder logic diagram for the system.