Sequential Function Chart
Sequential Function Chart
4
Programmable Logic
Control Systems
Version 2 EE IIT, Kharagpur 1
Lesson
21
Programming of PLCs:
Sequential Function
Charts
Version 2 EE IIT, Kharagpur 2
Instructional Objectives
After learning the lesson students should be able to
A. Describe the major features of the IEC 1131-3 standard for PLC programming
B. Describe the major syntax conventions of the SFC programming language
C. Identify valid and invalid SFC segments
D. Develop SFC programs for simple sequence control problems
Introduction
We have studied the RLL in a previous lesson. There are also other languages to program a PLC
in, than the RLL. Most of the significant manufacturers support about 3 to 5 programming
languages. Some of these languages, such as the RLL, have been in use for a long time. While
most manufacturers used similar languages, these were not standardised in terms of syntactic
features. Thus programs developed for one would not run in another without considerable
modifications, often mostly syntactic. In the last few years there has been effort to standardise
the PLC programming languages by the International Electrotechnical Commission (IEC). One
of the languages, namely the Sequential Function Chart, which offers significant advantages
towards development of complex structured PLC programs for concurrent industrial processes, is
studied in detail. Know other languages are introduced in brief.
International
Programmable
Controller
IEC 1131 is an international standard for PLCs formulated by the International Electrotechnical
Commission (IEC). As regards PLC programming, it specifies the syntax, semantics and
graphics symbols for the following PLC programming languages:
IEC 1131 was developed to address the industry demands for greater interoperability and
standardisation among PLC hardware and software products and was completed in 1993. A
component of the IEC 1131, the IEC 1131-3 define the standards for data types and
programming. The goal for developing the standard was to propose a programming paradigm
that would contain features to suit a large variety of control applications, which would eliminate
proprietary barriers for the customer and their associated training costs. The language
specification takes into account modern software engineering principles for developing clean,
readable and modular code. One of the benefits of the standard is that it allows multiple
languages to be used simultaneously, thus enabling the program developer to use the language
best suited to each control task.
Version 2 EE IIT, Kharagpur 3
variety of operations, and both users and vendors can create their own. A typical simple function
block is shown below in Fig. 21.1.
Raise switch
&
IV
Top LS OK
Loading
valve
Lower switch
&
&
Bottom LS OK
Pump running
Fig. 21.1 Combinational logic programmed with function blocks
start_cmd:
mul_op:
LD
ii 01
ADD
10
MUL(
i_gain
SUB
offset 01
)
ST
op 01
JMPNC mul_op
Point to Ponder: 1
A. Name one programming task for which, IL would be your chosen language.
B. Name one programming task for which, ST would be your preferred language over FBD.
C. For whom are the features code reusability and library support important, and why?
Steps
Each step is a control program module which may be programmed in RLL or any other
language. Two types of steps may be used in a sequential function chart: initial and regular. They
are represented graphically as shown below in Fig. 21.4.
(a)
(b)
Fig. 21.4 An initial step (a) and a regular step (b) in an SFC
The initial step is executed the first time the SFC block is executed or as a result of a reset
operation performed by a special function named SFC_RESET. There can be one and only one
initial step in an SFC. The initial step cannot appear within a simultaneous branch construct,
(which is described later in this section) but it may appear anywhere else.
A regular step is executed if the transitional logic preceding the step makes the step active. There
can be one or many regular steps in an SFC network, one or more of which may be active at a
time. Only the active steps are evaluated during a scan.
Each step may have action logic consisting, say, of zero or more rungs programmed in Relay
Ladder Diagram (RLD) logic language. Action Logic is the logic associated with a step, i.e., the
logic, programmed by RLL or any other logic, which is executed when the step is active. When a
step becomes inactive, its state is initialised to its default state. A collection of steps may be
labeled together as a macro-step.
Action
Step
(a)
(b)
Fig. 21.5 A step with action logic (a) and a macro-step (b) in an SFC
Transitions
Each transition is a program module like a step that finally evaluates a transition variable. Once a
transition variable evaluates to true the step(s) following it are activated and those preceding it
are deactivated. Only transitions following active states are considered active and evaluated
during a scan. Transitions can also be a simpler entity such as a variable value whose value may
be set by simple digital input. Transition logic can be programmed in any language. If
programmed in RLL, each transition must contain a rung that ends with an output coil to set its
transition variable.
S1
T1
S2
T2
S3
Fig. 21.6 Transitions connect steps in an SFC
The SFC in Fig. 21.6 shows how the transitions connect steps in an SFC. Initially, step S1 is
active. Thus transition T1 is also active. When the transition variable T1 becomes true,
immediately, S1 becomes inactive, S2 becomes active while T1 becomes inactive and T2
becomes active.
Point to Ponder: 2
A. What is the difference between a step of an SFC and a state of an FSM?
B. Why action logic is separately indicated from step logic, although both occur in the same
step?
C. How is the computation for step logic different from that of transition logic?
Simple Sequence
In a simple sequence, control passes from step S2 to step S3 only if step S2 is active and
transition T2 evaluates true.
S1
T1
S2
T2
S3
(a)
Version 2 EE IIT, Kharagpur 8
Scan
1
2
3
4
S1
A
I
I
I
T1
A
I
I
I
S2
I
A
A
I
(b)
T2
I
A
A
I
S3
I
I
I
A
T3
I
I
I
A
Fig. 21.7 A simple sequence in an SFC (a) and its execution over scans (b)
The table in Fig. 21.7 (b) indicates the status (A : active; I:inactive) of te steps and transitions
over scan cycles.
S1
T2
T1
S2
S3
S5
S4
T3
T4
S6
S1
T1
S2
S3
S5
S4
T2
S6
Fig. 21.11 Convergence of a simultaneous sequence
The transition logic for T2 is only executed when all of the steps at the end of the simultaneous
sequence are active.
cycle **
S1
T1
S2
T2
T3
jump *
S3
T4
jump **
S4
T5
cycle *
Fig. 21.12 Source and Destination Connectors
Many PLCs also allow SFCs to entered be as graphic diagrams. Small segments of ladder logic
can then be entered for each transition and action. Each segment of ladder logic is kept in a
separate program. The architecture of such programs is discussed next.
Point to Ponder: 3
A. Identify whether the SFC segments indicated in Figs. 21.13-21.15 are valid. If not, justify
your answer.
Cycle
S1
T1
S2
T2
S3
Cycle
Fig. 21.13
S1
T1
S2
S3
T3
T2
Cycle
S5
S4
S6
T4
S7
T5
S8
T6
Cycle
Fig. 21.14
Version 2 EE IIT, Kharagpur 13
S3
T2
S4
S5
T3
S6
S7
T4
S10
Fig. 21.15
Preprocessing
This section is processed at the start of every scan. Normally, RLD preprocessing logic is used to
process, at the start of the scan cycle, events which may affect the sequential processing section
of the program. These events may include:
Initialization;
Operator commands;
Resetting the SFC to the initial state.
Sequential Processing
This portion of the PLC scan consists of evolving the SFC to its next state and processing the
action logic of any steps that become active. Only the logic associated with active steps and
transitions is scanned by the PLC, leading to a significant reduction of scan time.
Post processing
This section is processed every scan after the SFC is complete. It may contain Relay Ladder
Diagram (RLD) logic to process safety interlocks, etc.
INPUTS
_MAIN
PROGRAM
BLOCK
OUTPUTS
SFC
BLOCK
1
SFC
BLOCK
2
SFC
BLOCK
3
Preprocessing
Sequential Processing
Post processing
Preprocessing
Sequential Processing
Post processing
Preprocessing
Sequential Processing
Post processing
Piston
Up
Solenoid
Down
Solenoid
Die
Part sensor: A position switch that detects when a part has been placed.
Stop PB: A push button to stop the machine while the piston is moving down.
Reset PB: After pressing Stop PB, this push button indicates that the machine is ready to
return to stamping in the auto mode.
Bottom LS: This sensor indicates the bottom position for the piston.
Top LS: This sensor indicates top position for the piston.
D. A Stop PB, if pressed, stops the press only when it is going down
E. If the Stop PB is pressed, the Reset PB must be pressed before the Auto PB can be
pressed
F. After retracting, the press waits till the part is removed and the next part is detected
Part
Removed
A
2
Power
B
Dn Sol on
Part hold
C
D
4
5
Power/light
off
Dn Sol off
Dn Sol off
Up Sol on
E
6
Up Sol off
Part hold off
Fig. 21.18 The State Diagram for the industrial stamping press
State No.
O/P
Auto Indicator
Part Hold
Up Sol
Down Sol
0
0
0
0
1
0
0
0
1
1
0
1
1
1
1
0
0
0
0
0
1
0
0
0
Fig. 21.19 The Output Table for the industrial stamping press
1
6
7
Part not
detected
1
Reset PB
Auto PB
Auto
Indicator on
2
2
Part detect
3
4
Stop PB
Bottom LS
Auto
Indicator off
Down Sol off
Down Sol on
Part Hold on
Up Sol off
Part hold off
Part hold
RLL for transition 3
Bottom LS
EOT Step 2
Point to Ponder: 4
A. Develop an SFC for a two person assembly station. The station has two presses that may
be used at the same time. Each press has a cycle button that will start the advance of the
press. A bottom limit switch will stop the advance, and the cylinder must then be
retracted until a top limit switch is hit.
B. Create an SFC for traffic light control. The lights should have cross walk buttons for both
directions of traffic lights. A normal light sequence for both directions will be green 16
seconds and yellow 4 seconds. If the cross walk button has been pushed, a walk light will
be on for 10 seconds, and the green light will be extended to 24 seconds.
C. Draw an SFC for a stamping press that can advance and retract when a cycle button is
pushed, and then stop until the button is pushed again.
D. Design a garage door controller using an SFC. The behavior of the garage door
controller is as follows,
a. there is a single button in the garage, and a single button remote control
b. when the button is pushed the door will move up or down.
c. if the button is pushed once while moving, the door will stop, a second push will
start motion again in the opposite direction.
d. there are top/bottom limit switches to stop the motion of the door.
e.
there is a light beam across the bottom of the door. If the beam is cut while the
door is closing the door will stop and reverse.
f. there is a garage light that will be on for 5 minutes after the door opens or closes.
Point to Ponder: 2
A. What is the difference between a step of an SFC and a state of an FSM?
Ans: A step of an SFC denotes a computation module which gets executed cyclically, as long
as the step is active. A state of an FSM is an instantiation of the values of its state variables.
Note that a step in the SFC can represent a possibly cyclic subgraph of an FSM through
which the FSM moves during the time the step is active. In the simplest case, a step of an
SFC represents one state of an FSM.
B. Why action logic is separately indicated from step logic, although both occur in the same
step?
Ans: The computation within a step can be of two types, namely, those that update internal
state variables other than outputs and those that update the outputs which are exercised on
physical outputs. The second type of computation is named action logic and explicitly
indicated at the steps. Since the physical outputs are of final importance, these are separately
indicated for each step.
C. How is the computation for step logic different from that of transition logic?
Version 2 EE IIT, Kharagpur 21
Ans: Systems are supposed to spend time in the states. Transitions are instantaneous and
merely indicate conditions under which systems change from one state to another. In an SFC,
at any point of time, a number of steps and transitions are active. However, the computations
of the steps can update output variables in the action logic while the computations in the
transitions cannot.
Point to Ponder: 3
A. Identify whether the SFC segments indicated in Figs. 21.13-21.15 are valid. If not, justify
your answer.
Ans:
a. The SFC in Fig. 21.13 is invalid because a backward jump connects the two states S3
and S1 without an intervening transition. This is illegal. Any two steps in an SFC
must contain an intermediate transition.
b. The SFC in Fig. 21.14 is invalid because there is a jump into one of the branches of a
simultaneous sequence. This is illegal, since the steps in the other branches of the
simultaneous sequence are indeterminate.
c. The SFC in Fig. 21.15 is valid.
Point to Ponder: 4
E. Develop an SFC for a two person assembly station. The station has two presses that may
be used at the same time. Each press has a start cycle button that will start the advance
of the press. A bottom limit switch will stop the advance, and the cylinder must then be
retracted until a top limit switch is hit.
1.
Master
4
Start button #1
press #1 adv.
Start button #2
5
press #1 retract
press #1 off
press #2 adv.
press #2 retract
Top limit switch #2
press #2 off
F. Create an SFC for traffic light control. The lights should have cross walk buttons for both
directions of traffic lights. A normal light sequence for both directions will be green 20
seconds and yellow 10 seconds. If the cross walk button has been pushed, a walk light
will be on for 10 seconds, and the green light will be extended to 30 seconds.
2.
Start
EW crosswalk button
Red NS, green EW
walk light on for 10s
30s delay
NO EW crosswalk button
Red EW, green NS
20s delay
10s delay
NS crosswalk button
Red EW, green NS
walk light on for 10s
30s delay
NO NS crosswalk button
Red NS, green EW
16s delay
4s delay
G. Draw an SFC for a stamping press that can extend and retract when a cycle button is
pushed, and then stop until the button is pushed again.
3.
Start
idle
Cycle button pressed
extending
Advance limit switch made
retracting
Retract limit switch made
H. Design a garage door controller using an SFC. The behavior of the garage door
controller is as follow.
a. There is one button inside the garage, and one button remote control.
b. When either of the buttons are pushed the door will move up or down.
c. If the button is pressed once while moving, the door will stop, a second press will
start motion again in the opposite direction.
d. There are top/bottom limit switches to stop the motion of the door when it reaches
either of the two ends.
e.
There is an infrared beam across the bottom of the door. If the beam is
interrupted while the door is closing the door will stop and reverse.
f.
There is a garage light that will be on for 5 minutes after the door opens or
closes.
4.
1
2
T1
Garage or Remote
button pressed
3
T3
T2
Light beam
interrupted
Close door
4
T4
Garage or Remote
button pressed
5
T5
Open door