Processing Order in SFC

Basic behavior of the elements

Processing sequence

  1. Resetting of the IEC actions
    TwinCAT resets the internal action control flags of the action qualifiers (N, R, S, L, D, P, SD, DS, SL). These are the flags that control an IEC action. However, flags that are called within actions will not be reset!
  2. Executing exit actions
    TwinCAT then checks all steps to see whether they fulfill the condition for executing the exit actions. The checking sequence corresponds to the order in the SFC diagram: from top to bottom and from left to right.
    TwinCAT executes an exit action when the step is deactivated, i.e. when its input and step actions (if available) have been executed in the previous cycle and the condition for the subsequent step returns TRUE.
  3. Executing entry actions
    TwinCAT then checks all steps to see whether they fulfill the condition for executing the entry actions. The checking sequence corresponds to the order in the SFC diagram: from top to bottom and from left to right. If this is the case, TwinCAT executes the entry actions.
    TwinCAT executes an entry action as soon as processing has reached the transition preceding the step and this transition returns TRUE, i.e. the step is activated.
  4. Time check, executing step actions
    TwinCAT executes the following for all steps in the sequence in which they are arranged in the SFC diagram:
  5. Executing IEC actions
    TwinCAT executes the IEC actions in alphabetical order. This is done in two cycles through the list of actions. In the first run TwinCAT executes the IEC actions of all steps that were deactivated in the previous cycle. In the second run, the IEC actions of all steps that are active are executed.
  6. Transition check, activation of the following steps
    The transitions are evaluated: If a step is active in the current cycle and the following transition returns TRUE (and a minimum step time that may have been defined has elapsed), the following step is activated.
Processing Order in SFC 1:

When implementing actions, note the following:
It may happen that an action is executed several times within the same cycle, because it is associated with several processes. (Example: An SFC contains the two IEC actions A and B, which are both programmed in SFC and which both call an IEC action C. In this case, A and B can both be active in IEC actions in the same cycle and IEC action C can be active in both actions. In this case C would be called twice.)
If the same IEC action is used simultaneously at different levels of an SFC diagram, this can lead to unpredictable effects during execution Therefore, a corresponding error message is issued. These may appear when working with projects that were created with an older version of the programming system.

Processing Order in SFC 2:

Note the possibility of using implicit variables to monitor or control the processing status of steps and actions.

See also: