Description
You can use the "Return" instruction to stop the execution of a program block conditionally or absolutely. The signal state of the return value (operand) is mapped in the enable output ENO of the calling program block when the program block is exited.
There are three ways that the execution of a program block can be ended:
|
Termination of the program block |
Description |
|---|---|
|
Without a call of the instruction |
The program block is exited after the execution of the last network. The enable output ENO of the calling program block is set to signal state "1". |
|
Call of the instruction with preceding logic operation (see example) |
If the preceding logic operation is fulfilled, the program execution in the currently called program block is ended and the program block is exited. (Conditional program block end) The program execution is continued in the calling program block (e.g. an OB) after the program block call. The enable output ENO of the calling program block corresponds to the operand. |
|
Call of the instruction without preceding logic or the instruction is directly connected to the left power rail. |
The program block is exited unconditionally. (Absolute program block end) The enable output ENO of the calling program block corresponds to the operand. |
If an organization block (OB) is ended, another program block is selected by the execution level system and started or further executed.
-
If the OB program cycle is ended, it is restarted.
-
If an OB is ended that has interrupted another program block (e.g. an interrupt OB), then the interrupted program block (e.g. program cycle OB) is further executed.
|
Note RET instruction in relation with JMP and JMPN If a network already contains the "JMP: Jump if RLO = 1" or "JMPN: Jump if RLO = 0 instruction, the RET: Return" instruction must not be used. Only one jumping coil may be used in a network |
Possible settings of the return value (operand)
The return value of the instruction can assume the following values:
-
Ret (RLO, corresponds to the result of logic operation RLO. The signal state "1" is supplied to the enable output ENO of the calling program block because the RET instruction is only then executed as a conditional instruction when the condition is TRUE.)
-
Ret True or Ret False (the respective value of the constant, TRUE or FALSE, is supplied to the calling program block.)
-
Ret Value (the value of the Boolean tag <Operand> is supplied to the calling program block.)
To set the return value of the instruction, click the small yellow triangle of the instruction and select the desired value in the drop-down list.
The following table shows the status of the calling program block when the instruction is programmed in a network within the called program block:
|
RLO |
Return value |
ENO of the calling program block |
|---|---|---|
|
1 |
RLO |
1 |
|
TRUE |
1 |
|
|
FALSE |
0 |
|
|
<Operand> Boolean tag with possible memory areas I, Q, M, D, L, T, and C |
<Operand> |
|
|
0 |
RLO |
The program execution is continued in the next network of the called program block. |
|
TRUE |
||
|
FALSE |
||
|
<Operand> |
Example
The following example shows how the instruction works:
If one of the operands "TagIn_1" or "TagIn_2" have signal state "1", the instruction is executed. Program execution is ended in the called program block and continues in the calling program block. The enable output ENO of the calling program block is reset to signal state "0".