EN and ENO for LAD, FBD and SCL

Determining "power flow" (EN and ENO) for an instruction

Certain instructions (such as the Math and the Move instructions) provide parameters for EN and ENO. These parameters relate to power flow in LAD or FBD and determine whether the instruction is executed during that scan. SCL also allows you to set the ENO parameter for a code block.
- EN (Enable In) is a Boolean input. Power flow (EN = 1) must be present at this input for the box instruction to be executed. If the EN input of a LAD box is connected directly to the left power rail, the instruction will always be executed.
- ENO (Enable Out) is a Boolean output. If the box has power flow at the EN input and the box executes its function without error, then the ENO output passes power flow (ENO = 1) to the next element. If an error is detected in the execution of the box instruction, then power flow is terminated (ENO = 0) at the box instruction that generated the error.

Program editor Inputs/outputs Operands Data type
LAD EN,ENO Power flow Bool
FBD EN I, I:P, Q, M, DB, Temp, Power Flow Bool
FBD ENO Power Flow Bool
SCL EN1 TRUE, FALSE Bool
SCL ENO2 TRUE, FALSE Bool
  1. The use of EN is only available for FBs
  2. The use of ENO with the SCL code block is optional. You must configure the SCL compiler to set ENO when the code block finishes

How do you enable the ENO enable output of an instruction in LAD and FBD?

​ Certain instructions have an ENO (enable output) in LAD and FBD. If error checking is not necessary during runtime, you can disable this ENO output in a SIMATIC S7-1500 CPU. This leads to an enhancement of the controller's performance.

​ To disable/enable the ENO enable output of an instruction you right-click the instruction in your program for which you want to set the EN/ENO mechanism. The pop-up menu opens as shown

![image-20210915214924037](EN and ENO for LAD, FBD and SCL.assets/image-20210915214924037-16317137722341.png)

​ Now, in the pop-up menu, you select the "Do not generate ENO" command to disable the ENO enable output or the "Generate ENO" command to enable the ENO enable output.

​ In STEP 7 (TIA Portal) V12 onwards the ENO enable output for the S7-1500 is disabled by default in the programming languages LAD (Ladder Diagram) and FBD (Function Block Diagram).

Configuring SCL to set ENO

To configure the SCL compiler for setting ENO, follow these steps:

  1. Select the "Settings" command from the "Options" menu.

  2. Expand the "PLC programming" properties and select "SCL (Structured Control

    Language)".

  3. Select the "Set ENO automatically" option.

Using ENO in program code

You can also use ENO in your program code, for example by assigning ENO to a PLC tag, or by evaluating ENO in a local block.

Examples:

"MyFunction"
( IN1 := ... ,
  IN2 := ... ,
  OUT1=>#myOut
  ENO => #statusFlag);  //PLC tag statusFlag holds the value of ENO
"MyFunction"
( IN1 := ... ,
  IN2 := ... ,
  OUT1=>#myOut
  ENO => ENO);  //Block status flag of "MyFunction" is stored in the local block
IF ENO = TRUE THEN
                // execute code only if MyFunction returns true ENO

Effect of Ret_Val or Status parameters on ENO

​ Some instructions, such as the communication instructions or the string conversion instructions, provide an output parameter that contains information about the processing of the instruction. For example, some instructions provide a Ret_Val (return value) parameter, which is typically an Int data type that contains status information in a range from -32768 to +32767. Other instructions provide a Status parameter, which is typically a Word data type that stores status information in a range of hexadecimal values from 16#0000 to 16#FFFF.

The numerical value stored in a Ret_Val or a Status parameter determines the state of ENO for that instruction.

  • Ret_Val: A value from 0 to 32767 typically sets ENO = 1 (or TRUE). A value from -32768 to -1 typically sets ENO = 0 (or FALSE). To evaluate Ret_Val, change the representation to hexadecimal

  • Status: A value from 16#0000 16#7FFF typically sets ENO = 1 (or TRUE). A value from 16#8000 to 16#FFFF typically sets ENO = 0 (or FALSE)

​ Instructions that take more than one scan to execute often provide a Busy parameter (Bool) to signal that the instruction is active but has not completed execution. These instructions often also provide a Done parameter (Bool) and an Error parameter (Bool). Done signals that the instruction was completed without error, and Error signals that the instruction was completed with an error condition

  • When Busy = 1 (or TRUE), ENO = 1 (or TRUE).

  • When Done = 1 (or TRUE), ENO = 1 (or TRUE).

  • When Error = 1 (or TRUE), ENO = 0 (or FALSE)

Further More

What is the meaning of the BR bit in the status word in STEP 7?

Description
The BR bit (binary result) is bit 8 of the status word and is used to pass on the function result to other functions to be processed subsequently. The table below explains the meaning of the BR bit and how you can use it.

No. Meaning and use of the BR bit
1 In the FBD/LAD editor, the BR bit is transmitted at the ENO output of function blocks (FBs/FCs and SFBs/SFCs). If BR = 1, an immediately consecutive function or block with EN=1 (=BR) is executed or called. If BR = 0, an immediately consecutive function or block with EN=1 (=BR) is neither executed nor called.
2 If, in the FBD/LAD editor, you use word operations (like ADD_...) or other non-binary operations, a positive function result is shown as BR = 1 and any processing error (e.g. Overflow) is shown as BR = 0. In this way, the call of subsequent functions or function blocks is controlled by the BR.
3 If you write a function block or function in STL and call it in the FBD/LAD editor, you must save the result of the logic operation (RLO) in the BR bit directly before quitting the block. Use the operations "SAVE", "JCB" and "SPBNB" to enable the release output (ENO) for the LAD/FBD box (see below).
4 If you you call a system function block (SFB) or a system function (SFC), the SFB or SFC indicates via the signal status of the BR bit whether the CPU has executed the function with or without error. If an error occurred during processing, the BR bit = 0. If an error did not occur during processing, the BR bit = 1.
5 SAVE The "SAVE" statement saves the RLO in the BR bit. The first check bit "/FC" bit is not reset. For this reason, if there is an AND logic operation in the next network, the state of the BR bit is included in the logic operation. It is not recommended to use SAVE and then query the BR bit in the same block or lower-level blocks, because the BR bit might be changed if there are too many interim operations. The best thing to do is use SAVE just before quitting the block, because then the ENO output (=BR bit) is set to the value of the RLO bit and you can set a block error handling immediately after that.
6 "JCB " instruction **JCB: jump when the RLO=1 and save the RLO in the BR. The "jump label" is the symbolic name of the jump destination. If the RLO = 1, the "JCB " statement interrupts the linear program run and jumps to the jump destination. Linear program execution continues at the jump destination. The jump destination is marked by a jump label. If the RLO = 0, the jump is not made. The RLO is set to "1" and the program continues with the following instruction. **Example U E10.1 U E10.2 JCB M001 //Jump to jump label "M001" if the RLO=1
7 "JNB " instruction **JNB: jump when the RLO=0 and save the RLO in the BR. The jump destination is marked by a jump label. If the RLO = 0, the "JNB " instruction interrupts the linear program run and jumps to the jump destination. Linear program execution continues at the jump destination. If the RLO = 1, the jump is not made. The RLO is set to "1" and the program continues with the following instruction. **Example U E10.1 U E10.2 JNB M001 //Jump to jump label "M001" if the RLO=0

The jumps mentioned above may be both forwards and backwards. The maximum jump distance is -32768 or +32767 bytes of the program code. Jumps may only be made within a block, in other words the jump instruction and the jump destination must be in the same block. The destination can only occur once in one block. The actual maximum number of instructions that can be skipped depends on the combination of instructions in the program (one-word, two-word or three-word instructions).

Note on the program behavior with S7-300
The internal structures of an S7-300 CPU and an S7-400 CPU are different. The S7-400 processes the program directly, whereas the S7-300 program is compiled during when loaded. Therefore, with the S7-400 we speak of ASIC machines and of compiler machines with the S7-300. In particular there are differences in the processing of binary logic operation sequences. The beginning and end of the logic operation sequences are known only when compiling the program for the S7-300 CPU modules. At this point you can define the behavior of the first scan bit /ER in the status word.

If there is a jump to a logic operation sequence using a jump instruction, then the RLO of the jump instruction is linked with the /ER bit of the logic operation sequence. This influence on the RLO gives the impression that the OR statement is apparently processed incorrectly in a 300-series CPU. Therefore, after a jump, it is necessary to begin a new logic operation sequence.


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。