You can influence processing of the user program by means of the program flow control functions. The available functions are shown in Fig. 8.32.
8.6.1 Working with status bits in the function block diagram Scanning status bits
Status bits provide information on the result of an arithmetic function and on any errors, for example exceeding a numerical range. Chapter 14.1.5 “Evaluating the status bits” on page 566 describes how you can use scan boxes to scan the signal state of the status bits.
Fig. 8.32 Overview of functions for program flow control in the function block diagram Functions for program flow control
FC_name EN
param_1 ...
param_2 ...
param_3 ...
ENO
DB_name FB_name
EN param_1 ...
param_2 ...
param_3 ...
ENO
Data block Data block Logic block
Target Target RLO
SAVE
JMP JMPN RET
Status bit
OPN OPNI CALL
MCRA MCR< MCR> MCRD
Scan status bit Save binary result
Jump functions Block end function
Select data block Change block
Block calls
Master control relay
For programming, drag the symbol labeled Status with the mouse from the pro- gram elements catalog under Basic instructions > Further instructions to the working area. You can set the status bit to be scanned (OV, OS, UO, BIE, ==0, >=0, <=0, >0, <0, and <>0) via a drop-down list which you can open using the small yellow triangle when the box is selected.
Example: In Fig. 8.33, a floating-point number is checked for validity. To do this, the tag is compared with any floating-point constant. The type of comparison does not play a role here. If the floating-point number is invalid, the comparison is incorrect in all cases and the status bit OV (overflow) is set. Thus if the comparison is incorrect and the overflow bit is set, the intermediate memory #Floating_point_number_invalid is set and the JMP (jump) to the Error label is carried out.
Save binary result
With the SAVE box you can save the result of logic operation RLO in the binary result BIE. A detailed function description of the SAVE box is provided in Chapter 14.1.4
“Controlling the binary result” on page 565.
For programming, drag the SAVE box with the mouse from the program elements catalog under Basic instructions > Further instructions to the working area and, if ap- plicable, set the SAVE function via a drop-down list which you can open using the small yellow triangle when the box is selected.
The SAVE box requires a preceding logic operation and is present alone in a logic operation. A T branch must not be programmed in the network with a SAVE box.
Note that the SAVE box does not terminate the logic operation, and therefore the logic operation can be continued in the following network.
You can control the ENO output of the block with the SAVE box if you call the box in the last network of the block. In the example in Fig. 8.36 on page 344, the error mes- sages are collected in the last network of the block: #Floating_point_number_invalid (error with “1”) and #Adder_error (error with “0”). The logic operation must not be fulfilled with an error; in this case signal state “0” is transferred by the SAVE box to the ENO output.
Fig. 8.33 Example of scanning a status bit
8.6.2 EN/ENO mechanism with FBD
With FBD, all block calls and functions (statements) for which an error can occur have an enable input EN and an enable output ENO.
The EN input and the ENO output are not block parameters and are not declared.
They are statement sequences which the program editor generates in the program before and after a block or function call. They are not visible to the user. The EN input and the ENO output are both of data type BOOL.
You can use the properties of EN and ENO to connect several boxes into a sequence, where the enable output ENO leads to the enable input EN of the next box. In this manner it is possible, for example, to “switch off” the complete sequence, or the rest of the sequence is no longer processed if a box signals an error.
Controlling a processing sequence
In the example in Fig. 8.34, neither of the boxes is processed if the #Enabling tag has signal state “0”. If an error occurs during processing of the ADD box, for example a numerical range is exceeded, the subsequent SQRT box is no longer processed.
Enable input EN
You can control the calling of a block using the enable input EN. If EN has signal state “1” or is not connected, the called block is processed. If EN has signal state “0”, the called block is not processed. A jump is then made beyond the block call to the next following statement (function).
Enable output ENO
You can scan the error status of the block using the enable output ENO. If ENO has signal state “1”, processing has been carried out correctly. With signal state “0”, the ENO output signals that the block was not called (EN was “0”) or that an error is present in the block (Fig. 8.35).
The ENO output has the signal state which the binary result BIE had in the block.
With self-created blocks, you can control the assignment of the ENO output via the binary result in order, for example, to signal faulty processing in the block.
Fig. 8.34 Example of series connection of ENO and EN with FBD
Example: In Fig. 8.36 on page 344, in the first network the #Adder_error tag is set to signal state “0” in the event of an error in the “Adder.FBD” block, and a jump is made to the Error label.
The jump label Error is present in the last network of the block. The binary result BIE, and thus also the ENO output of the current block, are set to signal state “0”
here by means of the SAVE box.
8.6.3 Jump functions
For programming a jump function, drag the symbol of a jump function with the mouse from the program elements catalog under Basic instructions > Program con- trol operations to the working area. You define the jump label (the jump destina- tion) using the jump box. To program the jump destination, use the mouse to drag the Label function to the start of the network with which processing of the program is to be continued from the program elements catalog under Basic instructions >
Program control operations and write the label into the box.
You can subsequently set the jump function (JMP or JMPN) via a drop-down list which you can open using the small yellow triangle when the box is selected. If the box with the jump function JMP does not have a preceding logic operation, the jump is always carried out (absolute jump). The jump function JMPN always requires a preceding logic operation.
The jump functions cannot be programmed in association with a T branch. Only one jump statement is permissible per network. If you use the Master Control Relay (MCR), the jump destination must be located in the same MCR zone or in the same MCR area as the jump function.
A detailed description of the jump functions is provided in Chapter 14.2 “Jump functions” on page 568.
Fig. 8.33 on page 341 and Fig. 8.36 on page 344 show examples of the jump func- tions. In the first example, a jump is carried out by means of a JMP coil to the Error
Is EN connected?
YES NO
Is EN = “1”? Block/function being processed
YES NO
Block/function being processed Block/function not being processed
Has an error occurred? Has an error occurred?
YES NO YES NO
ENO output is set to “0”
ENO output is set to “1”
ENO output is set to “0”
ENO output is set to “0”
ENO output is set to “1”
Fig. 8.35 Schematic diagram for setting of enable output ENO
label upon a result of logic operation “1”. In the second example, a jump is also carried out by means of a JPMN coil to the Error label upon a result of logic opera- tion “0”.
8.6.4 Block functions Block end function, RET box
To program the block end function, drag the RET box with the mouse from the program elements catalog under Basic instructions > Program control operations to the working area. Above the RET box, RLO (result of logic operation) indicates that the result of the logic operation present in front of the RET box is assigned to the ENO output of the block which has been left.
A detailed description of the RET box is provided in Chapter 14.3 “Block end func- tions” on page 575.
The RET box requires a preceding logic operation and must only terminate a logic operation on its own.
Fig. 8.36 Examples of functions for program flow control in the function block diagram
In the second network in Fig. 8.36, the block with the RET box is left if the “Adder”
block does not signal an error.
Open data block, OPN and OPNI boxes
To program the OPN or OPNI box, drag it with the mouse from the program ele- ments catalog under Basic instructions > Program control operations to the working area. With OPN you open a data block via the DB register, with OPNI via the DI reg- ister.
You can subsequently set the function (OPN or OPNI) via a drop-down list which you can open using the small yellow triangle when the box is selected.
The OPN or OPNI box is present alone in a network without a preceding logic oper- ation.
A detailed description of the OPN or OPNI box is provided in Chapter 14.5.1 “Open- ing a data block” on page 583.
Opening a data block using block parameters
A block parameter with parameter type BLOCK_DB allows the transfer of a data block (or more precisely: a data block number) to the called block. You call this data block as a global data block in the called block with the OPN box via the DB register.
Calling of a data block transferred with BLOCK_DB is not possible via the DI register.
Block change, CALL box
To program the CALL box, drag it with the mouse from the program elements cata- log under Basic instructions > Further instructions to the working area. With CALL, you call a code block which must not have any block parameters.
The CALL box is present alone in a network. If the CALL box does not have a preced- ing logic operation, the block call is carried out without conditions.
A detailed description of the CALL box is provided in Chapter 14.4.4 “Change to a block without block parameter” on page 581.
Block call functions
Calling of blocks is represented by EN/ENO boxes. With functions (FC), the block name is present quasi as a function name in the box; with function blocks, the in- stance name (the name of the instance data block or the name of the local instance) is additionally present above the box. A detailed description of the block calls is pro- vided in Chapter 14.4 “Calling of code blocks” on page 576.
To call a code block, use the mouse to drag the block which has already been programmed from the project tree under Program blocks into the working area.
With a logic operation preceding the EN input you can structure the block call depending on conditions.
Network 29 in Fig. 8.36 shows the call of a function (FC). The function name is pres- ent as the title in the call box. In the event of an error in the block (ENO is then “0”),
#Adder_error is set to “0” and a jump made to the network with the Error label. In network 30, the call of a function block is present as a single instance. The name of the function block is present as the title in the call box, the instance name – in this case the name of the instance data block – is present above the box.
8.6.5 Master Control Relay (MCR)
The Master Control Relay controls write operations to the user memory. A detailed description of the MCR functions is provided in Chapter 14.6 “Master control relay”
on page 587.
You use the MCRA and MCRD boxes to define an MCR area. The two boxes are each present alone in a network.
You use the MCR< box to open an MCR zone. The box requires a preceding logic operation and terminates a logic operation. If the result of the logic operation is = “1”, the MCR dependency is switched off (“normal” processing); if the RLO = “0”, the MCR dependency is switched on.
Fig. 8.37 MCR dependency and MCR zone in the FBD representation
The MCR> box closes an MCR zone and is present alone in a network.
To program the corresponding MCR function, drag it with the mouse from the program elements catalog under Basic instructions > Further instructions to the working area. You can subsequently set the function (MCR<, MCR>, MCRA, or MCRD) via a drop-down list which you can open using the small yellow triangle when the coil is selected.
Fig. 8.37 shows the functions and networks required to switch the MCR dependency on and off.
If MCR dependency is switched on, the following system blocks influence the oper- ands in the I/O range, in the process image, and in the bit memory address area:
b SET, SETI, and SETP set the parameterized operands to signal state “1”,
b RESET, RESETI, and RESETP reset the parameterized operands to signal state “0”.
The system blocks can be found in the program elements catalog under Basic instructions > Further instructions. A detailed description of these blocks is provided in Chapter 13.2.6 “Control memory area with MCR dependency” on page 515.
9 Statement list STL