Programming SFC
This chapter contains descriptions that are specific to the graphical IEC 61131-3 programming language SFC, its specific objects and the handling of variables in SFC.
PLCnext Engineer provides special SFC extensions to facilitate the practical use of SFC POUs.
Note
Safety-related POUs cannot be programmed in SFC. Use SNOLD instead. |
The general and language-independent handling of the graphic editor and the steps how to use and set up the editor are described in the topic "Feature Overview: Graphic Editor".
For a description of the objects that are common to all graphical programming languages, for example, jumps and returns, refer to the topic "Constants, Jumps/Labels, Returns, Connectors".
This topic contains the following sections:
- SFC syntax
- Extensions to the IEC 61131-3 standard
- SFC function block POU, coded actions and transition
- SFC network
SFC syntax
Code programmed in the graphical language Sequential Function Chart (SFC) is composed of steps and transitions connected via directed links.
A step is either active or inactive. It can have one or more assigned actions. While a step is active, the associated action(s) is (are) executed according to the action qualifier(s).
An action can be a single Boolean variable or a separately coded action consisting of code written in the programming languages ST, FBD or LD. An action block consists of the action name and the action qualifier. The action qualifier specifies how the action is affected by the step to which it belongs.
One interlock can be associated to each step to allow or prevent the execution of its assigned actions.
A transition represents the condition under which the immediately preceding step becomes inactive and the process continues with the immediately succeeding step (succeeding step becomes active). A transition can be a single Boolean variable (TRUE/FALSE constants are also allowed) or a directly connected LD/FBD network with a Boolean result or a separate coded transition consisting of code written in the programming languages ST, FBD or LD. If a transition is FALSE, the preceding step and the assigned actions are executed continuously. The transition is evaluated again. When the transition becomes TRUE, the preceding step executes the actions defined in this step once again and then the succeeding step becomes active.
The set of connected objects is called SFC network. An SFC network must have one initial step which is the first step to be executed when the SFC POU is called for the first time. Simultaneous branches (executed simultaneously) or alternative branches (executed alternatively) can be inserted in the SFC network.
One of the main characteristics of editing in SFC is that the programming system always tends to create a closed network. While inserting new steps and transitions the part of the network under the insertion point is pushed automatically downwards or to the right.
When inserting SFC objects such as steps, transitions, etc. into the SFC network or deleting SFC objects in an SFC network, always a valid SFC network is created after the editing operation. Invalid SFC networks are not possible.
Note
PLCnext Engineer only allows SFC function blocks. POUs of the type program and function cannot be developed in SFC. |
Extensions to the IEC 61131-3 standard
PLCnext Engineer extends the IEC 61131-3 standard by implementing SFC operating modes used to control the execution of the SFC code. For that purpose, each SFC function block gets formal parameters by default when it is inserted into a code worksheet.
Two variants of such SFC function blocks are available:
- SFC function block showing all parameters as inputs and outputs:
- Compact SFC function block, where most of the parameters are combined in a STRUCT data type which is to be connected to an InOut formal parameter. Only the dynamically generated 'STEP_STATES' and 'STRUCTURE' are implemented as function block output parameters.
The only difference between the normal and the compact SFC FB is the way it is connected in the calling POU. The contained SFC code and functional possibilities are identical.
You define the type when inserting the SFC function block in the COMPONENTS area. For that purpose, the context menu on the 'Functions & Function Blocks' folder provides the menu items 'Add SFC Function Block' and 'Add Compact SFC Function Block'.
Note
An existing SFC function block cannot be changed to a compact one or vice versa. |
Further Info
Refer to the topic "SFC Parameters, Operating Modes and Data Types" for further information. |
As a further extension, one PreExecuted and one PostExecuted worksheet can be added to each SFC FB (see topic "Always Executed Code") and interlocks can be added to steps.
SFC function block POU, coded actions and transition
The SFC function block POU consisting of the variables table and the code worksheet(s) is opened in the editors area by double-clicking the POU icon under 'COMPONENTS | Programming > Local > Functions & Function Blocks' (or any subfolder). In the components area, normal and compact SFC FBs are identical.
Each coded action and transition that can be used as action/transition in the SFC network is available as separate node in the corresponding subfolder of the SFC function block POU.
SFC network
When creating a new SFC POU, an SFC code worksheet with one transition detail is automatically added to the 'Local' folder. The SFC code worksheet contains by default a basic SFC network consisting of one initial step, the relating action and one transition.
When programming SFC code by inserting steps, transitions, etc. into the SFC network, a syntax check is always done ensuring that no invalid SFC network can be created.
Further Info
Refer to the separate topics for details on the various SFC objects ![]() ×‣ Transition in SFC ×‣ Action and Action Qualifier in SFC ×‣ Branch in SFC ×. |