Configuring S7 Error OBs to Prevent CPU STOP on Hardware Faults

David Krause18 min read
PLC HardwareSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Configuring S7 Error OBs to Prevent CPU STOP on Hardware Faults

On Siemens S7-300, S7-400, S7-1200, and S7-1500 controllers, every detected runtime fault is routed by the operating system to a dedicated Organization Block (OB). If the corresponding OB is not present in the user program, the CPU escalates the event and transitions to STOP. The standard engineering response is therefore to download the appropriate Error OB into the load memory. An empty OB is sufficient to suppress the STOP transition; a programmed OB lets you react to the event, log it, or fail over to a safe state.

This reference covers the full family of S7 Error OBs, the priority classes that govern their execution, the STEP 7 V5.x and TIA Portal procedures for adding them, and the diagnostic information the OBs make available. It also addresses the common field case where an engineer removes or swaps a distributed I/O module during commissioning and watches the CPU drop into STOP because OB83 / OB86 have not been loaded.

Field rule of thumb: If the only objective is to keep the CPU running while an error is investigated, load an empty OB. If the system is going into service, write the OB so the fault is at least logged to the diagnostic buffer and an HMI flag is set for the operator.

1. Why an Unhandled Error Drives the S7 CPU to STOP

The S7 CPU operating system executes a deterministic scan cycle. When a fault is detected during I/O update, communication processing, or program execution, the OS queries the OB registry for the matching error OB:

  1. The fault is classified into one of the OB80–OB87 (synchronous/asynchronous hardware errors) or OB121/OB122 (program execution errors) categories.
  2. If the matching OB exists in the load memory, it is started according to its priority class. The main cyclic OB (OB1) is paused for the duration of the error OB.
  3. If the matching OB is not present, the OS calls the OB102 (cold restart) / OB88 / OB121 / OB122 / OB80 fault routine depending on firmware, and finally transitions the CPU to STOP. The SF (System Fault) LED turns on, and the diagnostic buffer records the entry “STOP due to missing OB” with the OB number.

Loading the OB into the load memory is therefore a hard requirement for continued operation. The OB does not need to contain any code; an empty body satisfies the OS and the CPU remains in RUN.

2. The S7 Error OB Family at a Glance

The following table consolidates every standard error OB across the S7-300/400 and S7-1200/1500 lines. Some entries apply only to certain CPU series; this is called out in the “Applicable platforms” column.

OB Name Trigger Priority Applicable platforms
OB70 I/O redundancy error Loss of redundancy on an I/O pair in an H-system 25 S7-400 H only
OB72 CPU redundancy error Loss of CPU redundancy, master/role change 28 S7-400 H only
OB73 Communication redundancy error Loss of a redundant communication link 25 S7-400 H only
OB80 Time error Cycle time exceeded; OB1 still running when time slice elapses 26 S7-300/400, S7-1200/1500
OB81 Power supply error Failure of a 24 V sensor supply, battery low, backup failure 25/26/27 S7-300/400, S7-1500
OB82 Diagnostic interrupt Module reports a diagnostic event (channel fault, wire break, overtemperature) 24–26 S7-300/400, S7-1200/1500
OB83 Insert/Remove module interrupt Module pulled or inserted during RUN on a hot-swap capable station 24 S7-300/400 (with active backplane), S7-1200/1500 (ET 200SP)
OB84 CPU hardware fault MPI/Profibus/PROFINET interface fault, DP slave lost, hardware link failure 24/25/28 S7-300/400, S7-1500
OB85 Priority class error Update of process image failed; OB called that does not exist; I/O fault during OB startup 24 S7-300/400, S7-1200/1500
OB86 Rack/Station failure Failure of a Profibus slave, PROFINET device, or expansion rack 24 S7-300/400, S7-1200/1500
OB87 Communication error Global data communication error, S7 connection failure, time sync lost 24 S7-300/400, S7-1500
OB121 Programming error DB not loaded, range error, illegal data type, BCD conversion overflow Same as OB that caused the error S7-300/400, S7-1200/1500
OB122 I/O access error Read/write access to a faulty or missing I/O address during program execution Same as OB that caused the error S7-300/400, S7-1200/1500
How to read priority: A higher number wins when two OBs are pending simultaneously. OB80/81/82/83/84/85/86/87 can interrupt OB1 (priority 1). OB121/OB122 share the priority of the OB in which the error occurred, so they cannot escalate above their caller.

3. Priority Classes and OB Execution Order

The priority class determines whether an error OB can interrupt the currently executing OB. The table below shows how priority is assigned in firmware V4.x for S7-300/400 and V2.x for S7-1500. Newer firmware revisions expose the priorities in the OB properties dialog.

Priority range Example OBs Pre-empt OB1? Local data requirement
1 (OB1) Main cyclic n/a Default 256 bytes
2–7 Time-of-day OB10–OB17 Yes Default 256 bytes; configurable per OB
9–12 Delay OB20–OB23 Yes Default 256 bytes
16–23 Cyclic interrupt OB30–OB38 Yes Default 256 bytes
24 OB82/83/85/86/87 Yes Default 256 bytes; expand for diagnostic
25–28 OB70/72/73/80/81/84 Yes Default 256 bytes

The local data stack is shared across all OBs in a priority class. If an error OB is allocated 256 bytes by default but the code uses more, the stack will overflow and OB85 (priority class error) will be raised. When writing a diagnostic-heavy OB82, raise the local data allocation in the OB properties (STEP 7) or in the OB’s “Properties > General > Local Data Stack” tab (TIA Portal).

4. Prerequisites Before Adding an Error OB

Before loading an error OB, confirm the following items. Each one is a separate failure mode that produces confusing symptoms if missed.

  • Project match. The offline project must match the online CPU firmware. Mismatched firmware versions on S7-1500 generate a download rejection with error code “Online/offline difference”.
  • User rights. The PG/PC must have the project password or the CPU must be in a state that allows program changes. Without rights, the online OB cannot be loaded.
  • CPU mode. To load a new OB during commissioning, the CPU must be in STOP or in “RUN with test…program changes” (S7-300/400) / “RUN with extended program modifications” (S7-1500 with firmware V2.6 or later).
  • Available load memory. Each empty OB occupies roughly 200–400 bytes of load memory. S7-300 CPUs with a 64 KB MMC will refuse a download that exceeds free memory.
  • Hot-swap capable hardware. If the goal is to prevent STOP on module removal, the rack or station must physically support hot swapping. Standard S7-300 IM153 does not; ET 200S, ET 200M with active backplane, and ET 200SP do.

5. Step-by-Step: Adding an Empty Error OB in STEP 7 V5.x (S7-300/400)

The classic SIMATIC Manager workflow for adding an error OB to a STEP 7 V5.x project is shown below. The same logic applies to S7-300 and S7-400.

  1. Open the project and expand the S7 program node in the project tree.
  2. Right-click Blocks and select Insert New Object > Organization Block (OB).
  3. In the “Properties – Organization Block” dialog, set the symbolic name and click the dropdown under “OB”. The list shows all OBs valid for the selected CPU; the fault interrupts are grouped at the bottom.
  4. Select OB82 (Diagnostic Interrupt) for a module fault, OB83 for module removal, OB86 for station failure, and so on.
  5. Accept the default priority, leave the body empty, and click OK.
  6. Repeat for every OB that the application might trigger. A minimum recommended set is OB80, OB82, OB85, OB86, OB121, OB122.
  7. Select all OBs in the block folder, right-click, and choose Download. Confirm the target module selection. The CPU will accept the new blocks in RUN (with the “Test…Program changes” option on S7-400) or require a STOP transition for S7-300.
  8. Open PLC > Diagnostic/Setting > Module Information and verify the OBs are present under the “Block Folder” tab. The diagnostic buffer should now record event class “OB Start” entries instead of STOP transitions when the corresponding fault occurs.
Why the CPU still went to STOP during testing: If you pulled a module from a non-hot-swap station, the missing OB83/OB86 is only half the story. The station itself must be ET 200S, ET 200M with active backplane, or ET 200SP. Standard S7-300 IM153 / IM360 stations will signal a station failure regardless of OBs once a slot is empty. Configure the hardware as “Module replacement during operation” in HW Config and assign OB83/OB86 before relying on this path.

6. Step-by-Step: Adding an Error OB in TIA Portal (S7-1200/1500)

The TIA Portal workflow exposes every OB through the “Add new block” dialog. The procedure below has been validated on TIA Portal V17 and V18 with S7-1500 CPUs running firmware V2.9.

  1. Open the project and expand PLC_x > Program blocks in the project tree.
  2. Double-click Add new block.
  3. In the dialog, choose the Organization block category and use the search filter to type “Error” or scroll to the fault interrupt section.
  4. Select the desired OB number (OB82, OB83, OB86, etc.). TIA Portal automatically pre-fills the symbolic name and the language (LAD/FBD/SCL/STL are all supported; SCL is recommended for diagnostic bodies).
  5. Click OK. The OB editor opens with the standard interface declarations already populated (Temp variables for the start info).
  6. Optionally add code. The minimum body that satisfies the OS is empty.
  7. Compile the project (Project tree > right-click CPU > Compile > Software).
  8. Download to the device (Online > Download to device). On S7-1500 with firmware V2.6 or later, the download can occur in RUN through the “Download to device” wizard if the OB does not modify the same data blocks currently being read by OB1.
  9. Open Online > Online & Diagnostics > Diagnostics buffer and verify the new event class entries “OB82 START” / “OB86 START” appear after a forced fault.

The TIA Portal adds two features that are not present in STEP 7 V5.x: the OB’s start info is automatically decoded into named temporary variables (for example OB86_FLT_IOID), and the diagnostic event is integrated with the ProDiag fault model introduced in TIA V15.1. If ProDiag is enabled, the same OB82 instance can be reused across multiple supervised blocks.

7. Empty OB vs Programmed OB: Choosing the Right Strategy

Loading an empty OB is the minimum acceptable response for a non-safety machine that must keep cycling while maintenance is performed. It is not, however, a substitute for proper error handling. The trade-offs are summarized below.

Strategy CPU behavior on fault Operator visibility Maintenance cost Recommended use
Empty OB Fault logged, CPU stays in RUN None (only diagnostic buffer) Lowest (single download) Commissioning, non-safety skid, lab test rig
Programmed OB (flag + buffer write) Fault logged and visible on HMI High (HMI tag goes true) Moderate Production lines, OEM machinery
ProDiag / GRACEFUL_STOP routine Fault logged, supervised block transitions to safe state Highest Highest (TIA V15.1+ required) Modular machines, FDA/regulated process

A standard compromise is to use the OB to set a global flag, write the event ID to a ring buffer DB, and call a function block that raises an HMI alarm. The skeleton in the next section implements this pattern.

8. Module Removal and the Hot-Swap Question

A recurring failure pattern is the engineer who disconnects a module on the workbench to simulate a failure and watches the CPU drop into STOP. The presence of OB83 / OB86 is necessary but not sufficient; the hardware must be configured for “module replacement during operation”.

Distributed I/O family Hot-swap capable? Required CPU/proxy OBs that must be loaded
ET 200S Yes (IM151-1 with active backplane) Any S7-300/400/1200/1500 OB82, OB83, OB86
ET 200M (active backplane) Yes (BM IM/IM 153-2 with redundant PS) S7-400, S7-1500 OB82, OB83, OB86
ET 200M (passive backplane) No All OB86 only; OB83 not triggered
ET 200SP Yes S7-1500 (PROFINET), S7-1200 V4+ OB82, OB83, OB86
ET 200pro Yes Any with PROFINET OB82, OB83, OB86
ET 200AL Yes S7-1500, ET 200SP OB82, OB83, OB86
Standard IM153-1 / IM360 rack No S7-300/400 OB85 / OB86 will still fire on slot removal; expect degraded behavior
Profinet station failure vs PROFINET module failure: OB86 fires once when a station disappears from the network. OB82 fires for a single module’s diagnostic event inside a station. OB83 fires on a per-slot insert/remove inside a station. If only OB86 is loaded, individual slot events will still produce an SF LED and may stall the cyclic OB if OB83 is missing.

9. OB Start Information and Diagnostic Buffer

Each error OB receives a fixed-length start info block in the local data stack. The first 20 bytes are common to all OBs; the remaining bytes are OB-specific. The table below lists the most useful variables for S7-1500 OB82/OB83/OB86; S7-300/400 follows the same layout but with a different byte offset in some cases (see the system manual for the exact byte position).

Variable Type Meaning (OB82) Meaning (OB83) Meaning (OB86)
OBxx_EV_CLASS BYTE Event class (0x39 = diagnostic event coming) 0x33 / 0x34 = module insert/remove 0x38 / 0x39 = station failure / return
OBxx_FLT_ID BYTE Fault ID (1 = channel fault, etc.) Fault ID (0x61 = insert, 0x63 = remove) Fault ID (0xC4 = station failure)
OB82_IO_FLAG BOOL 1 = input, 0 = output n/a n/a
OB82_MDL_ADDR WORD Logical base address of the module Logical base address Logical base address of station
OB82_CHANNEL UINT Channel number (0–31) n/a n/a
OB82_DIAG_INFO DWORD Channel diagnostic status word n/a n/a
OB83_IO_FLAG BOOL n/a 1 = input, 0 = output n/a
OB86_FLT_IOID BYTE n/a n/a Sub-module ID (PROFINET/Profibus)
OB86_RACK_NO UINT n/a n/a Rack or station number
Date_Time (local 8 bytes) DATE_AND_TIME Time of fault Time of fault Time of fault

For S7-300/400 in STEP 7 V5.x, the same variables are accessed via the absolute local data stack at fixed offsets (for example OB82_FLT_ID at byte offset 13). The TIA Portal naming convention used above applies to S7-1200/1500 from firmware V2.0 onward.

10. Sample Error OB Bodies (STL, SCL, LAD)

The three code blocks below implement the same pattern: set a global “fault present” flag, write the start info to a ring buffer DB, and acknowledge the event on the diagnostic buffer so the SF LED clears when the cause is removed.

STEP 7 V5.x STL snippet for OB82:

// OB82 - Diagnostic interrupt (S7-300/400)
// Increment ring buffer write pointer
      L     DB99.DB10    // RingBuffer.WriteIndex (WORD)
      +     1
      T     DB99.DB10
      L     64
      MOD
      T     DB99.DB10

// Store fault ID + module address
      L     OB82_MDL_ADDR
      T     DB99.DBD[DB99.DB10 * 8 + 0]
      L     OB82_FLT_ID
      T     DB99.DBB[DB99.DB10 * 8 + 4]

// Set global fault flag
      SET
      =     DB99.DBX14.0   // DiagnosticFaultActive

TIA Portal SCL snippet for OB86 (S7-1500):

// OB86 - Rack/Station failure (S7-1500, SCL)
#RingBuf[#RingBuf.WriteIndex].Timestamp := OB86_DATE_TIME;
#RingBuf[#RingBuf.WriteIndex].FltId      := OB86_FLT_ID;
#RingBuf[#RingBuf.WriteIndex].RackNo     := OB86_RACK_NO;
#RingBuf[#RingBuf.WriteIndex].IoId       := OB86_FLT_IOID;
#RingBuf[#RingBuf.WriteIndex].MdlAddr    := OB86_MDL_ADDR;
#RingBuf.WriteIndex := (#RingBuf.WriteIndex + 1) MOD 64;

// Persistent flag for HMI
"Fault".StationFailed := TRUE;

TIA Portal LAD snippet for OB83:

// OB83 - Insert/Remove interrupt
[OB83_FLT_ID = B#16#63] // 0x63 = module removed
   --("ModuleRemoved") ; HMI alarm tag
[OB83_FLT_ID = B#16#61] // 0x61 = module inserted
   --("ModuleInserted"); HMI alarm tag
Clearing the SF LED: On S7-300/400, the diagnostic interrupt bit must be acknowledged inside the OB (for example with ACK_OP in the user program or by writing to the module’s diagnostic status). On S7-1500, the SF LED is cleared automatically when the diagnostic event disappears and OB82 is exited cleanly. If the LED stays on, the start info was not consumed or the module is still reporting the fault.

11. Verification and Commissioning Procedure

Use the following sequence after loading the error OBs to confirm that the CPU will not enter STOP on a forced fault.

  1. Open Online & Diagnostics in TIA Portal (or PLC > Module Information in STEP 7 V5.x). Note the current operating mode and diagnostic buffer state.
  2. From Online & Diagnostics > Diagnostics buffer, clear the buffer (right-click > Clear) so the test events are isolated.
  3. Force the desired fault. For OB82/OB83, simulate by removing a terminal block on a digital input module of a hot-swap station. For OB86, disconnect the Profibus/PROFINET cable to a DP slave/IO device. For OB85, configure a process image update on a slot that has no module.
  4. Verify the CPU remains in RUN. The diagnostic buffer should now show the OB start event followed by the OB exit event.
  5. Confirm the SF LED does not latch on once the fault is removed. If it does, the start info was not consumed or the module is still asserting the diagnostic interrupt.
  6. Restore the original wiring and confirm the OB exits within the configured monitoring time (default 5 s on S7-1500 for PROFINET station failure).
  7. Open Online & Diagnostics > Cycle time / load memory and confirm that the OB execution does not blow the cycle time budget. An OB82 with extensive ring buffer writes can push a 4 ms cycle to 6–7 ms; increase the OB1 watch-dog or trim the code.

12. Troubleshooting Matrix

Symptom Likely root cause OB or configuration to add Reference
CPU drops to STOP on DI module wire break OB82 not loaded, OR module diagnostic not enabled in HW Config OB82; enable “Diagnostic interrupt” in module properties Module diagnostics manual
CPU drops to STOP on PROFINET device unplug OB86 missing; PROFINET station not assigned to a hot-swap group OB86; set station “Module replacement during operation” in device configuration PROFINET commissioning manual
CPU drops to STOP on ET 200SP module swap OB83 missing, OR base unit is type C0 (no hot swap) OB83; replace base unit with type C1 or higher ET 200SP system manual
CPU drops to STOP on cycle time overflow OB80 not loaded; OB1 watch-dog tripped OB80; investigate what is consuming cycle time S7 system manual, “Cyclic interrupt” chapter
CPU drops to STOP on DB not loaded OB121 not loaded OB121; ensure DB is generated before first access STEP 7 online help, “Programming error”
CPU drops to STOP on read of a missing I/O address OB122 not loaded OB122; verify that I/O address is configured STEP 7 online help, “I/O access error”
SF LED stays on after fault cleared OB did not consume start info or module still asserts diagnostic interrupt Check OB body; on S7-300/400 call ACK_OP S7-300/400 system manual
CPU runs but no OB events recorded OB loaded but priority too low; check OB properties “Priority” Confirm priority matches the table in section 2 TIA Portal help “Organization blocks”
CPU only stays in STOP on rack 0 slot 3 missing module Central rack does not support hot swap; OB83/OB86 will not save you Move module to distributed I/O or accept STOP behavior S7-300/400 system manual
Programmed OB82 causes OB85 (priority class error) Local data stack exhausted by diagnostic code Increase local data allocation in OB properties TIA Portal help “Local data stack”

For further reference, the Siemens Industry Online Support portal publishes a FAQ catalog with examples of programmed error OBs. The legacy entry 42781106 in the Siemens support database is the canonical sample for STEP 7 V5.x; TIA Portal examples are available under the “Application Examples > Error Handling” filter on support.industry.siemens.com. Use the search string “OB82 OB86 S7 example” and filter to “Application” content type to surface the most current code.

Do I really need every error OB in the table, or is just OB82 enough?

At a minimum, load OB82, OB85, OB86, OB121, and OB122. OB82 covers channel diagnostic events, OB85 covers the “OB not loaded” class error that will otherwise take the CPU down if any other OB is missing, OB86 covers station failure, and OB121/OB122 cover all program-side errors. OB80, OB83, OB84, OB87 are only required if your hardware actually generates those events (cycle overflow, hot-swap modules, MPI/Profibus fault, time-sync loss).

Can I download a new error OB without stopping the CPU?

On S7-400 with STEP 7 V5.x, yes, using “PLC > Download to Target System” while the CPU is in RUN with the “Test…Program Changes” option enabled. On S7-1500 with firmware V2.6 or later, yes, via the TIA Portal “Download to device” wizard. On S7-300, the CPU must be in STOP for a new block download. Adding the OB during commissioning is normal; modifying an OB that is currently executing can corrupt the local data stack.

Why does the CPU still stop when I pull a module even though OB86 is loaded?

The most common reason is that the rack or station is not configured as a hot-swap station. On a non-hot-swap station, the slot removal is treated as a hard fault regardless of OB presence. Open HW Config (STEP 7) or the device configuration in TIA Portal, open the station properties, and check “Module replacement during operation”. If the option is greyed out, the base unit type does not support hot swap (for example ET 200SP base unit type C0).

Will a programmed OB82 increase the scan time?

It can. An empty OB adds under 50 µs to the cycle on S7-1500. A programmed OB82 that writes a ring buffer DB can add 200–800 µs depending on the number of records. Measure with “Online & Diagnostics > Cycle Time” before and after the change. If the cycle approaches the watch-dog, consider moving the ring buffer write to a cyclic interrupt OB30 running at 100 ms and just setting a flag from OB82.

Where do I find the diagnostic event ID for the active fault?

Open Online & Diagnostics > Diagnostics buffer. Each entry shows event class (e.g. 0x39 for diagnostic interrupt), event ID, and a textual description. The same data is exposed programmatically in OBxx_FLT_ID, OBxx_MDL_ADDR, and OBxx_DATE_TIME. Export the buffer to a CSV via the “Save As” icon for archival in the machine’s FAT.

Is loading an empty OB acceptable for a safety-relevant machine?

No. On a safety-relevant system, the safety CPU (F-CPU) has its own safety program and safety OBs (OB82 / OB85 with safety signature). Loading empty OBs in the standard program does not satisfy SIL/PL requirements. The error handling for the safety function must be programmed and validated per IEC 61508 / ISO 13849. Refer to the F-CPU programming and operating manual for the correct safety OB set.

Back to blog