SFC element Action

Symbol: SFC element Action 1:

An action contains one or more instructions in one of the valid programming languages. You can assign an action to a step.

Actions that you use in SFC steps must be created as function blocks in the project.

SFC element Action 2:

Exception: in the case of IEC actions that you add to a step as an action association, you can also specify a boolean variable instead of an action object. The value of this variable is toggled between FALSE and TRUE each time the action is executed.

SFC element Action 3:

Step names must be defined unambiguously within the scope of the "father" function block. An action written in SFC must not contain a step that has the same name as the step to which the action is assigned.

There are "IEC actions" and "Step actions“.

1. IEC Actions

IEC actions are actions according to the IEC 61131-3 standard. They are executed according to their qualifier. IEC actions are executed at least twice: the first time when the step becomes active and a second time when it is deactivated. If you assign more than one action to a step, the action list is processed from top to bottom.

Each action box contains the qualifier in the first column and the action name in the second column. Both can be edited directly.

SFC element Action 4:

Unlike for step actions, you can use different qualifiers for IEC actions. Another difference compared with step actions is that each IEC action has a control flag. This means that TwinCAT executes the action only once, even if it is called by another step at the same time. This cannot be guaranteed for step actions.

You can assign IEC actions to a step using the Insert action association command in the SFC menu.

SFC element Action 5:

Associated Boolean variables

An associated Boolean variable is set or reset on each call of the SFC function block. This means that it is reassigned either the value TRUE or FALSE each time, regardless of whether the associated step is active or not.

If the same global boolean variable is associated as an IEC action in different SFC function blocks, this can lead to undesirable overwrite effects.

See also:

2. Step actions

These are actions that you can use to extend the IEC standard.

SFC element Action 6:

See also:

Difference between IEC action - step action

Version

The main difference between step actions and IEC actions with qualifier "N" is that the IEC action is executed (at least) twice: the first time when the step is active and a second time when it is deactivated. See the following example:

SFC element Action 7:

You have added the Action_SFC1 action to step SFC1 as a step action (left), and also as an IEC action with qualifier N. Since in both cases two transitions are triggered, it takes two PLC cycles until the initialization step is reached again. Assume that Action_SFC1 incremented a counter variable nCounter that was initialized with 0. After activating the Init step again, nCounter has the value 1 in the left example. In the right example, however, it has a value of 2, since the IEC action is executed a second time due to the deactivation of SFC1.

Duplication

Another difference is that step actions can be "embedded". In this case, they can only be called from the relevant step. When you copy this step, TwinCAT automatically generates new action objects and copies the implementation code.

You can define whether a step action is "embedded" either when you insert the first action in the step, or using the step property Duplicate or copy. In general, this behavior can also be preset in the TwinCAT options in the SFC editor category.

Boolean variable

In addition, a boolean variable can be specified instead of an action object for IEC actions. This is not possible with step actions.

See also: