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;TRUEStep | |
|---|---|
| Shows the step state in the current cycle. For |
| Shows the step state for the next cycle. If |
| 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 |
| Variable used for internal purposes only. |
| Entry point for getting information about the |
IEC action | |
|---|---|
| Shows the action state in the current cycle.
|
|
|
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:
In the Project Information dialog, on the Properties tab, set the Boolean
UseMetaStepsEnabledproperty toTRUE.For each SFC object which requires the functionality, enable the use of the
SFCMetaStepsvariable 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>
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>
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.