Skip to main content

Qualifiers for Actions in SFC

You assign qualifiers to IEC actions which are associated with a step. The qualifier defines the execution behavior of the respective action – in what way, when, and for how long it is executed.

Qualifiers are processed by the SFCActionControl function block in the library IecSfc.library. The library is automatically embedded in the project as soon as CODESYS SFC has been installed.

For more information, see the following: Programming in SFC

Table 2. Available qualifiers

N

Non-stored

The action is active as long as the step.

R

overriding Reset

The action executed with S, SD, DS, or SL will be deactivated and therefore no longer executed.

S

Set (Stored)

The action is executed as soon as the step becomes active. The action execution continues, even after the step has been deactivated, until it gets a reset.

L

time Limited

The action is executed as soon as the step becomes active. The action is executed until the step is deactivated or the given time span has elapsed.

D

time Delayed

The action is executed after the step has become active if the specified delay time has elapsed and the step is still active. The action is executed until the step is deactivated.

P

Pulse

The action is performed exactly twice: one time when the step becomes active and the second time when the step is deactivated.

SD

Stored and time Delayed

The execution of the action will only start when the specified delay time has elapsed after the step has become active. The action is executed until it gets a reset.

DS

Delayed and Stored

The execution of the action will only start when the specified delay time has elapsed after the step has become active and the step is still active. The action is executed until it gets a reset.

SL

Stored and time Limited

The action is executed as soon as the step becomes active. It is executed until the specified time has elapsed or it gets a reset.



Note

An action with the qualifier S, SD, DS, or SL continues running after the step becomes inactive.

For the qualifiers S, SD, and DS, the action only ends with a resetting call to the same action with the R qualifier. This kind of call is necessary for the action to end.

For the SL qualifier, the action ends automatically as soon as the specified time has elapsed, or prematurely by a call with R.

You need to specify the times for the L, D, SD, DS, and SL qualifiers in the format of a TIME constant.

For more information about how to use qualifiers, see the following: Examples for Qualifiers.

Tip

When an IEC action is deactivated, it is executed one more time. This means that CODESYS executes this kind of action at least twice. This also applies to actions with the P qualifier.

Examples for Qualifiers

This section contains examples of how to use qualifiers.

Example: Smoke ventilation in a ventilation system

The qualifier of an action determines when the action starts and how long it runs. The example shows the same process in three implementations of the Sequential Function Chart (SFC). The implementations differ by the use of qualifiers.

The initial situation: A ventilation system uses a smoke sensor to monitor the air. When the sensor detects smoke, the controller immediately activates the smoke ventilation.

POU with an N qualifier

_c4_img_sfc-qualifizierer-simple.png

The POU contains the simplest flow. When the smoke sensor detects smoke, the step with the Ventilate action becomes active. The step calls the action with the N qualifier. The smoke ventilation runs as long as the sensor detects smoke.

Procedure. Controlling the smoke ventilation
  1. Create a POU in SFC and change the name to Simple_N. For more information, see the following: Creating a POU in SFC

  2. In the declaration part of the created POU, create the following Boolean variables:

    PROGRAM Simple_N
    VAR	
        bSmokeDetected: BOOL;
        bVent: BOOL;
    END_VAR
  3. Change the transition of the initial step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable.

  4. After the transition of the initial step, add a step named SmokeInSystem.

  5. Change the transition of the SmokeInSystem step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable. Add NOT: NOT bSmokeDetected

  6. In the device tree, right-click the newly created POU Simple_N and select the Add Object → Action command. Assign the name Ventilate and select Structured Text (ST) as the implementation language.

  7. Insert the following code there:

    // The alternation simulates the running ventilator.  
    bvent := NOT bvent;
  8. Click the SmokeInSystem step and use the SFC → Insert Action Association command to add an action association.

    The N qualifier will now be assigned to the associated action.

  9. Click in the right field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the Ventilate action.

    A simple smoke ventilation has been set up.

POU with two N qualifiers

_c4_img_sfc-qualifizierer-advanced_2_N.png

Problem: A residual amount of smoke remains in the system. The smoke ventilation must therefore run 5 seconds longer.

The POU handles the follow-up time by using an additional step. When the smoke sensor detects smoke, the step with the Ventilate action becomes active. The step calls the action with the N qualifier.

When the sensor no longer detects smoke, the controller switches to step NoSmokeMore. The smoke ventilation continues to run. The transition following the step evaluates the implicit step variable with the condition NoSmokeMore.t > t#5s. This variable contains the time that the step has been active.

After 5 seconds, the condition is fulfilled and the step becomes inactive. This also ends the execution of the Ventilate action.

Procedure. Controlling the smoke ventilation
  1. Create a POU in SFC and change the name to Advanced_N_N. For more information, see the following: Creating a POU in SFC

  2. In the declaration part of the created POU, create the following Boolean variables:

    PROGRAM Advanced_N_N
    VAR	
        bSmokeDetected: BOOL;
        bVent: BOOL;
    END_VAR
  3. Change the transition of the initial step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable.

  4. After the transition of the initial step, add a step named SmokeInSystem.

  5. Change the transition of the SmokeInSystem step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable. Add NOT: NOT bSmokeDetected

  6. In the device tree, right-click the newly created POU Advanced_N_N and select the Add Object → Action command. Assign the name Ventilate and select Structured Text (ST) as the implementation language.

  7. Insert the following code there:

    bvent := NOT bvent;
  8. Click the SmokeInSystem step and use the SFC → Insert Action Association command to add an action association.

    The N qualifier will now be assigned to the associated action.

  9. Click in the right field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the Ventilate action.

  10. Add a step named NoSmokeMore after the transition of the SmokeInSystem step and add a transition with the condition NoSmokeMore.t > t#5s.

  11. Click the NoSmokeMore step and use the SFC → Insert Action Association command to add an action association.

    The N qualifier will now be assigned to the associated action.

  12. Click in the right field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the Ventilate action.

    The smoke ventilation will stop after 5 seconds.

POU with S and R qualifiers

_c4_img_sfc-qualifizierer-advanced.png

Problem: A residual amount of smoke remains in the system. The smoke ventilation must therefore run 5 seconds longer.

Here too, the controller immediately activates the smoke ventilation. The SmokeInSystem step calls the Ventilate action with the S qualifier. During the NoSmokeMore step, the smoke ventilation continues to run however, because the action is stored with the S qualifier and only ends with R.

The POU solves the follow-up time with an additional NoSmokeMore step. After 5 seconds, the condition is fulfilled and the step becomes inactive.

The additional After_5sec step calls the Ventilate action with the R qualifier. The step resets the action and therefore stops the smoke ventilation after 5 seconds.

Procedure. Starting the smoke ventilation
  1. Create a POU in SFC and change the name to Advanced_S_R. For more information, see the following: Creating a POU in SFC

  2. In the declaration part of the created POU, create the following Boolean variables:

    PROGRAM Advanced_S_R
    VAR	
        bSmokeDetected: BOOL;
        bVent: BOOL;
    END_VAR
  3. Change the transition of the initial step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable.

  4. After the transition of the initial step, add a step named SmokeInSystem.

  5. Change the transition of the SmokeInSystem step: click the transition and use the Input Assistant _cds_icon_button_threedots.png to assign the bSmokeDetected variable. Add NOT: NOT bSmokeDetected

  6. In the device tree, right-click the newly created POU Advanced_S_R and select the Add Object → Action command. Assign the name Ventilate and select Structured Text (ST) as the implementation language.

  7. Insert the following code there:

    bvent := NOT bvent;
  8. Click the SmokeInSystem step and use the SFC → Insert Action Association command to add an action association.

  9. Click in the left field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the S qualifier.

  10. Click in the right field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the Ventilate action.

    A simple smoke ventilation has been set up.

Procedure. Stopping smoke ventilation after 5 seconds
  1. Add a step named NoSmokeMore after the transition of the SmokeInSystem step and add a transition with the condition NoSmokeMore.t > t#5s.

  2. Add another step named After_5sec after the transition of the NoSmokeMore step and add a transition with the condition TRUE.

  3. Click the After_5sec step and use the SFC → Insert Action Association command to add an action association.

  4. Click in the left field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the R qualifier.

  5. Click in the right field of the association and use the Input Assistant _cds_icon_button_threedots.png to select the Ventilate action.

    The smoke ventilation will stop.