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:
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 is the preset default value for EN.) |
|
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. |
|
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:
Several blocks assign a value to the same variable.
The value FALSE is assigned to the input EN of one of these blocks.
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:
Page:ABS block
Page:ACOS block
Page:ADD_2D_ARRAY block
Page:ArduinoPinMode block
Page:ASIN block
Page:Assert block
Page:CAN_close block
Page:CAN_getState block
Page:CAN_init block
Page:CAN_open block
Page:CAN_recv block
Page:CAN_release block
Page:CAN_send block
Page:CAN_setBitrate block
Page:CHS block
Page:CONCAT block
Page:CONCAT_DT block
Page:DELETE block
Page:DIV block
Page:DIV_2D_ARRAY block
Page:DIV_TIME block
Page:EXPT block
Page:GPIOReadPin block
Page:GPIOWritePin block
Page:I2C_open block
Page:INET_ATON block
Page:INET_NTOA block
Page:INSERT block
Page:INTEGRATOR block
Page:LEFT block
Page:LN block
Page:LoadRetainData block
Page:LOG block
Page:MAX_2D_ARRAY block
Page:MB_Close block
Page:MB_GetState block
Page:MB_InitRTU block
Page:MB_InitTCP block
Page:MB_ReadBits block
Page:MB_SetDebug block
Page:MB_SetSlave block
Page:MB_WriteBit block
Page:MB_WriteBits block
Page:MEMCMP block
Page:MEMCPY block
Page:MEMSET block
Page:MID block
Page:MIN_2D_ARRAY block
Page:MOD block
Page:MOVE_2D_ARRAY block
Page:MUL_2D_ARRAY block
Page:MUX_BYTE block
Page:MUX_DINT block
Page:MUX_DWORD block
Page:MUX_INT block
Page:MUX_SINT block
Page:MUX_UDINT block
Page:MUX_UINT block
Page:MUX_USINT block
Page:MUX_WORD block
Page:REPLACE block
Page:RIGHT block
Page:SaveRetainData block
Page:SEL_2D_ARRAY block
Page:SPLIT_DT block
Page:SQRT block
Page:SUB_2D_ARRAY block
Page:System_close block
Page:System_delete block
Page:System_ioctl block
Page:System_open block
Page:System_read block
Page:System_write block
Page:TCP_Close block
Page:TCP_Connect block
Page:TCP_Receive block
Page:TCP_Send block
Page:TCP_ServerOpen block
Page:TO_BOOL block
Page:TO_BYTE block
Page:TO_DATE block
Page:TO_DINT block
Page:TO_DT block
Page:TO_DWORD block
Page:TO_INT block
Page:TO_LINT block
Page:TO_LREAL block
Page:TO_LWORD block
Page:TO_REAL block
Page:TO_SINT block
Page:TO_STRING block
Page:TO_TOD block
Page:TO_UDINT block
Page:TO_UINT block
Page:TO_ULINT block
Page:TO_USINT block
Page:TO_WORD block
Page:UDP_Close block
Page:UDP_Open block
Page:UDP_Receive block
Page:UDP_Send block
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 |
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 |
|
There is the same execution for a function. To illustrate this, here just the FBD-logic:
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 |
|
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. |
Equivalence as ST-code |
|
There is the same execution for a function. To illustrate this, here just the FBD-logic with the default behavior:
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).
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.
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.
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). |
|
2st workaround: Use the call of the MOVE block within the same network. |
|
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. |
|
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. |
|
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.