SFC Flags
SFC flags are implicitly created variables with predefined names which provide functions for controlling and diagnosing SFC charts. These flags allow you to trigger transitions in a targeted manner.
For example
Detecting timeouts
Resetting step chains
Activating the tip mode
To access these variables, the corresponding flags must be declared and enabled.
Name | Data Type | Description |
|---|---|---|
|
|
|
|
| Behaves similarly to In contrast, after initialization, the initial step continues to be executed. For example, in the initial step you can immediately set the |
|
| Becomes If another timeout occurs in the program after the first one, then it will only be detected if the variable The declaration of |
|
| Used for targeted activation ( When you declare and activate this variable (SFC settings), then you also need to set it to The requirement is the declaration of |
|
| Stores the name of the step which caused a timeout registered by The name will be retained until the registered step error is reset using The requirement is the declaration of |
|
| In case of a timeout, stores the name of the POU where a timeout registered by The requirement is the declaration of |
|
| As long as this Boolean variable is The requirement is the declaration of |
|
| As long as this variable is |
|
| Becomes |
|
| Displays the name of the currently active step, regardless of the time check In the case of a parallel branch, the name of the step of the branch furthest to the right is always stored. |
|
|
When you enable tip mode by setting |
| Contains a string of all variables which contribute to the total value
For information about the advanced configuration of the analysis, see also: SFC | |
| Contains a table of the variables which contribute to the total value
For information about the advanced configuration of the analysis, see also: SFC |
Implicit generation of SFC flags
SFC flags are automatically declared when you have enabled the corresponding option. You can set this option in the SFC Settings properties dialog for individual POUs or in the SFC project settings dialog for all SFC POUs in the project.
Tip
The SFC settings of the SFC flags of individual POUs are only effective when you have not enabled the Use defaults option. If you have enabled this option, then the settings defined in the project settings will apply.
Tip
SFC flags which you have declared in the SFC settings dialog are only visible in the online view of the SFC POU.
Tip
In the SFC Element Properties, you can define if a symbol definition should be exported to the symbol configuration for a flag.
Explicit generation of SFC flags
A manual declaration – as previously required in CoDeSys V2.3 – is only still required if there needs to be write access to the flags from another POU. Note the following for this:
Important
If the flags have been declared in a global variable list, then you need to disable the Declare setting in the SFC settings dialog. Otherwise, a local SFC flag is also implicitly created. This flag is then used instead of the global variable.
Application example for SFCError
You have created an SFC POU named sfc1, which contains a step s1. You have defined time limits in the properties of the step.
If the activity duration of the step s1 exceeds the limit defined in its time properties, then the flag SFCError will be set. The application can evaluate this flag in order to react to the timeout.
To allow this access, you need to enable and declare the flag in the SFC settings. If you only declare it, then the SFC flag will be displayed in the declaration part of the online view of sfc1, but it will not work.

Now you can address the SFC flag within the POU – for example in an action (2) or from outside the POU (1).

Online view of SFC POU sfc1:

SFCError will become TRUE as soon as a timeout occurs within sfc1.
You can use the SFCErrorAnalyzation and SFCErrorAnalyzationTable flags from the Analyzation library to analyze the cause of a timeout. These flags allow you to identify the individual components of the expression which contribute to SFCError getting the value TRUE.
Access to the flags
Syntax for access
Within the POU, you assign the flag directly: <variable name> := <sfc flag>
checkerror := SFCError;From another POU with name: <variable name> := <pou name>.<sfc flag>
checkerror := SFC_prog.SFCError;
If you need write access from another POU, then you also need to explicitly declare the SFC flag as a VAR_INPUT variable in the SFC POU or globally in a GVL.
Local declaration
PROGRAM SFC_prog
VAR_INPUT
SFCInit : BOOL;
END_VAROr global declaration in a global variable list
VAR_GLOBAL
SFCInit : BOOL;
END_VARPROGRAM PLC_PRG
VAR
SetInit : BOOL;
END_VAR
SFC_prog.SFCInit := SetInit; //Write access to SFCInit in SFC_prog