SFC Flags

SFC flags are implicitly generated variables with predefined names used for controlling the processing of an SFC diagram. You can use these flags, for example, to display timeouts or reset step chains. In addition, you can activate tip mode specifically to activate transitions. You have to declare and activate these variables in order to have access to them.

Implicit generation of SFC flags

CODESYS declares SFC flags automatically when you activate the respective options. You can set this option in the SFC Settings tab of the properties dialog box for each POU, or in the SFC project settings dialog box for each SFC POU in the project.

Note

The SFC settings for the SFC flags of individual POUs are effective only if you have not selected the Use defaults check box. If you select this option, then the settings apply that were defined in the project settings.

Note

SFC flags that you declare in the SFC settings dialog box are visible only in the online view of the SFC block.

See also

Explicit generation of SFC flags

Manual declaration, which was necessary in CoDeSys V2.3, is now only required to enable write access from another block. In this case, you should note that when you declare the flag in a global variable list, you must deactivate its Declare setting in the SFC settings dialog box. If you do not do this, then a local SFC flag is implicitly declared that CODESYS uses instead of the global variable.

Application example for SFCError

You have created an SFC block named sfc1, which contains the s1 step. You have defined timeouts in the step properties. (See “Online view of SFC block sfc1” below.)

If for any reason the s1 step remains active longer than its time properties have permitted (timeout), then CODESYS sets the SFCError flag to permit access by the application.

To permit access, you have to declare and activate the SFC flag in the SFC settings. If you have only declared it, then the SFC flag is only displayed in the online view of sfc1 in the declaration section, but it has no function.

Now the SFC flag can be referenced within the POU, for example in an action (2) or outside of the block (1).

Online view of the SFC block sfc1

SFCError is TRUE as long as a timeout occurs within sfc2.

Access to the flags

Syntax for access

Within the POU, you assign the flag directly: <variable name>:=<SFC flag>

Example

checkerror:=SFCerror;

From another block with POU name:  <variable name>:=<POU-Name>.<SFC flag>

Example

checkerror:=SFC_prog.SFCerror;

If you need write access from another block, then you also have to declare the SFC flag explicitly as a VAR_INPUT variable in the SFC block or globally in a GVL.

Example

Local declaration:

PROGRAM SFC_prog
VAR_INPUT
  SFCinit:BOOL;
END_VAR

Global declaration in a global variable list:

VAR_GLOBAL
  SFCinit:BOOL;
END_VAR
PROGRAM PLC_PRG
VAR
  setinit: BOOL;
END_VAR
SFC_prog.SFCinit:=setinit;  // write access to SFCinit in SFC_prog

SFC flags

Name Data Type Description
SFCInit BOOL TRUE: CODESYS resets the sequence to the initial step. The other SFC flags are also reset (initialization). While the variable is TRUE, the initial step remains set (active), but its actions are not executed. Only when you reset SFCInit to FALSE does the block processing continue.
SFCReset BOOL This functions similar to SFCInit. However, CODESYS continues processing after the initialization of the initial step. For example, in the initial step, you could immediately reset the SFCReset flag to FALSE.
SFCError BOOL TRUE if a timeout occurs in an SFC diagram. If second timeout occurs in the program, it is not registered unless you previously reset the variable SFCError. The declaration of SFCError is a requirement for other flag variables to function for controlling the chronological sequence (SFCErrorStep, SFCErrorPOU, SFCQuitError).
SFCEnableLimit BOOL Used specifically for activating (TRUE) and deactivating (FALSE) the timeout control in steps using SFCError. If you declare and activate this variable (SFC settings), then you must set it to TRUE for SFCError to work. If you do not, then the timeouts are ignored. This is useful, for example, at start-up or in manual operation. If you do not declare the variable, then SFCError will work automatically. The requirement is the declaration of SFCError.
SFCErrorStep String Stores the name of the step that caused a timeout, which was registered by SFCError. The requirement is the declaration of SFCError.
SFCErrorPOU String Stores the name of the block in which a timeout occurred and was registered by SFCError. The requirement is the declaration of SFCError.
SFCQuitError BOOL As long as this boolean variable is TRUE, CODESYS pauses the processing of the SFC diagram and any timeout in the variable SFCError is reset. If you reset the variable to FALSE, then all previous times in the active steps are reset. The requirement is the declaration of SFCError.
SFCPause BOOL As long as this variable is TRUE, CODESYS pauses the processing of the SFC diagram.
SFCTrans BOOL TRUE if a transition is active.
SFCCurrentStep String Shows the name of the active step, regardless of the time monitoring. In parallel branches, the name of the step of the rightmost branch line is always stored.

SFCTip,

SFCTipMode

BOOL

Controls the tip mode of the SFC block.

If you enable this flag with SFCTipMode=TRUE, then you can activate the next step only by setting SFCTip to TRUE. While SFCTipMode is set to FALSE, transitions can also be used to continue activation.