Execution control: EN, ENO

Use the input EN and the output ENO of a →block to control the execution of this block and of following blocks. This section gives information on:

This section is valid for →ST, for →FBD as well as for →LD.

Blocks with EN/ENO

All blocks provide input EN and output ENO when →calling the block. Those blocks are:

  • the standard blocks of logi.CAD 3, e.g. the IEC-blocks

  • your user blocks

Mind that a formal call must be used when you want to address the EN/ENO. In detail:

  • If you want to set EN for a block resp. if you want to access ENO of a block, you must use the formal call for this block.
    An assignment to input EN of the block resp. an access to output ENO of the block is only allowed within the formal call of the block.

  • If you do not need to control the execution, you can use either a formal (without EN/ENO) or a non-formal call of the block.

The FAQ article "When to use a formal call? When to use a non-formal call?" contains more information on formal and non-formal call.

Behavior of EN

This behavior applies to standard blocks as well as to user blocks. See "Examples for behavior of EN and ENO" for illustrations of the behavior.

If the value of EN is set to this value,

the following behavior is valid when calling the block:

TRUE (or an equivalent)

(TRUE is the preset default value for EN.)

  1. Output ENO is reset to value TRUE (or an equivalent).

  2. The functionality of the block is executed.

  3. The functionality of the block may include an →assignment of a →Boolean value to ENO. This is the case for blocks with interal error diagnostic.

FALSE (or an equivalent)

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Applies to the FBD-editor: The value FALSE is also valid for an EN, if this EN is negated and n o other element is connected to this EN.
See under "Negating inputs and outputs" for illustrations of the behavior.

  1. Output ENO is reset to value FALSE (or an equivalent).

  2. The functionality of the block is not executed. →Input variables and →in-out variables are not set in the instance.

  3. All →output variables (except for ENO) behave as follows:

    1. In case of a →function block instance, these variables retain the last values assigned to them.

    2. The default behavior of logi.CAD 3 is: In case of a →function or a →method, these variables and a possibly existing return value get the →initial value. Reason: According to the →IEC-standard, functions/methods do not store their state.
      But it is possible to change the behavior of logi.CAD 3 so that the variables and a possibly existing return value of functions also retain the last values assigned to them. If you prefer this behavior, you must define the start option lc3.fbdPreserveFunctionOutputs for logi.CAD 3 . Best practice is to contact your administrator in order to have this configuration variable correctly defined. Moreover, observe that this start option is also changing the error handling of feedback loops for functions without a variable in between (see "→Feedback loop" for details).

  4. Assignments from output variables (incl. from output ENO) of the block to other variables are not executed, if these assignments are located within the same →network (applies to the FBD-editor and the LD-editor; e.g. a value field in the FBD-editor contains this variable in this case) or within the same →call (applies to the ST-editor).
    But you might use some workarounds to force such assignments within the FBD-editor by moving the assignment to a different network or by using the call of a block within the same network. Applied to the ST-editor, you have to enter a corresponding access separately from the call of a function block instance.

Conclusion: When to use EN with blocks?

  • If you want to clear the execution of a block, set EN to TRUE within the call of the block.

  • If you want to suppress the execution of a block, set EN to FALSE within the call of the block.

Avoid the following constructs:

  1. Several blocks assign a value to the same variable.

  2. The value FALSE is assigned to the input EN of one of these blocks.

  3. The blocks and the variable are located within the same network. Mind that connectors and continuations are elements of the networks – although there is no graphical connection.

If you are creating such constructs anyway, the assignment to the variable will not be executed. Moreover, if assignments depend on this variable, the behavior of these assignments becomes difficult to reproduce.

Behavior of ENO

This behavior applies to standard blocks as well as to user blocks.

  • If the block is executed correctly, output ENO follows input EN (see table under "Behavior of EN").

  • If an error is detected while executing a block with internal error diagnostic, output ENO of this block is set to value FALSE (or an equivalent) . The values for all other outputs and in-out variables of the block are in principle undefined. That means that these variables can assume different values on different target systems.

Conclusion: When to use ENO with blocks providing an internal error diagnostic?
If you want to clear the execution of following blocks but only when the current block is executed without errors, then make the execution of the following blocks dependent on output ENO of the current block (e.g. by an appropriate access to output ENO in the formal call). Condition: The current block must provide an internal error diagnostic.

Blocks with internal error diagnostic

The following standard blocks are providing an internal error diagnostic:

If you want to create a user block with an internal error diagnostic, you must create one or several assignments to ENO in your user block.

Examples for behavior of EN and ENO

Examples: Execution when EN=TRUE

FBD-logic with a function block instance

images/download/attachments/453674747/ENTrue_FBD1-version-2-modificationdate-1606404154597-api-v2.png

Note: The values are displayed by using →OLT-fields.

Explanation of the execution: As input EN for the function block instance RS1a is set to value TRUE, output ENO is set to the value TRUE and the functionality of the RS block is executed. Hence, Q1 is set to TRUE. As the assignments are executed, the variables Var1a to Var6a are also set to TRUE.

Equivalence as ST-code

images/download/attachments/418939344/ENTrue_ST-version-2-modificationdate-1538664710737-api-v2.png
Note: The values for the in-/outputs of the RS block are not displayed within the ST-viewer due to a restriction. Instead, the relevant values can be seen within the upper Values of Variables view.

There is the same execution for a function. To illustrate this, here just the FBD-logic:

images/download/attachments/453674750/ENTrue_FBD2-version-2-modificationdate-1606404266066-api-v2.png

The execution is analogous to the one of the RS block: As input EN for ADD is set to value TRUE, output ENO is set to the value TRUE and the functionality of the ADD block is executed. Hence, the value 5 is assigned to the variables result1 and result2. As the assignments are executed, the variables Var7 and Var8 are also set to TRUE as well as the variables result3 and result4 are also set to value 5.

Examples: Execution when EN=FALSE

FBD-logic with a function block instance

images/download/attachments/453674753/ENFalse_FBD1-version-2-modificationdate-1606404423552-api-v2.png

Explanation of the execution: As input EN for the function block instance RS1a is now set to value FALSE, output ENO is set to the value FALSE and the functionality of the RS block is not executed any longer. Q1 is still set to TRUE because the last value is retained. Due to EN=FALSE, the assignments from the output variables of the RS block are not executed because they are located within the same network. The evidence for this is the assignment of output ENO of the RS block to Var1a: The value FALSE of output ENO is not assigned to the variable Var1a – so the last value TRUE is retained for Var1a.
Note: The following assignment from variable Var1a to Var4a is executed again. This would become visible, if the value for Var1a would be changed e.g. within the Values of Variables view.

Equivalence as ST-code

images/download/attachments/418939341/ENFalse_ST-version-2-modificationdate-1538664677475-api-v2.png

There is the same execution for a function. To illustrate this, here just the FBD-logic with the default behavior:

images/download/attachments/453674756/ENFalse_FBD2-version-2-modificationdate-1606404638167-api-v2.png

Again, the execution is analogous to the one of the RS block: As input EN for the call of ADD is now set to value FALSE, output ENO is set to the value FALSE and the functionality of the ADD block is not executed any longer. Due to EN=FALSE, the assignments from the output variables of the ADD block are not executed because they are located within the same network. The evidence for this is the assignment of output ENO of the ADD block to Var7: The value FALSE of output ENO is not assigned to the variable Var7 – so the last value TRUE is retained for Var7.
Note: As difference to a function block instance, the last return value of the function is not retained. Instead the return value of ADD is now 0, because it has been type-coded with the data type INT and 0 is the initial value of INT. The assignments from the return value are not executed as well (see the next examples for more explanations).
images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If the return value of ADD is 5 in your logi.CAD 3 version, you are using a c onfiguration where the variables and a return value of functions retain the last values assigned to them. And value 5 is the value that has been calculated at last.

In order to illustrate in detail that assignment from output variables are not executed due to EN=FALSE, the following values have been changed in the Values of Variables view:

  • The value for Q1 of the function block instance RSa1 has been changed from TRUE to FALSE.

    images/download/attachments/453674759/ENFalse_FBD3-version-2-modificationdate-1606404792588-api-v2.png


    Explanation of the execution: Although the value for Q1 of the RS block is now set to value FALSE, the variables Var2a and Var3a still have the value TRUE. Reason: Due to EN=FALSE of the RS block, the assignments from output variables are not executed because they are located within the same network. Mind that connectors and continuations are elements of the networks – although there is no graphical connection.
    Note: The following assignment from variable Var2a to Var5a and the one from Var3a to Var6a are executed again. This would become visible, if the values for Var2a and Var3a would be changed e.g. within the Values of Variables view.

  • The value of the variable add1 (that is used as input for the ADD block) has been changed from 2 to 12.

    images/download/attachments/453674762/ENFalse_FBD4-version-2-modificationdate-1606404941666-api-v2.png


    Again, the execution is analogous to the one of the RS block: Although add1 is now set to value 12, the variables result1 and result2 still have the value 5. Reason: Due to EN=FALSE of the ADD block, the assignments of the return value are not executed because they are located within the same network. Mind that connectors and continuations are elements of the networks – although there is no graphical connection.
    Note: The following assignment from variable result1 to result3 and the one from result2 to result4 are executed again. This would become visible, if the values for result1 and result2 would be changed e.g. within the Values of Variables view.

Examples: Forcing the assignments when EN=FALSE

In case of a block with EN=FALSE, you are able to force the assignments from the output variables anyway. Mind that the the corresponding example under "Examples: Execution when EN=FALSE" is the basis for the following illustrations.

If the block is a function block instance, there are 2 workarounds within the FBD-editor:

1st workaround: Create the assignment in a different network (by entering the output variable within a value field).

images/download/attachments/453674765/ENFalse_FBD_Fix1-version-2-modificationdate-1606405187817-api-v2.png

2st workaround: Use the call of the MOVE block within the same network.

images/download/attachments/453674768/ENFalse_FBD_Fix2-version-2-modificationdate-1606405395567-api-v2.png

Due to EN=FALSE for the function block instances RS1b and RS1c, their output ENO is set to value FALSE. The value for Q1 of the corresponding function block instances has also been changed to FALSE – as seen in the previous examples. But in contrast to the previous examples, the assignments from the output variables are now executed because they are located within a different network (1st workaround) or they have been realized by using the MOVE block within the same network (2nd workaround).

It is not possible to enter output variables of functions within a value field. Reason: According to the IEC-standard, function do not store their state. Hence, there is only the following workaround for functions:

Workaround: Use the call of the MOVE block within the same network.

images/download/attachments/453674771/ENFalse_FBD_Fix3-version-2-modificationdate-1606405517123-api-v2.png

Due to EN=FALSE for ADD, the output ENO is set to value FALSE. The value for add1 has been changed to 12– as seen in the previous examples. But in contrast to the previous examples, the assignments from the return value are now executed because they have been realized by using the MOVE block within the same network. Mind that the variables result5 and result6 now have the value 0. Reason: The return value of ADD has been type-coded with the data type INT and 0 is the initial value of INT.

If the block is a function block instance, there is the following workaround within the ST-editor:

Workaround: Use accesses to the corresponding variables that are to be entered separately from the call.

images/download/attachments/418939338/ENFalse_ST_Fix-version-2-modificationdate-1538664632270-api-v2.png

Due to EN=FALSE for RS1a and RS1b, their output ENO is set to value FALSE. The value for Q1 of the corresponding function block instances has been changed to FALSE – as done in the previous examples. But in contrast to RS1a, the assignments from the output variables of RS1b are executed because they are entered separately from the call.

If the block is a function, there is no workaround within the ST-editor. Reason: Function do not store their state. Subsquently, it is not possible to enter the output variables and the return value of the function separately from the call of the function.