SFC element Action
Symbol:
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.
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.
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.
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.
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. |
See also:
- TC3 User Interface documentation: Command Insert action association
- Qualifiers for Actions in SFC
2. Step actions
These are actions that you can use to extend the IEC standard.
- Input action:
TwinCAT executes this action once after the step has been activated and before the main action is executed.
You reference a new action or an action already created under the SFC object from a step via the element property Entry action (Step entry). You can also add a new action to the step using the Add entry action. The entry action is indicated by an "E" in the lower left corner of the step box. - Main action:
TwinCAT executes this action after the step has been activated and any entry action has already been executed. However, unlike an IEC action (see above), it is not executed a second time when the step is deactivated again. Also, you cannot use qualifiers here.
To add an existing action, use the element property Main action (Step active). A main action is indicated by a filled triangle in the upper right corner of the step box. - Exit action:
TwinCAT executes this action once if the step has been deactivated. Note, however, that the execution no longer takes place in the same cycle, but at the beginning of the next one!
You reference a new action or an action already created under the SFC object from a step via the element property Exit action (Step exit). You can also add a new action to the step using the Add exit action. The exit action is indicated by "X" in the lower right corner of the step box.
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:
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: