Implicit Variables

Every SFC object supplies implicit variables for you to monitor the status of steps and IEC actions at runtime. These implicit variables are declared automatically by CODESYS for each step and each IEC action.

The implicit variables are structure instances of the type SFCStepType for steps and type SFCActionType for actions. The variables have the same names as their elements, for example “step1” variable name for “step1” step name. The structure components describe the status of a step or action or the current elapsed time in an active step.

Note

In the element properties, you can define whether CODESYS should export a symbol definition for this flag to the symbol configuration.

See also

Step and action status

Syntax for the implicit variable declaration:

<step name>:SFCStepType;

_<action name>:SFCActionType;

The following implicit variables are available for step or IEC action status:
Step
<step name>.x

Shows the activation status in the current cycle.

If <step name>.x = TRUE, then CODESYS processes the step in the current cycle.

<step name>._x

Shows the activation status for the next cycle.

If <step name>._x = TRUE and <step name>.x = FALSE, then CODESYS processes the step in the next cycle. This means that <step name>._x is copied to <step name>.x at the beginning of a cycle.

<step name>.t

The t flag yields the current elapsed time since the step was activated. This applies only to steps, regardless of whether a minimum time has been defined or not in the step properties.

See also: SFCError flag.

IEC action
_<action name>.x TRUE when the action is being executed.
_<action name>._x TRUE when the action is active.

Hint

You can use the above variables to force a specific status value to a step (activate a step). Please note, however, that this can cause an unstable status in the SFC.

See also

Access to implicit variables

Syntax for access:

Assign implicit variable directly in the POU: <variable name>:=<step name>.<implicit variable> and <variable name>:=_<action name>.<implicit variable>

Example

status:=step1._x;

From another block with POU name:  <variable name>:=<POU name>.<step name>.<implicit variable> and <variable name>:=<POU name>._<action name>.<implicit variable>

Example

status:=SFC_prog.step1._x;

Symbol generation

In the element properties of a step or action, you define whether CODESYS should add a symbol definition for the step or action flag. In the Properties view, you must select the necessary access rights in the Symbol column.

See also