Implicit Variables

Each SFC object provides implicit variables, which you can use to monitor the status of steps and IEC actions at runtime. TwinCAT automatically creates these implicit variables for each step and IEC action.

The implicit variables are structure instances of type SFCStepType (for steps) or SFCActionType (for actions). The variables have the name of the element, e.g. "step 1" for a step with step name "step1“. The structure components describe the status of a step or action or the time that has already elapsed in an active step.

Step and action status

Syntax for the implicit variable declaration:

<stepname>:SFCStepType;

_<actionname>:SFCActionType;

The following implicit variables are available for step or IEC action status:

Step

<stepname>.x

Shows the activation status in the current cycle.

If <stepname>.x = TRUE, TwinCAT executes the step in the current cycle.

<stepname>._x

Shows the activation status for the next cycle.

If <stepname>._x = TRUE and <stepname>.x = FALSE, TwinCAT executes the step in the next cycle, i. e. <stepname>._x is copied to <stepname>.x at the beginning of a cycle.

<stepname>.t

The flag t returns the current timespan that has elapsed since the step became active. This applies only to steps, regardless of whether a minimum time is defined in the step properties or not.

See also SFC flag SFCError.

<stepname>._t

Used only for internal purposes

IEC action

_<actionname>.x

TRUE if the action is executed.

_<actionname>._x

TRUE if the action is active.

Implicit Variables 1:

You can use the variables described above to force a particular status value for a step, that is, to set a step to active. Note, however, that this causes an uncontrolled status of the SFC.

Access to implicit variables

Syntax for the access:

Within the POU, you assign the implicit variable directly: <variable name>:=<step name>.<implicit variable> or <variable name>:=_<action name>.<implicit variable>

Example:

status := step1._x;

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

Example:

status := SFC_prog.step1._x;

See also: