Which Organization Blocks Are Required for Error Handling in S7-CPU?

 Description

The S7-CPU module can identify the following types of errors:
Synchronous Errors
These errors are triggered by specific operations during the execution of the user program and can be pinpointed to a specific part of the user program.
Asynchronous Errors
These errors cannot be directly attributed to the running user program. They include priority class errors, automation system errors (module errors), or redundancy errors. The table below provides an overview of the situations in which organization blocks (OBs) are called and executed when synchronous or asynchronous errors occur. If the relevant error OB has not been downloaded, the CPU will enter STOP mode (exceptions: OB 70, OB 72, OB 73, and OB 81).



You can view which organization blocks can be enabled in the “Interrupts” tab of the CPU properties, allowing them to be inserted into the STEP 7 project.



Through the menu command "Options > Report System Error..." in the hardware configuration page, you can also easily add error-handling OBs.
Notes on Using Error OBs
When an error occurs, to ensure reliable and trouble-free operation, it is necessary to write a fault-handling program—at the very least, a program to generate alarm messages when an error occurs. This is because hazardous conditions may go unnoticed if the CPU does not enter STOP mode. Note that only H CPUs support OB 70 and OB 72. OB 73 is only applicable to CPU 417-4H V2.0.X. For more information on error OBs, refer to the STEP 7 online help: “Error evaluation in OB122 has changed for 400-series CPUs” - Entry ID: 5708202. Keywords: “Generate Error OB,” “Set System Error Report Information.” For details on which OBs need to be downloaded to the CPU to prevent it from entering STOP mode when a remote I/O error occurs, see Entry ID: 19350076.
Example of Power Supply Failure
When an event is triggered by a power supply failure (specific to S7-400 PLCs) or a backup battery failure, the CPU’s operating system calls OB81. Once the error is cleared, OB81 is called again. For an S7-400 with a battery failure, OB81 is only called if the BATT.INDIC switch is activated for battery monitoring. If OB81 is not programmed, the CPU will not enter STOP mode. If OB81 is unavailable, the CPU will remain in RUN mode during a power failure.
In the example program, the temporary variable "OB81_FLT_ID" from OB81 is used to evaluate and determine a battery failure. In this case, the error code for the variable is "22hex." If the condition is met in a comparison query (battery failure), the flag M81.1 is set. Two event levels can be identified via the variable "OB81_EV_CLASS":
  • B#16#39: Incoming event, battery failure.
  • B#16#38: Outgoing event, battery failure cleared.
Based on the evaluation of these variables, the flag M81.0 is reset. If the status of flags M81.1 and M81.2 is "TRUE" (in the case of an incoming power failure event), the flag M81.0 is set. When the event ID indicates an outgoing event (M81.6 = TRUE), the flag M81.0 is reset.


The example described above applies to a situation where the CPU is in RUN mode and a battery failure occurs. If the battery failure occurs in STOP mode, the incoming event (calling OB81) is only triggered when the CPU re-enters RUN mode. If the power is turned off, the incoming event (battery failure) will not be triggered.
Additional Information
For more details on error OBs, refer to the STEP 7 online help or the reference manual “System Software for S7-300/400 System and Standard Functions,” Entry ID: 1214574.