3-LO2 PLC Programming
3-LO2 PLC Programming
3-LO2 PLC Programming
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 1 / 71
Learning Objectives
1 Use conventional (relay logic) and ladder logic to program a PLC with
documentation.
2 Use logic fundamentals (AND, OR, and NOT), Boolean expressions, and truth tables
as a basis for PLC ladder logic diagrams and programs for the PLC, as appropriate.
3 Use PLC ladder logic to control a motor.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 2 / 71
The Binary Concept
1 Binary refers to the idea that many things can be thought of as existing in only one of
two states. The binary states are 1 and 0
2 The 1 and 0 can represent: ON or OFF; Open or Closed True or False or High or
Low
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 3 / 71
AND, OR, and NOT Functions
The AND Function An AND gate is a device with two or more inputs and one output.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 4 / 71
The AND gate
If all inputs are 1, the output will be 1. If any input is 0, the output will be 0.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 5 / 71
Hardwired AND
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 6 / 71
The OR gate
The OR Function
An OR gate can have any number of inputs but only one output.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 7 / 71
The OR gate
The OR gate output is 1 if one or more inputs are 1. If all inputs are 0, the output will be 0.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 8 / 71
Hardwired OR
The OR logic gate operates similarly
to control devices connected in
parallel. The light will be on if switch A
or switch B or both are closed.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 9 / 71
The NOT Function
The NOT function can have only one input. The NOT output is 1 if the input is 0. The
output is 0 if the input is 1.Since the output is always the reverse of the input it is called an
inverter.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 10 / 71
Hardwired NOT Function
The NOT function can be performed on a contact input simply by using a normally closed
instead of a normally open contact.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 11 / 71
Example: NOT Gate Application - Low-pressure
indicating circuit
If the power is “on” (1) and the
pressure switch is not closed (0),
the warning indicator will be “on”
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 12 / 71
The NAND Function
An AND gate with an inverted output is called a NAND gate.
The NAND gate has the opposite outputs to the AND gate.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 13 / 71
The NOR Function
A OR gate with an inverted output is called a NOR gate.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 14 / 71
The Exclusive-OR (XOR) Function
The output of the XOR gate is HIGH (1) only when one input or the other is HIGH, but not
both. It is commonly used for the comparison of two binary numbers.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 15 / 71
Boolean Algebra
1 The mathematical study of the
binary number system and logic is
called Boolean algebra.
2 Boolean algebra is used to write
combinations of logic statements
that are used to solve PLC
programming problems.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 16 / 71
Logical expressions (Boolean equations)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 17 / 71
Logical expressions (Boolean equations)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 18 / 71
Laws of Boolean algebra
Some laws of Boolean algebra are similar to those of ordinary algebra.
(the distributive law holds true only in Boolean algebra)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 19 / 71
Developing Logic Circuits from Boolean
Expressions
Logic gate circuit developed from the Boolean expression Y = AB + C. Gates required:
AND gate with input A and B
OR gate with input C and output from previous AND gate
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 20 / 71
Developing Logic Circuits from Boolean
Expressions
Logic gate circuit developed from the Boolean expression Y = A (BC + D). Gates required:
- AND gate with input B and C
- OR gate with inputs BC and D
- AND gate with inputs A and the output from the OR gate
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 21 / 71
Boolean Equations from Logic Circuits
The output of the OR gate is A + B
The output of the inverter is D
Based on the input combination applied to the AND gate the Boolean equation for the
circuit is
Y = C D (A +B)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 22 / 71
Boolean Equations from Logic Circuits -1
The output of AND gate 1 is A’B
The output of AND gate 2 is AB’ Based on the combination of inputs applied to the OR
gate the Boolean equation for the circuit is
Y = A’ B + AB’
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 23 / 71
Exercise: Circuit Development Using A Boolean
Expression
draw the digital circuit for
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 24 / 71
Exercise: Circuit Development Using A Boolean
Expression
draw the digital circuit for
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 25 / 71
Excersise: Producing A Boolean Expression From
A Given Circuit
find the corresponding logical expression
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 26 / 71
Excersise: Producing A Boolean Expression From
A Given Circuit
Is this an XOR gate?
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 27 / 71
PLC program
1 A program is a series of instructions that directs the PLC to execute actions.
2 The PLC program is executed as part of a repetitive process referred to as a scan.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 28 / 71
Relay ladder logic
Relay ladder logic is based on electromagnetic relay control can be hard and complex to
implement.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 30 / 71
Hardwired relay logic
The motor starter coil (M) is energized when both the pressure and temperature switches
are closed or when the manual pushbutton is pressed.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 31 / 71
Mixer Process: PLC implementation
Connect Field devices to I/O modules (hard wired) (i.e. pressure and temperature
switches (sensors), and mixer motor)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 32 / 71
Mixer Process: PLC implementation
Enter the PLC ladder logic program into the memory of the CPU.
1 The symbols
represent
instructions and the
numbers represent
the instruction’s
addresses.
2 Each input and
output device is
given an address,
which lets the PLC
know where it is
connected.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 33 / 71
Mixer Process: PLC implementation
1 For the program to operate, the
controller is placed in the RUN mode.
2 During each scan the controller
examines the status of input devices,
executes the user program, and
changes outputs accordingly.
3 The coil O/1 is energized when
contacts I/1 and I/2 are closed or when
contact I/3 is closed.
4 Either of these conditions provides a
continuous logic path across the rung
that includes the coil.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 34 / 71
Mixer Process: PLC implementation-1
Source: Photo
courtesy Tyco
Electronics
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 36 / 71
Modified Program
1 If a relay system were used, it would require some rewiring of the circuit.
2 Original hardwired process control circuit modified.
3 If a PLC system were used, no rewiring would be necessary. The inputs and outputs
are still the same. All that is required is to change the PLC ladder logic program.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 37 / 71
Hardwired Stop/Start Motor Control Circuit
The term hardwired logic refers to logic control functions that are determined by the way
devices are interconnected.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 39 / 71
Programmed Stop/Start Motor Control Circuit
1 Each rung is a
combination of input
conditions connected
from left to right with the
symbol that represents
the output at the far right.
2 The input and output field
devices remain the same
as those required for the
hardwired circuit.
3 The instructions used are
the relay equivalent of
normally open (NO) and
normally closed (NC)
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 40 / 71
lader logic program
The most common PLC programming language is ladder logic .
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 41 / 71
Symbols used for Electrical Ladder Diagrams
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 42 / 71
ladder program
• A ladder logic program consists of several rungs, each of which controls an output.
• Each rung is a combination of input conditions (symbols) connected from left to right,
with the symbol that represents the output at the far right.
• Relationship between the relay ladder schematic, the ladder logic program, and the
equivalent logic gate circuit.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 43 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 44 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 45 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Two limit switches connected in parallel and used to control a solenoid valve.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 46 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Two limit switches connected in parallel with each other and in series with a pressure
switch to control a pilot light.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 47 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 48 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Two limit switches connected in series with each other and in parallel with two other limit
switches (in series), and used to control a pilot light.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 49 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 50 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Two limit switches connected in series with each other and in parallel with a third limit
switch, and used to control a warning horn.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 51 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 52 / 71
relay ladder schematic, ladder logic program, and
digital circuit
One limit switch connected in series with a normally closed pushbutton and used to
control a solenoid valve.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 53 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 54 / 71
relay ladder schematic, ladder logic program, and
digital circuit
The output lamp of this circuit is ON only when pushbutton A or B is pressed, but not both.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 55 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 56 / 71
relay ladder schematic, ladder logic program, and
digital circuit
When either start button is depressed, the motor runs. Either stop button stops the motor
when it is depressed.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 57 / 71
relay ladder schematic, ladder logic program, and
digital circuit
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 58 / 71
Programming Word Level Logic Instructions
Selecting Word Logic Instructions
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 59 / 71
Programmed AND Instruction
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 60 / 71
Programmed AND Instruction
This instruction tells the processor to perform an AND operation on B3:5 and B3:7 and to
store the result in destination B3:10 when input device A is true.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 61 / 71
Program simulation of the word level AND
instruction.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 62 / 71
Programmed OR Instruction
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 63 / 71
Programmed OR Instruction
This instruction ORs the data in Source A, bit by bit, with the data in Source B and stores
the result at the destination address.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 64 / 71
Programmed OR Instruction
Program simulation of the word level OR instruction.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 65 / 71
Programmed XOR Instruction
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 66 / 71
Programmed XOR Instruction
Data from input I:1.0 are compared, bit by bit, with data from input I:3.0. Any mismatches
energize the corresponding bit in word O:4.0.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 67 / 71
Programmed XOR Instruction
Program simulation of the word level XOR instruction
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 68 / 71
input A is true
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 69 / 71
Word-level NOT operation. The bit pattern in B3:10 is the result of the instruction being
true and is the inverse of the bit pattern in B3:9.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 70 / 71
Program simulation of the word level NOT instruction
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 71 / 71
Shift registers
Basic Concept:
A bit shift register is a register that allows the shifting
of bits through a single register or group of registers.
The bit shift register shifts bits serially (from bit to bit)
through an array in an orderly fashion.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 72 / 71
Types of shift registers:
BSL (Bit Shift Left) —Loads a bit of data into a
bit array, shifts the pattern of data through the array
to the left, and unloads the last bit of data in the
array.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 73 / 71
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 74 / 71
Applications of shift registers:
A shift register can be used to simulate the movement,
or track the flow, of parts and information. We use the
shift register whenever we need to store the status of an
event so that we can act on it at a later time.
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 75 / 71
Amar Khoukhi (revised and edited by Bashar Ahmad) ELE 2613 - Industrial Automation 20th August 2020 76 / 71