Sequential Logic Design
Star Delta switch
L1
L2
L3
C1 A1_C1
Mains Contactor
C3
Delta Contactor
A1_C3
M C2
Star Contactor
A1_C2
State diagram design of the Y-D example
Problem !
Stop
Stop
Stop
Star Delta
Rest
Start Timer[Dt]
S1 S2 S3
A1_C3
C1 C1
A1_C1 C2
Stop
+A1_C2
C3
Timer
+A1_C3 A1_C2
S4 Alarm
Fault
In practice, It is better to use the
normally closed contacts (NC) for
Auxiliary contacts feedback. However,
using the NO instead is easier in
programming and debugging
State diagram design of the Parking Lot example
Card Reader
Or
Ticket machine Photo detector
Entrance
Timer1[Dt]
Timer1[Dt]
stayopen Ph1
Ph1
S4 Ph1↓
In_gate wait In_gate
Rest wait
In_key.Cout[n] Ph1↓ Rest In_gate
S1 S2 S3 In_key.Cout[n] Ph1↓
S1 S2 S3
In_gate Timer1 In_gate Timer1
Count_up Count_up
State diagram design of the Parking Lot example
In_gate Fwd
Drive
Rev Circuit M
bar_up bar_down
bar_down
Open Idle Close
Rest
In_gate bar_up In_gate
S1 S2 S3 S4
Drive_Fwd Drive_Rev
Reversing DC Motor Direction (H-Bridge)
Reversing DC. Motor Motion Using Relays
RA Use of hardware Interlocks to avoid
RB supply short circuit!!
RA
RB
RB RA
RA RB
bar_down
RB RA
Re_open_cmd
Open Idle Close
Rest
Open_cmd bar_up Close_cmd
S1 S2 S3 S4
Drive_Fwd Drive_Rev
(RA) (RB)
I/O Assignment
Inputs Address Description Outputs Address Description
In_key In_gate Can be used for flashing light
Ph1 Out_gate Can be used for flashing light
Bar1_up Lot_full Parking status indicator
Bar1_down RA1 In gate Drive forward
Out_key RB1 In gate Drive reverse
Ph2 RA2 Out gate Drive forward
Bar2_up RA2 Out gate Drive reverse
Bar2_down
Scan Cycle Nature
1- I/O Refresh (most common)
Max delay ~2 Scan Cycles
1 Scan Cycle
R E W R E W
Read Execute Logic Write Read Execute Logic Write
Inputs Outputs Inputs Outputs
A Change in input - here Change in input read hear Output due to the
Change in input
2- I/O Direct Access
Max delay ~1 Scan Cycles
1 Scan Cycle
R E WR EW R E WR E W R E W R E WR EW R E WR E W R E W
A Change in input - here Change in input read hear
Output due to the
Change in input
Implementation in different I/O modes
Ladder order is important 3 States Example
𝑆1 = 𝑆1 + 𝑖𝑛𝑖𝑡𝑎𝑡𝑖𝑜𝑛 + 𝑆𝑡𝑜𝑝 + 𝑆3. 𝑇 . 𝑆2. 𝑇
𝑆2 = 𝑆2 + 𝑆1. 𝑇 . 𝑆3. 𝑇
𝑆3 = 𝑆3 + 𝑆2. 𝑇 . 𝑆1. 𝑇
𝑂𝑢1 = 𝑆2
𝑂𝑢2 = 𝑆2
𝑂𝑢3 = 𝑆3
𝑂𝑢4 = 𝑆3
I/O Refresh Direct Access
Interface Relays
PLC output module 380 Vac
24 Vdc 220 Vac
- + Auxiliary contact
Pre-Actuator
M
Interface relay
Actuator
3-phase Motor contactor
Grafcet
Sequential function Charts (SFC)
Using IEC-1131-3
PLC Programming Languages
Graphical languages
• ladder diagrams (LD)
• function block diagram (FBD)
Text-based languages
• instruction list (IL)
• structured text (ST)
Different Programming
Languages
Example:
Activate valve 3 if it the start of cycle
and Limit switch 1 is pressed.
Inputs : Start_Cycle
Limit_S_1
Output : Valve_3
Programming Using
Grafcet/Sequential Function Charts (SFC)
1- Ladder Diagram
Start Stop Motor A
Motor A
2- Grafcet
Transition
Start
1 Motor A=1
Stop
State
PLC Programming
3- Using statement list
LD X100 ; Start
ORB Y200 ; MotorA
ANDI X101 ; Stop
OUT Y200 ; MotorA
4- Using Function Blocks
Start
Motor >= Motor
Stop &
5
Grafcet - SFC
Grafcet (Graphe Fonctionnel de Commande Étape Transition) is a symbolic,
graphic language, which originated in France, that represents the control
program as steps or stages in the machine or process.
The English translation of Grafcet means “step transition function charts”.
Grafcet is the foundation for the IEC 1131 standard’s sequential function charts
(SFCs), which allow several PLC languages to be used in one control program.
Similarity with Flow Charts
Reactor Vessel Tank Example
Filling
Stirrer
Draining
Heater
Main SFC Features
Initial state
Start Transition
Start switch=1
Filling
Fill State
Stirrer
Vessel Full=1
Draining
Stir &Heat Heater
Temp = 80 C
No alternate transitions
Drain No simultaneous states
Start switch=0
Divergent path
Start
Start switch=1
Fill
Vessel Full=1
Stir
Temp = 80 C
Drain
Start switch=0 Start switch=1
Simultaneous Sequences
Start
Start switch=1
Fill Simultaneous sequence divergence
Vessel Full=1
Stir Chk Temp
Tr1 Tr2 Monitor
Drain Chk Press
Start switch=0
Simultaneous sequence convergence
State & Transition
The step active flag .X (read dot X) is a boolean
variable that is only set true while a particular step
is active.
Initial
State.X
State
Transition
State Action Box
Transition
The step elapsed time .T (read dot T) is variable of
data type TIME. The variable record the elapsed time
by the state..
Action box
Indicator Variable
Action qualifier Action Optional
SFC actions qualifiers
‘N’ non-stored action qualifier
Standards rules allows execution of
the action one final time after falling
edge of .X flag so that action variables
can reset certain variables after an
action block has been deactivated.
Amendments to the standards are
being considered
‘S’ set and ‘R’ reset qualifiers
‘L’ qualifiers
‘D’ time delay qualifier
‘P’ pulse qualifier
‘SD’ stored and time delay action qualifier
‘DS’ time delay and stored action qualifier
‘SL’ stored and time limited action qualifier
Precedence
Mutually exclusive divergent paths
Special forms of divergent paths
Simultaneous convergence
Incorrect branching
Unreachable state and solution
Tank Filling
Reservoir
V1 V2
h1 h2
Tank 1 Tank 2
b1 b2
W1 W2
Tank Filling
Description: Reservoir
• If push button m is pressed, both tanks are
filling by opening valves V1 (V1=1 means
opened) and V2.
• When a tank is full, e.g., tank1, filling stops V1 V2
(by closing V1) and its contents start to be used h1 h2
(by opening W1). Tank 1 Tank 2
• When tank 1 is empty, valve W1 is closed b1 b2
• Both tanks are used in a similar way.
W1 W2
• Tank 1 is empty when the level is less than b1,
i.e., b1=0, and full when level is greater than
h1, i.e., h1=1.
• At the initial state both tanks are empty.
State transition diagram Reservoir
b2 1 b1 V1 V2
m
h1 h2
V1.V2 Tank 1
h1 2 Tank 2
h2 b1 b2
V2.W1 V1.W2 W1
3 4 W2
h2 h1
b1 5 W1.W2 b2
V2 6
b1 b2 7 V1
h2 h1
W2 8 9 W1
Solution
1 4
2 V1 5 V2
h1 h2
3 W1 6 W2
b1 b2
Solution Reservoir
V1 V2
h1 h2
Tank 1 Tank 2
1 4 b1 b2
W1 W2
m m
2 V1 5 V2
h1 h2
3 W1 6 W2
b1 b2