System Status List
11.6 Error OBs as a Reaction to Detected Errors
The system program can detect the following errors:
S CPU functioning incorrectly
S Error in the system program execution S Error in the user program
S Error in the I/Os
Depending on the type of error, the CPU is set to the STOP mode or an error OB is called.
You can design programs to react to the various types of errors and to determine the way in which the CPU reacts. The program for a particular error can then be saved in an error OB. If the error OB is called, the program is executed.
An error occurs...
If an error OB is programmed, the CPU executes the program in the OB.
If no OB is programmed, the CPU changes to the STOP mode (exception OB81).
The CPU calls the corresponding error OB.
Figure 11-3 Error OBs as a Reaction to Detected Errors
A distinction is made between synchronous and asynchronous errors as follows:
S Synchronous errors can be assigned to an MC7 instruction (for example load instruction for a signal module that has been removed).
S Asynchronous errors can be assigned to a priority class or to the entire programmable logic controller (for example cycle time exceeded).
Table 11-6 shows what types of errors can occur. Refer to the CPU descriptions in the manuals /70/ or /101/ to find out whether your CPU provides the specified OBs.
Detectable Errors
Programming Reactions
Error OBs
长沙工控帮教育科技有限公司整理
Table 11-6 Error OBs
Error Class Error Type OB Priority
Asynchronous Time error OB80 26
Power supply error OB81 (or 28 if the error OB is called in the Diagnostic interrupt OB82 OB is called in the startup program) Remove/insert module interrupt OB83
p p g )
CPU hardware fault OB84
Priority class error OB85
Rack failure OB86
Communication error OB87
Synchronous Programming error OB121 Priority of the OB that caused the error Access error OB122 that caused the error
Using the local data (start information) of the error OB, you can evaluate the type of error that has occurred.
If, for example, the CPU detects a battery fault, the operating system calls OB81 (see Figure 11-4). You can write a program that evaluates the event code triggered by the OB81 call. You can also write a program that brings about a reaction, such as activating an output connected to a lamp on the operator station.
The CPU detects a battery fault.
OB81 checks the type of power supply fault that was detected and indicates whether or not the problem resulted from a battery failure.
21 Battery exhausted (central rack) 1 22 No backup power
(central rack)
23 24 V power supply failed (central rack) 1
31 Battery exhausted (expansion rack) 1 32 No backup power
(expansion rack) 1 33 24 V power supply failed
(expansion rack) 1
Types of power supply fault
1 Not with the S7-300.
Figure 11-4 Using the Local Data of an Error OB Example of Using
Error OB81
长沙工控帮教育科技有限公司整理
Table 11-7 describes the temporary (TEMP) variables declared in the variable declaration table of OB81.
The symbol Battery_error (BOOL) must also be identified as an output in the symbol table (for example Q 4.0) so that other parts of the program can access this data.
Table 11-7 Variable Declaration Table of OB81
Decl. Name Type Description
TEMP OB81_EV_CLASS BYTE Error class/error identifier 39xx
TEMP OB81_FLT_ID BYTE Error code:
b#16#21 = At least one backup battery of the CPU is exhausted 1
b#16#22 = No backup voltage in the CPU b#16#23 = Failure of the 24 V power supply in
the CPU 1
b#16#31 = At least one backup battery of an expansion rack is exhausted 1 b#16#32 = Backup voltage not present in an
expansion rack 1
b#16#33 = Failure of the 24 V power supply of an expansion rack 1
TEMP OB81_PRIORITY BYTE Priority class = 26/28
TEMP OB81_OB_NUMBR BYTE 81 = OB81
TEMP OB81_RESERVED_1 BYTE Reserved
TEMP OB81_RESERVED_2 BYTE Reserved
TEMP OB81_MDL_ADDR INT Reserved
TEMP OB81_RESERVED_3 BYTE Only relevant for error codes B#16#31, B#16#32, B#16#33
TEMP OB81_RESERVED_4 BYTE B#16#33
TEMP OB81_RESERVED_5 BYTE
TEMP OB81_RESERVED_6 BYTE
TEMP OB81_DATE_TIME DATE_AND_
TIME
Date and time at which the OB was started
1 Not with the S7-300.
Local Data of the Error OB81
长沙工控帮教育科技有限公司整理
The sample STL program shows how you can read the error code in OB81.
The program is designed as follows:
S The error code in OB81 (OB81_FLT_ID) is read and compared with the value of the event “battery exhausted” (B#16#3921).
S If the error code corresponds to the code for “battery exhausted”, the program jumps to the label Berr and activates the output Battery_error.
S If the error code does not correspond to the code for “battery exhausted”, the program compares the code with the code for “Battery failure”.
S If the error code corresponds to the code for “Battery failure” the program jumps to the label Berr and activates the output Battery_error. Otherwise the block is terminated.
STL Description
L B#16#3921 L #OB81_FLT_ID
== I JC Berr L b#16#3922
<> I BEC
Berr: S #Battery_error
Compare event code “battery exhausted”
(B#16#3921) with the error code for OB81.
If the same (battery is exhausted), then jump to Berr.
Compare event code “battery failure”
(b#16#3922) with the error code for OB81.
If not the same (no battery failure in the CPU), then terminate the block.
Berr sets the output “Battery_error” if a battery failure or an exhausted battery is detected.
Note
The error codes of all organization blocks are described in the STEP 7 online help and in the reference manual /235/.
Sample Program for the Error OB81
长沙工控帮教育科技有限公司整理