Course T300, Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
TABLE OF CONTENTS
Chapter 11 Sequential Function Chart (SFC).............................................................................................................................. 11-1
11.1 General Information......................................................................................................................................................... 11-3
11.1.1 Description ................................................................................................................................................................ 11-3
11.1.2 Objectives.................................................................................................................................................................. 11-3
11.1.3 Reference Documentation......................................................................................................................................... 11-3
11.1.4 Steps to go ................................................................................................................................................................. 11-3
11.2 SFC Handling................................................................................................................................................................... 11-4
11.2.1 Create SFC ................................................................................................................................................................ 11-4
11.2.2 Copy / Paste SFC ...................................................................................................................................................... 11-4
11.2.3 Delete SFC ................................................................................................................................................................ 11-4
11.2.4 Insert Branch ............................................................................................................................................................. 11-4
11.2.5 Delete Branch............................................................................................................................................................ 11-6
11.3 SFC Language.................................................................................................................................................................. 11-8
11.3.1 General ...................................................................................................................................................................... 11-8
11.3.2 The SFC Editor ......................................................................................................................................................... 11-8
11.3.3 Sequential Rules...................................................................................................................................................... 11-10
11.3.4 Sequence Constructs ............................................................................................................................................... 11-10
11.3.5 Online Functions ..................................................................................................................................................... 11-12
11.4 Advanced Sequence Constructs..................................................................................................................................... 11-14
11.4.1 Simultaneous Sequences......................................................................................................................................... 11-14
11.4.2 Sequence Selection ................................................................................................................................................. 11-14
11.4.3 Jumps and Destinations .......................................................................................................................................... 11-14
11.4.4 Subsequence............................................................................................................................................................ 11-14
11.5 Sequence Control Variables........................................................................................................................................... 11-15
11.5.1 Automatically Generated Variables........................................................................................................................ 11-15
11.5.2 Step Timing Variables ............................................................................................................................................ 11-15
11.5.3 Different Methods for Activating Outputs ............................................................................................................. 11-16
11-1
Course T300, Engineering an 800xA System
11-2
Engineering an 800xA System
11.1 General Information
11.1.1 Description
This chapter describes the use of the SFC.
11.1.2 Objectives
On completion of this chapter you will be able to:
Describe the use of SFC.
Describe the sequential rules.
Use online functions of SFC.
Use sequence constructs.
Use the different Sequence Control Variables.
11.1.3 Reference Documentation
Use the online help: Contents tab, Sequential Function Chart Editor
11.1.4 Steps to go
1. Create a new program or single control module
2. Open the POU (Program Organization Unit) editor
3. Change the language of the POU editor to SFC
4. Create the chain
5. Program the steps and transitions
6. Save the chain
7. Test the chain
11-3
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
11.2 SFC Handling
11.2.1 Create SFC
1. Open a program in the Control Builder
2. Create a new code page for the program and select as language Sequential
Function Chart.
11.2.2 Copy / Paste SFC
Select a transition, step or a whole branch and copy it. Then paste it in the same or
another SFC codeblock.
11.2.3 Delete SFC
You have to delete the whole code page where the SFC exists.
11.2.4 Insert Branch
1. Open the context menu for this transition where you want to insert the new
branch after.
11-4
Engineering an 800xA System
Right
click
2. Select the entry Step, Transition to insert a new step with its transition
3. Insert a Simultaneous Sequence after the transition Tr2.
11-5
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
11.2.5 Delete Branch
For deleting a branch you have to select the step and the transition.
1. Mark the Simultaneous Sequence (S3, S4 and Tr3) by click and hold the left
mouse button and moving a rectangle around the simultaneous sequence.
2. Open the context menu for the transition Tr3 and select the entry Delete.
11-6
Engineering an 800xA System
11-7
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
11.3 SFC Language
11.3.1 General
The Sequential Function Chart (SFC) programming language allows the user to
describe the sequential behavior of the control program graphically. This concept
enables all control actions for a process to be described in one compound sequence
structure even if it involves several parallel action chains. Furthermore, sequences can
be hierarchical, that is action chains can be grouped to give a clear high level
presentation of the process control unit.
A sequence is a unit with a complete sequence surrounded by an unconditional loop;
the first step is reactivated when the sequence is finished. A sequence can be divided
into separate types of structures. There are two types of structures, sequence selection
and simultaneous sequence. It is possible to structure the sequence view into several
hierarchical levels with the subsequence function.
11.3.2 The SFC Editor
The SFC programming editor is divided into four panes, the declaration pane, code
pane, structure pane, and the message pane. The declaration pane, the code pane (see
also below), the message pane, the toolbar and commands in the menu bar, concerning
the code are the same as in the other language program editors.
11-8
Engineering an 800xA System
11.3.2.1 SFC Toolbar
There is a special toolbar in the Sequence Function Chart editor, with shortcuts to
many of the commands found in the menu bar (or in the pop-up menus). You can see a
brief explanation of each button, if you hold the cursor over the button.
Toolbar
button
Menu Command
Description
Insert > Step, Transition
Inserts a step and transition after the
current selection.
Insert > Sequence Selection
Inserts a sequence selection after the
current selection.
Insert > Simultaneous Sequence
Inserts a simultaneous sequence after
the current selection.
Insert > New Branch
Inserts a new branch.
Insert > Jump
Inserts a jump.
Tools > Make Subsequence
Turn the selected steps and transitions
into a subsequence.
Tools > Dissolve Subsequence
Dissolves the selected subsequence.
View > Step into Subsequence
Steps into the selected subsequence.
11-9
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
View > Step Out of Subsequence
Steps out of the open subsequence.
11.3.2.2 Structure Pane
All the graphical editing of the sequence structure are performed in the structure pane.
You will be able to add, delete, move and modify steps, transitions, actions,
simultaneous sequence, sequence selections, and jumps.
The basic editing principles are to first select an item and then choose a menu
command, for example, if a transition is selected and then the Step, Transition menu
command is chosen, a step and a transition is added below the selected transition. All
menu commands perform different actions depending on currently selected item.
11.3.3 Sequential Rules
The sequence loop is always closed. The last transition is always connected to the first
step. The execution continues from the last step to the first step when the last
transition condition becomes true.
11.3.4 Sequence Constructs
The basic elements in a sequence are steps and transitions. Each step can have three
associated actions. Each transition has an associated boolean transition condition. A
transition can be a jump that enables the execution order to be changed. The jump
destination can be a step forward or backward in the sequence. An action is a code
block. An action qualifier specifies how and when the action code shall be executed.
Below is an example with sequence selection and simultaneous sequence.
11.3.4.1 Steps
A step is a basic element, which is activated by its preceding transition.
The step becomes active until its succeeding transition is true, and then
next step is activated.
Each step has a name, that can be changed, and each step can have up
to three associated set of actions.
11.3.4.1.1 Initial Step/Step
Each sequence has one initial step. The initial step becomes active at a
cold start of the application(s) or when the sequence is reset by the
SequenceName.Reset variable.
11.3.4.2 Action
An action is a code block, written in the Structured Text (ST). An action can have an
action qualifier, specifying how and when the action code is to be executed. The
names of the actions are automatically generated. The actions will be named step
name_action qualifier, for example, see figure below. If the step name is
changed, the action names are automatically changed. It is not possible to change the
action names.
11-10
Engineering an 800xA System
There are three different action qualifiers:
The N action qualifier stands for Non-stored, and means that the action code is
executed continuously, while the step is active.
The P1 action qualifier stands for Pulse rising edge, and means that the action code
is executed once, when the step becomes active.
The P0 action qualifier stands for Pulse falling edge, and means that the action
code is executed once, when the active step becomes inactive.
Using the ST language, you write code in the code pane for each of the three action
boxes. Any of the three may be left empty or even deleted. Each action can execute
any number of statements.
11.3.4.3 Transitions
The transition from one step to the next, is controlled by transition conditions, which
are boolean expressions including process signals.
11.3.4.3.1 Transition Condition
It is possible to rename a transition condition. When the next sequence step is
activated, its associated statements are executed and the previous ones are disabled. A
transition contains a condition. When the condition is true AND the preceding step is
active the following takes place:
The preceding step(s) is deactivated.
The succeeding step(s) is activated.
The state of the sequence changes, when a transition condition becomes true. The
sequence evolution is controlled by Sequence Control Variables (for example,
StepName.X and StepName.Reset).
When a transition condition becomes true and the preceding step(s) is active (that is,
the transition can fire), the actions are executed in the following order during that
scan:
The N action of the deactivated step runs its final scan
The P0 action of the deactivated step that is activated one scan
The P1 action of the activated step that is activated one scan
The N action of the activated step is activated cyclically
During scans when no transition condition becomes true, only N actions associated to
active steps will execute. A step is active when the step variable (discussed later)
StepName.X is true
11-11
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
11.3.5 Online Functions
In online mode, the code and the variable values are displayed in the program editor.
Online commands in the menu bar and toolbar buttons concerning the code are the
same as in the other language program editors. There are functions only available in
the online mode. Some of them are:
Disable Actions
Show Actions
Block Transitions
Block All Transitions
Reset
Force Forward
Force Backward
Show All Actions
Hide All Actions
Use the online help to read about the online functions.
11.3.5.1 Toolbar in Online Mode
The following specific online mode toolbar buttons (each with its corresponding menu
command) exist:
Toolbar
button
11-12
Menu Command
Description
Tools > Disable Actions
Disables the associated actions of the
selected step (toggle command). No action
code executes when the step is active. All
actions associated to the step are blocked
(shut off).
Tools > Block Transition
Blocks the selected transition (toggle
command). The transition condition is
regarded as False. When a transition is
blocked, the execution cannot continue in
the next step.
Tools > Force Forward
Moves the execution, from the step before
the selected transition, to the step after the
selected transition, though the transition
condition is not evaluated. The execution
continues in the step after the selected
transition.
Tools > Force Backward
Moves the execution, from the step after the
selected transition, to the step before the
selected transition, though the transition
condition is not evaluated. The execution
continues in the step before the selected
transition.
View > Step into
Subsequence
Steps into the selected subsequence.
Engineering an 800xA System
View > Step out of
Subsequence
Steps out of the open subsequence.
11-13
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
11.4 Advanced Sequence Constructs
11.4.1 Simultaneous Sequences
The simultaneous sequence structure allows simultaneous and independent execution
of two or more branches of sequence actions. The transition cannot activate its
succeeding step unless the last step of both branches is active. When the transition
condition that precedes the simultaneous sequence structure becomes true, all the
branches are started simultaneously, that is, the execution continues in every branch.
The transition, that succeeds the simultaneous sequence structure, cannot fire until all
the branches have finished, that is, when the last step of each branch is active.
11.4.2 Sequence Selection
To choose one sequence branch among two or more, the sequence selection is used.
When one of the first transition conditions become true, that branch is selected and the
execution continues in that branch. The execution can only continue in one of the
branches. The branch with the highest priority and a true transition condition will be
chosen (graphically, the left to right branch order corresponds to the priority order,
that is. The leftmost branch has the highest priority).
11.4.3 Jumps and Destinations
Unstructured links inside the sequence structures are necessary in some cases to deal
with extraordinary situations and when, for example, changing the process production
mode. A jump is a link from a named single transition to a named single step, located
anywhere in the same sequence structure. It is allowed to have more than one jump
connected to a step. A jump can be considered as a sequence selection. A jump is a
transition where the execution is transferred from the preceding step to the jump
destination step, when the transition condition becomes true.
11.4.4 Subsequence
For documentation and overview reasons, it is sometimes convenient to graphically
structure the sequence into smaller parts, subsequences, thus hiding details until they
are requested. The subsequence is usually put around a sequence part, which performs
a set of logically related actions. The subsequence function is a way to structure the
sequence using a graphic hierarchy. The sequence can be graphically structured into
any number of hierarchical levels.
11-14
Engineering an 800xA System
11.5 Sequence Control Variables
There are facilities to control a sequence and monitor the timing of sequence steps.
When these functions are used, automatically generated variables are available for use
in the code.
11.5.1 Automatically Generated Variables
For one sequence, the following variables are automatically generated when the
program is compiled.
Name
Type
Menu
Access*
SequenceName.Reset
Bool
Yes
The sequence is reset to the initial
step. The system resets this variable
automatically to False after one scan.
SequenceName.Hold
Bool
Yes
All transitions in the sequence are
blocked. The Reset function as above
is NOT affected.
SequenceName.Disable
Bool
Yes
All actions associated to the steps of
the sequence are disabled, that is they
will not execute.
Bool
No
This variable is True while the step is
active.
Actions
StepName.X
Description
SequenceName = The code block name of the sequence.
StepName = The step name.
* A Yes in the Menu Access column means that the variable can be enabled by a menu
selection from the Tools menu in the online mode.
11.5.2 Step Timing Variables
The following variables are only generated if the Step Elapsed Time command in the
Tools menu is enabled (a check mark in the check box before the command), before
the program is compiled. Step time supervision activates an alarm if any step is active
for more than a specific time.
Name
SequenceName.MaxStepTime*
Time
Type
The value of this variable, gives the
maximum allowed time for step time
supervision.
Description
SequenceName.Check
Bool
This variable means that the step time
supervision can be activated/deactivated in
the code, instead of putting a check mark in
the box in the Tools menu.
SequenceName.StepTimedOut*
Bool
This variable becomes true if one step has
exceeded the maximum time for step time
supervision (see
SequenceName.MaxStepTime above).
Only enabled if Sequence Name.Check is
True.
11-15
Engineering an 800xA System
Chapter 11 Sequential Function Chart (SFC)
StepName.T
Time
This variable gives the activation time of the
step (in milliseconds). It is reset when the
step is activated, and then increased until
the step is deactivated. It keeps its value
until the next activation.
* The SequenceName.MaxStepTime and
SequenceName.StepTimedOut variables are available (visible) in
the insert variable dialog, even if the Step Elapsed Time
command not is enabled. They have, however, no use, if not
Step Elapsed Time command is enabled.
SequenceName = The code block name of the sequence.
StepName = The step name.
11.5.3 Different Methods for Activating Outputs
There are two different ways of activating outputs from a step.
11.5.3.1 In Actions
When a step is active is the N code action of the step also activated. For example if the
statement
Count := Count +1;
is written in an N action, the code is executed once every cycle while the step is
active. The advantage of writing activation code in the actions of the step, is that all
code associated with this step is kept in one place.
11.5.3.2 In a Separate Code Block Using StepName.X
By using the StepName.x (bool) variable is it possible to activate variables in other
code blocks. For example:
Start:= StartMotor.x;
This statement is written in another code block than the SFC sequence. The advantage
for this is that all activation code associated with the entire sequence could be
collected in one code block, instead of being scattered among the actions for all steps.
In the example above it is easy to find the reason for why the Start variable is true or
false: it depends on whether the step StartMotor is active or not.
11-16