Implicit variables in SFC

In SFC implicitly declared variables ( “flags”) can be used to scan the status of steps and actions as well as the time of steps. These flags each are set at the beginning of a cycle. For IEC step and Action they are provided by the library iecsfc.lib (structures SFCStepType and SFCActionType), which is included automatically in a project, for the simplified steps they are implemented in CoDeSys.

Scan \ of the step or action status via boolean variables:

  • For IEC steps: <stepname>.x resp. <stepname>._x:  <StepName>.x shows the current activation status. <StepName>._x shows the activation status for the next cycle. If <StepName>.x=TRUE, the step will be executed in the current cycle. If <StepName>._x=TRUE and <StepName>.x=FALSE, the step will be executed in the following cycle, i.e. <StepName>._x gets copied to <StepName>.x at the beginning of a cycle.
  • For simplified steps: <stepname> resp. _<stepname>:  If <StepName>=TRUE, the step will be executed in the current cycle. If _<StepName>=TRUE, the step will be executed in the following cycle, i.e. <StepName> gets copied to  _<StepName> at the beginning of a cycle.
  • For IEC-actions: <actionname>.x gets TRUE as soon as the action gets active (<actionname>._x is only for internal purposes, not for a status scan).

Time \ of a step via TIME variables:

The following implicit variables give the current time span which has passed since the step had got active; this is only for steps which have a minimum time configured in the ‘Extras’ ‘Step Attributes’.

  • For IEC steps: <stepname>.t    (<stepname>._t not usable for external purposes)
  • For simplified steps: _time<stepname>. BUT: If this implicit variable should be used for scan purposes, it also must be declared explicitly as a TIME variable; e.g. “_timeStep1 : TIME;”
  • For IEC actions: the implicit time variables are not used.

These status flags can be used in each action and transition of the SFC module. But they can also be accessed from other programs:

Example: boolvar1:=sfc.step1.x;

step1.x in this example is an implicit boolean variable showing the status of IEC step “step1” in POU “sfc1”.