Technical data

Diagnostics
23.9 Program Measures for Handling Errors
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 509
The following sample program could be written in OB122. The following table shows the temporary
variables that must be declared, in this case, in the variable declaration table of OB122.
Decl. Name Type Description
TEMP OB122EVCLASS BYTE Error class/error ID 29xx
TEMP OB122SWFLT BYTE Error code:
16#42, 16#43, 16#44
1)
, 16#45
1)
TEMP OB122PRIORITY BYTE Priority class = priority of the OB in which the error
occurred
TEMP OB122OBNUMBR BYTE 122 = OB122
TEMP OB122BLKTYPE BYTE Block type in which the error occurred
TEMP OB122MEMAREA BYTE Memory area and type of access
TEMP OB122MEMADDR WORD Address in the memory at which the error occurred
TEMP OB122BLKNUM WORD Number of the block in which the error occurred
TEMP OB122PRGADDR WORD Relative address of the instruction that caused the
error
TEMP OB122DATETIME DATEANDTIME Date and time at which the OB was started
TEMP Error INT Saves the error code of SFC44
1)
Not with the S7-300.
STL Description
L B#16#2942
L #OB122SWFLT
==I
JC Aerr
L B#16#2943
<> I
JC Stop
Aerr: CALL "REPL_VAL"
VAL : = DW#16#2912
RETVAL : = #Error
L #Error
L 0
==I
BEC
Stop: CALL "STP"
Compare the event code of OB122 with the event code
(B#16#2942) for the acknowledgement of a time error when
reading the I/O. If the same, jump to "Aerr".
Compare the event code of OB122 with the event code
(B#16#2943) for an addressing error (writing to a module
that does not exist). If not the same, jump to "Stop."
Label "Aerr": transfers DW#16#2912 (binary 10010) to
SFC44 (REPL_VAL). SFC44 loads this value in accumulator
1 (and substitutes the value that triggered the OB122
call). The SFC error code is saved in #Error.
Compare #Error with 0 (if the same, no error occurred
when executing OB122). End the block if no error occurred.
"Stop" label: calls SFC46 "STP" and changes the CPU to
STOP mode.