Skip to main content

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 automatically declared for each step and each IEC action.

The implicit variables are structure instances of type SFCStepType for steps or SFCActionType for actions. The variable name corresponds to the name of the associated element – for example step1 for a step with the step name step1. The structural components provide information about the current state of a step or action, as well as the time already elapsed during an active step.

Step and action state

Important

You can use the variables above to force a specific status value for a step in order to activate a step. However, note that this may lead to an inconsistent or uncontrolled state of the SFC chart.

Syntax for the implicit variable declaration:

<step name> : SFCStepType;
_<action name> : SFCActionType;TRUE
Table 1. The following implicit variables are available for step or IEC action status:

Step

<step name>.x

Shows the step state in the current cycle.

For <step name>.x = TRUE, the step is being executed in the current cycle.

<step name>._x

Shows the step state for the next cycle.

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

<step name>.t

Variable which provides the time span that has elapsed since the step was activated.

This information is only available for steps. The time is recorded regardless of whether a minimum time is defined in the step properties.

For more information, see the following: SFC Flags

<step name>._t

Variable used for internal purposes only.

<pou name>._MetaStep

Entry point for getting information about the ISFC elements in the linked list when the _MetaStep feature is enabled.



IEC action

_<action name>.x

Shows the action state in the current cycle.

TRUE: The action is being executed in the current cycle.

_<action name>._x

TRUE: The action is activated.

Implicit variable: _MetaStep

Variable for the linked list of elements programmed in the SFC POU

Important

The _MetaStep feature generates a lot of additional implicit code to implement the linking of elements. Enable the feature only if it is really needed.

The implicit variable _MetaStep identifies the element belonging to the initial step of an SFC chart. When the _MetaStep feature is enabled, additional implicit variables are created, resulting in a linked list for the elements in an SFC chart. As of the initial step, all transitions, steps, and jumps are linked by references to other ISFCElement objects (from the IecSfc.library, >= V4.4.0.0).

Each ISFCElement possesses the following, depending on the interface

  • Predecessor

  • Successor

  • Names

  • Number of elements in the chain

Depending on the type of ISFCElement object, a more specific sub-interface with additional attributes may be implemented.

The variable <pou name>._MetaStep is used as the entry point. The IQueryInterface function can be used to determine information about the predecessor and successor elements in the linked list of ISFC elements.

Restrictions: In the current version of the feature, the names of transitions within an SFC program must be unique. Otherwise, a warning is issued and the additional data in the linked list is not generated.

To enable the _MetaStep functionality, you need to perform the following steps:

  1. In the Project Information dialog, on the Properties tab, set the Boolean UseMetaStepsEnabled property to TRUE.

  2. For each SFC object which requires the functionality, enable the use of the SFCMetaSteps variable on the SFC Settings tab of each Properties dialog.

Access to implicit variables

Syntax for access

Within the POU, you assign the implicit variable directly:

<variable name>:=<step name>.<implicit variable> or <variable name>:=_<action name>.<implicit variable>

Example 5. Example
status := step1._x;


From another POU with instance path:  

  • <variable name> := <pou name>.<step name>.<implicit variable>

  • <variable name> := <pou name>._<action name>.<implicit variable>

Example 6. Example:
status := SFC_prog.step1._x;


Symbol generation

In the properties of a step or action, you can specify whether a symbol definition is added for the corresponding step or action flag. To do this, enable the desired access rights in the Symbol column of the Properties view.