Description
The "Get error locally" instruction is used to query the occurrence of errors within a program block. This normally involves programming or access errors. If the system reports an error during the execution of the program block, detailed information is stored in the operand at the ERROR output for the first error to occur during the execution of the block since the last execution of the instruction.
Only operands of the "ErrorStruct" system data type can be specified at the ERROR output. The "ErrorStruct" system data type specifies the exact structure in which the information about the error is stored. Using additional instructions, you can evaluate this structure and program an appropriate response. If several errors occur in the program block, the error information about the next error to occur is output by the instruction only after the first error that occurred has been remedied.
|
Note Output ERROR The ERROR output is only changed if error information is present. To set the output back to "0" after handling an error, you have the following options:
|
The enable output ENO is only set if the enable input EN returns signal state "1" and error information is present. If one of these conditions does not apply, then the remaining program execution is not affected by the instruction.
|
Note Activation of the local error handling As soon as you insert the instruction in the program code of a program block, the local error handling is activated and default system reactions are ignored when errors occur. |
Options for error handling
You can find an overview of the options for error handling here: Overview of mechanisms for error handling
For a detailed example of local error handling that contains several error handling options, refer to: Example of how to handle program execution errors
Parameters
The following table shows the parameters of the "Get error locally" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|---|---|---|---|---|
|
EN |
Input |
BOOL |
I, Q, M, D, L or constant |
Enable input |
|
ENO |
Output |
BOOL |
I, Q, M, D, L |
Enable output |
|
ERROR |
Output |
ErrorStruct |
D, L |
Error information |
Data type "ErrorStruct"
The "ErrorStruct" data type can be inserted in a global data block or in the block interface. You can insert the data type more then once if you assign a different name for the data structure each time. The data structure and the name of individual structure elements cannot be changed. If you save the error information in a global data block, it can also be read out by other program blocks.
The following table shows the structure of the "ErrorStruct" data type:
|
Structure component |
Data type |
Description |
|
|---|---|---|---|
|
ERROR_ID |
WORD |
Error ID |
|
|
FLAGS |
BYTE |
Shows whether the error occurred during a program block call. 16#01: Error during a program block call 16#00: No error during a program block call |
|
|
REACTION |
BYTE |
Default reaction: 0: Ignore (write error) 1: Continue with substitute value "0" (read error) 2: Skip instruction (system error) |
|
|
CODE_ADDRESS |
CREF |
Information about the address and type of the program block |
|
|
BLOCK_TYPE |
BYTE |
Program block type in which the error occurred: 1: Organization block (OB) 2: Function (FC) 3: Function block (FB) |
|
|
CB_NUMBER |
UINT |
Number of the code block |
|
|
OFFSET |
UDINT |
Reference to the internal memory |
|
|
MODE |
BYTE |
Information about the address of an operand |
|
|
OPERAND_NUMBER |
UINT |
Operand number of the machine command |
|
|
POINTER_NUMBER_LOCATION |
UINT |
(A) Internal pointer |
|
|
SLOT_NUMBER_SCOPE |
UINT |
(B) Storage area in internal memory |
|
|
DATA_ADDRESS |
NREF |
Information about the address of an operand |
|
|
AREA |
BYTE |
(C) Memory area: L: 16#40...16#7F, 16#86, 16#87, 16#8E, 16#8F, 16#C0...16#FF I: 16#81 Q: 16#82 M: 16#83 DB: 16#40, 16#84, 16#85, 16#8A, 16#8B PI: 16#01 PQ: 16#02 Technological objects: 16#04 |
|
|
DB_NUMBER |
UINT |
(D) Number of the data block |
|
|
OFFSET |
UDINT |
(E) Relative address of the operand |
|
Structure component "ERROR_ID"
The following table shows the values that can be output at the structure component "ERROR_ID":
|
ID* |
ID* |
Description |
|---|---|---|
|
0 |
0 |
No error |
|
2503 |
9475 |
Invalid pointer |
|
2520 |
9504 |
Invalid STRING |
|
2522 |
9506 |
Read error: Operand outside the valid range |
|
2523 |
9507 |
Write error: Operand outside the valid range |
|
2524 |
9508 |
Read error: Invalid operand |
|
2525 |
9509 |
Write error: Invalid operand |
|
2528 |
9512 |
Read error: Data alignment |
|
2529 |
9513 |
Write error: Data alignment |
|
252C |
9516 |
Invalid pointer |
|
2530 |
9520 |
Write error: Data block |
|
2533 |
9523 |
Invalid reference used |
|
2538 |
9528 |
Access error: DB does not exist |
|
2539 |
9529 |
Access error: Wrong DB used |
|
253A |
9530 |
Global data block does not exist |
|
253C |
9532 |
Faulty information or the function does not exist |
|
253D |
9533 |
System function does not exist |
|
253E |
9534 |
Faulty information or the function block does not exist |
|
253F |
9535 |
System block does not exist |
|
2550 |
9552 |
Access error: DB does not exist |
|
2551 |
9553 |
Access error: Wrong DB used |
|
2575 |
9589 |
Error in the program nesting depth |
|
2576 |
9590 |
Error in the local data distribution |
|
2577 |
9591 |
The block property "Parameter passing via registers" is not selected. |
|
25A0 |
9632 |
Internal error in TP |
|
25A1 |
9633 |
Tag is write-protected |
|
25A2 |
9634 |
Invalid numerical value of tag |
|
2942 |
10562 |
Read error: Input |
|
2943 |
10563 |
Write error: Output |
|
* The error codes can be displayed as integer or hexadecimal values in the program editor. You can find information on switching the display formats under "See also". |
||
Example
The following example shows how the instruction works:
An error occurred accessing the #Field[#index] tag. The enable output ENO of the "Multiply" instruction and the #TagOut_Enabled operand have signal state "1" despite the read/access error and the multiplication is performed with the value "0.0". If this error scenario occurs, it is recommended to program the "Get error locally" instruction after the "Multiply" instruction to get the error. The error information supplied by the "Get error locally" instruction is evaluated with the comparison instruction "Equal". If the "#Error.REACTION" structure component has the value "1", this involves a read/access error and the #TagOut_Enabled output is reset.