NOT Gate
AND Gate
OR Gate
NAND Gate
By DeMorgan’s Thm.
NOR Gate
Ex-OR Gate
Ex-NOR Gate
/https://drstienecker.com/tech-332/3-logic-circuits-boolean-algebra-and-truth-tables
https://engineeronadisk.com/V2/book_integration/
engineeronadisk-77.html
Ladder diagram examples
://www.sanfoundry.com/100-plc-programming •
mples/
Very good-above •
https://www.plcacademy.com/ladder-logic-example •
s/
mentationtools.com/ladder-logic-progr •
mples/
Nice explanation of ladder diagram- objecting sorting
https://www.youtube.com/watch?v=86CrhxgAKTw •
Good Explanation of 4 languages, timer and counters
https://www.youtube.com/watch?v=Re8RSPCZQn0
Learning Objectives
• Understand various programming techniques
used for PLC
• Be able to compare various PLC programming
languages
• Be able to use ladder diagram programming
for basic logic functions
Programming PLC
• Programming a PLC means writing instructions
(or program) that tells the PLC what to do.
• The program is entered through programming
device (may be PC also) and downloaded into
the PLC memory.
Ladder
Diagram
Graphical Function
Block Diagram
PLC programming
Instruction
Languages
List
Text
Structured
Based
Text
Graphic Sequential
Chart Function chart
Instruction List (IL)
• It is the most fundamental programming language
for PLC.
• It uses very simple instructions similar to the
original mnemonics like used in assembly
language programming.
• It is not supported in RSLogix5000.
Mnemonic Function Description Ladder Equivalent
LD/STR Load/start Starts a logic sequence with a
NO contact
LRN/STRN Load/start Starts a logic sequence with a
not NC contact
AND And point Makes a NO contact series
connection
OR Or point Makes a NO contact parallel
connection
OUT Energize coil Terminates a sequence with
an output coil
Instruction List (IL)
LD A
OUT X
LD A
AND B
ST X
LD A
ANDN B
OUT X
LD A
OR B
AND C
OUT X
LD A
LD B
OR C
OUT X
LD A
OR B
LD C
OR D
OUT X
PLC programming languages
IL : Instruction List - statement list
It uses very simple instructions similar to the original mnemonic programming
languages developed for PLCs.
(Note: some readers will recognize the similarity to assembly language programming.)
It is the most fundamental level of programming language - all other programming
languages can be converted to IL programs.
Most programmers do not use IL programming on a daily basis, unless they are using
hand held programmers.
23
PLC programming languages
IL : Instruction List - statement list
24
PLC programming languages
IL : Instruction List - statement list
25
PLC programming languages
ST: Structured Text
26
PLC programming languages
ST: Structured Text
Programming has been developed as a more modern programming
language. It is quite similar to languages such as BASIC and Pascal.
Structured Text (ST) is a high level textual language that is a Pascal like
language. It is very flexible and intuitive for writing control algorithms.
Benefits of Structured Text
1. People trained in computer languages can easily program control logic
2. Symbols make the programs easy to understand
3. Programs can be created in any text editor
4. Runs as fast as ladder logic
IF StartPb THEN
; Siren := NOT Level_Switch Motor := 1;
END_IF;
IF StopPb THEN
Motor := 0;
;Light := SwitchA OR SwitchB END_IF;
27
PLC programming languages
ST: Structured Text
; Siren := NOT Level_Switch
28
Assignment Statement
• VariableName : = value ;
• VariableName : = variable ;
• MotorSpeed : = 25 ;
• C1.Reset : = T1.DN ;
• T1.Preset : = 5000 ;
• Pressure := force/area ;
If-then-else structure
ST syntax for Timers
• Let the timer is T1, preset 2000, enabled by
O1, reset by switch S1.
TONR (Mixing) ;
Mixing.TimerEnable : = O1 ;
Mixing.Preset := 2000 ;
Mixing.Reset := S1;
ST syntax for Counters
• Let the counters is C1, up-counter, preset 10,
enabled by T1.DN , reset by switch S1.
Count up and down together
CTUD (C1) ;
C1.CUEnable : = T1.DN ;
C1.Preset := 10 ;
C1.Reset := S1;
Structured Text
• This language is more modern and uses structured text.
• Its structure is similar to Pascal or C language.
• It is very flexible language useful for writing control algorithm.
• Example 1:
J:=1
WHILE J<=100
J:=J+2
END_WHILE
:Example 2
for( a = 10; a < 20; a = a + 1 )
{
printf ("value of a: %d\n", a);
}
Function Block Diagram (FBD)
• In this language, the functions are written in
the form of blocks
• The data flow starting from the inputs, passes
from the blocks and generates the output.
Input Function Output
auto & => run
start AND gate 1gate
OR
manu &
cmd AND gate
• https://www.solisplc.com/tutorials/function-block-
programming
PLC programming languages
FBD: Function Block Diagram
FBD
is another graphical
.programming language
The main concept is the
data flow that start from
inputs and passes in
block(s) and generate the
.output
40
Ladder Logic
Function Block
PLC programming languages
FBD: Function Block Diagram
Inputs A and B are used to calculate a value sin(A) * ln(B). The result of this
calculation is compared to C
43
Ladder Diagram
• It is the most widely used programming language for PLC.
• Ladder diagram consists of two vertical lines representing two power rails
between which the circuits are connected.
• The horizontal line is called rung and each rung represents an operation in
the control process.
• A ladder diagram is read from left to right and top to bottom as shown in Fig
1.
Outputs
Inputs In the form of coil for
In the form of contacts motor, lamp, alarm etc
for switch, sensor etc
Fig 1: Ladder
diagram
structure
/scanning
Relay Symbol
Coil
:Basic Instructions/symbols in Ladder Diagram
1- Examine if closed (XIC) (Normally Open)
This instruction checks whether input is activated, if yes, it’s state becomes 1
Examine if closed (XIC) )Normally Open(
2- Examine if Open (XIO) (Normally Closed)
This instruction checks whether input is deactivated, if yes, it’s state becomes 0
Examine if Open (XIO) )Normally Closed(
3- Output Coil
This instruction for activating output, if all conditions are true, output is activated.
Contact Not activated Activated
XIC (NO)
0 1
XIO (NC)
1 0
Rules for Ladder Diagram Logic
• A live common vertical bus is provided along the LHS of the diagram.
• All horizontal logic lines are derived from this.
• Each rung must start with an input (or inputs) and must end with an output.
• Each line starting from the left bus must end in a coil, special function block or several
parallel coils.
• Output coils may have as many auxiliary contacts as required. Each auxiliary contact may
be configured as normally open or normally closed.
• Each output coil can appear only once in a program.
• A designated contact must not be placed to the right of a coil.
• All contacts & coils are numbered to indicate which device (or PLC I/O channel) they are
associated with.
• PLC output coils may be programmed as contacts, but contacts can not be programmed as
Advantages/Features of Ladder Diagram Programming
• It is a graphical language.
• It is one of the most widely used programming
languages for PLC.
• Easier to read (same like electrical diagram)
• Debugging is easy.
• It provides real time data and feedback.
• It provides “Live” or “Real Time” data.
• It contains/supports powerful instructions like
timer, counter, shift, mathematics and logic etc.
Sequential Function Chart (SFC)
• This method is used for more advanced (or
complex ) systems.
• Used for writing concurrent control programs
• Main components of SFC are:
Steps with associated actions
Transitions with associated logic conditions
Actions/Directed links between steps and
transitions
Stage (Step)
Each stage indicates the state of the process. A step can be active
.or inactive
.The stages involve associated actions
Each stage is identified with a number that must be unique and
not it must necessarily keep an order consistent with the sequence
. of the process
Transition
In between two steps, a transition is a
step represented by a horizontal line
across a vertical line. It is containing the
logic condition allowing the transfer from
.one step to another
Transitions are associated with a
condition, these can be a logical function
.of variables of input and internal system
a transition not only can have one input
step and one output step but also can
have more input steps and more output
.steps, connected by the directed links
Actions
The actions associated with the
stages are represented by a rectangle
sidebox where the type of action to
be carried out is indicated (only the
active ones). A stage can have one or
.more actions associated with it
Merits of SFC
.Similar to a flow chart •
.Useful for sequential control operations •
.Shows the main states of a system •
.SFC shows all possible status changes •
Examine if closed (XIC) instruction
It is similar to Normally open contact
Examine if Open (XIO)
.It is similar to normally closed
It checks whether the contact
Output Latching (L)
• The term latching means the relay remains
open or closed even after the power has been
removed.
• The output latches the input so that the
output can continue even if the input is
removed.
PL
Fig 2: Hardwired logic circuit and its PLC ladder language implementation
Advantages of Ladder Diagram
Logic Functions
• There are many control situations requiring action
to be initiated when certain combination of
conditions are fulfilled.
• Basic logic functions are AND, OR and NOT
functions.
OR gate application
Wherever the occurrence of any one or more than one event is needed to be detected or some actions are to be
taken after their occurrence, in all those cases OR gates can be used. It can be explained with an example. Suppose
in an industrial plant if one or more than one parameter exceeds the safe value, some protective measure is
needed to be done. In that case OR gate is used. We are going to show this with the help of a diagram.
/http://electrical4u.com/some-common-applications-of-logic-gates
AND gate
It is a circuit that performs logical AND operation on inputs
and produces an output.
Description
Output Y is High only if ALL inputs are High.
Output will be Low even if one input is Low.
A
Logic Symbol AND Y
B
INPUTS OUTPUT
A B Y
0 0 0
Truth Table 0 1 0
1 0 0
1 1 1
AND Gate Truth Table
AND Symbol
Boolean Expression Y = A • B = AB
Fig :PLC ladder diagram for AND gate
OR gate
It is a circuit that performs logical OR operation on inputs
Description and produces an output.
Output Y is High if any one input is High.
Output will be Low if ALL inputs are Low.
A
Logic Symbol OR Y
B
INPUTS OUTPUT
A B Y
0 0 0
Truth Table 0 1 1
1 0 1
1 1 1
OR Gate Truth Table
OR Symbol
Boolean Expression Y=A+B
Fig: OR gate ladder diagram
NOT gate (inverter)
Description Output Y is High if input A is Low .
i.e. Y is the inverse of A.
Logic Symbol A NOT Y
INPUT OUTPUT
Truth Table
A Y
0 1
1 0
NOT Gate Truth Table
_
Bar A
A
Boolean Expression Y=A
http://www.bbc.co.uk/schools/gcsebitesize/design/electronics/logicrev3.shtml
NAND gate
.NAND gate performs inverse action of AND gate
.Output of NAND gate will be High even if one input is High
Description .Output Y is Low if ALL inputs are High
A bubble is an inverter
A
Logic Symbol NAND Y
B
INPUTS OUTPUT
A B Y
0 0 1
Truth Table 0 1 1
1 0 1
1 1 0
NAND Gate Truth Table
Boolean Expression Y = AB
Learning Objectives
• Understand the Door Control using PLC
completely
• Develop the ladder diagram logic to control the
door
• Test and Debug the ladder diagram logic to
control the door
Door Shutter Control
Objective:
To design a ladder diagram using examine on and examine off
instructions to Control forward /reverse motor.
Devices:
Normally closed stop push button (I:1/02).
Normally open push button to open the shutter (I:1/00).
Normally open push button to close the shutter (I:1/01).
Limit switch to stop opening (I:1/03).
Limit switch to stop closing (I:1/04).
Motor, opening direction (O:2/00).
Motor, closing direction (O:2/01).
• Design a ladder diagram to close and open the shutter.
• (I:1/02) stops the shutter at any position.
• (I:1/00) opens the shutter until (I:1/03).
• (I:1/01) closes the shutter until (I:1/04).
• Motors should not run at the both directions at a time, (inter-lock is
required).