Problem Overview
When a SINAMICS G120 inverter equipped with a CU230P-2 PN Control Unit drops off PROFINET, an S7-1200 CPU does not automatically raise the user-defined reaction in the application program. Many integrators wire OB40 (hardware interrupt), OB82 (diagnostic error interrupt), and OB86 (rack/station failure) into the project expecting the cyclic OB1 program to be notified the moment the drive becomes unreachable, but the OB does not trigger and the diagnostic buffer lists "IO device failure - IO device not found" while the application keeps running with stale process data. The PLC and the drive exchange PROFINET IRT frames every millisecond, and TIA Portal exposes this loss in the diagnostic buffer, the LED indicators, and the DeviceStates function block, yet no OB fires because none of the project OBs of the corresponding class are loaded.
The three failure-handling OBs for PROFINET on S7-1200 (firmware V4.0 and later) are OB82 for diagnostic alarms, OB83 for module pull/plug events, and OB86 for station failure / station return. OB86 is the primary mechanism for the case where the G120 power section is de-energized, the PROFINET cable is broken, or the device name is missing - any condition that prevents the controller from reaching the drive at all. Until the OB is created in the project, the CPU does not have a routine to run and the system cannot react. This article walks through configuring OB86, complementing it with the DeviceStates function block, and adding OB82 for in-telegram diagnostic alarms coming from the drive itself.
Why OB82 and OB86 Do Not Fire on S7-1200
The S7-1200 CPU only calls an OB if that OB exists in the project. There is no implicit OB86, OB82, OB83, OB121, or OB122 like on a S7-1500 with default empty bodies - the engineer must explicitly add each one. Three other conditions also suppress OB execution on a CPU 12xx:
- CPU in STOP at startup. If the IO device failure occurs before the CPU leaves the startup phase, the diagnostic buffer records the event but OB86 is not called because the OB engine has not yet been started. The same behavior occurs on a warm restart. Add OB100 (warm restart) and OB101 (cold restart) so the application initializes the drive presence flag at the very first cycle.
- CPU firmware below V4.0. OB82 and OB86 were added to the S7-1200 line with firmware V4.0 (CPU 1211C/1212C/1214C/1215C/1217C and the 1212FC/1214FC/1215FC fail-safe variants). On V3.x firmware, the system cannot raise an OB86 even if the project contains one. Check the device properties in TIA Portal - the firmware version is shown under "Properties > General > Catalog Information".
-
PROFINET interface disabled or device name missing. The G120 CU230P-2 PN must have a PROFINET device name that matches the configured name in the TIA Portal project. If the G120 was commissioned with the SINAMICS Starter or Startdrive tool and the device name was changed after the last TIA Portal download, the controller treats the drive as a different device and reports "IO device not found" with a station number mismatch. OB86 does still fire, but with
OB86_FLT_ID = B#16#C4andOB86_MDL_ID = 0, which can be confusing.
The "IO device failure - IO device not found" diagnostic buffer entry on S7-1200 firmware V4.4 (and later) carries event ID 0x013C. Older firmware shows it as event ID 0x02A1 with the same root meaning. The diagnostic buffer entry by itself does not invoke an OB; it is the underlying PROFINET stack that calls OB86 when the IO controller has lost all AR (Application Relationship) to the IO device. The full event is also published in the online PROFINET diagnostics under "Online & Diagnostics > PROFINET interface > Diagnostics" of the G120 device object.
Prerequisites and Engineering Environment
Before adding OBs to the project, confirm the following baseline. None of these steps is optional - skipping any of them is a documented source of "OB does not fire" complaints.
| Item | Minimum requirement | Notes |
|---|---|---|
| CPU firmware | V4.0 (preferably V4.4 or V4.5) | Required for OB86/OB82 in S7-1200 |
| TIA Portal | V15.1 or later (V17/V18 recommended) | Adds DeviceStates under Communication |
| SIMATIC S7-1200 manual | Edition 09/2019 or later | Reference for OB priority classes |
| G120 CU230P-2 PN firmware | V4.7 SP13 or later | Aligns with TIA Portal V17 GSD |
| PROFINET topology | Star or line; G120 has integrated 2-port switch | No external switch required for a single drive |
| Telegrams | Standard telegram 1 (PZD-2/2) or 350/352 | Telegram 1 is the default for CU230P-2 PN |
The SIMATIC S7-1200 Programmable Controller System Manual (109751634) and the SINAMICS G120 CU230P-2 PN Operating Instructions (109751320) define the standard telegrams and the parameter assignment of the PROFINET interface. The PROFINET diagnostics page (68052880) lists the standard event identifiers and how the controller maps them to OBs. Two legacy FAQs cover the S7-1200 error-handling case in detail: "How can you manage peripheral device errors detected by the S7-1200 PLC" (42781105) and "How can you manage block execution errors detected by the S7-1200 PLC" (42908460).
OB Architecture and Priority Classes on S7-1200
OB86, OB82, OB83, and OB40 all run at the same fixed priority (priority class 16, OB-number priority 9) on a S7-1200. They cannot interrupt each other: while OB86 is executing, an incoming diagnostic alarm is queued and raised after OB86 returns. The firmware queues a single pending event per OB class; if two stations fail in rapid succession, the second failure overwrites the first and is reflected only in the diagnostic buffer. This is acceptable for a G120 that drives a fan or pump (the application only needs a boolean "drive reachable" flag), but it is not sufficient if every station must be reported individually. The standard solution is to use DeviceStates inside OB1 to obtain a 32-bit status mask that captures the state of up to 32 IO devices in a single call.
| OB | Event class (OBxx_EV_CLASS) | Trigger condition on S7-1200 |
|---|---|---|
| OB40 | B#16#11 (entering event) | Hardware interrupt from a digital input or PTO |
| OB82 | B#16#38 (entering) / B#16#39 (leaving) | Diagnostic alarm from a DP/PN slave (channel-level fault) |
| OB83 | B#16#55 / B#16#56 | Insert/remove of a module on ET200 stations |
| OB86 | B#16#38 / B#16#39 | Station failure / station return (whole IO device) |
| OB87 | B#16#38 / B#16#39 | Communication error (e.g. duplicate PROFINET name) |
| OB121 | B#16#25 / B#16#26 / B#16#27 | Programming error in OB1/OB3x/OB40 |
| OB122 | B#16#25 / B#16#26 / B#16#27 | I/O access error (PQE read on missing slot) |
For a G120 application, the two OBs that matter are OB86 (loss of the IO device) and OB82 (incoming diagnostic alarm from a sub-module, e.g. PROFIsafe channel fault or encoder wire break on a CU240 PN). They have different scopes: OB86 tells the application that the entire drive is unreachable, OB82 tells the application that the drive is reachable but a sub-slot has reported a channel-level diagnostic alarm. Skipping OB82 means missing any internal fault that the drive reports via the standard PROFINET diagnostic record 0x000A (channel diagnostics). The S7-1200 OB priority overview is documented in section "Organization blocks" of the System Manual (109751634).
Creating OB86 in TIA Portal
Open the S7-1200 device in the project tree, right-click "Program blocks", and select "Add new block > Organization block > OB86 - Rack or station failure". The wizard inserts an empty OB86 with the standard temporary tags shown below. Leave the default priority (16) and do not add an OBs in an OB-startup OB100 - that combination is illegal in S7-1200 firmware 4.x and forces the CPU to STOP.
The default temporary tags of OB86 are:
| Tag | Type | Description |
|---|---|---|
| OB86_EV_CLASS | BYTE | B#16#38 incoming (failure), B#16#39 outgoing (return) |
| OB86_FLT_ID | BYTE | B#16#C4 station failure, B#16#C5 station return, B#16#C7 expansion rack failure |
| OB86_PRIORITY | BYTE | Priority class (16) |
| OB86_OB_NUMBR | BYTE | 86 (OB number) |
| OB86_MDL_ID | WORD | 0 = no module, 0xC..F for PROFINET |
| OB86_MDL_ADDR | WORD | Logical base address of the IO device |
| OB86_RACKS_FLTD | BYTE | Bit mask of racks (always 0 for PROFINET) |
| OB86_NUM_FLTD | WORD | Number of failed racks/stations (1 for PROFINET) |
| OB86_DATE_TIME | DATE_AND_TIME | Time stamp of the event |
The following SCL body in OB86 raises a global flag and a non-retentive tag of the same value so the cyclic program can read the failed logical address without re-decoding the OB-start info on every scan:
// OB86 - Rack or station failure (S7-1200)
// Triggered when a PROFINET IO device is unreachable or returns
IF #OB86_EV_CLASS = B#16#38 THEN // Event entering (failure)
IF #OB86_FLT_ID = B#16#C4 THEN // Station failure
"G120_FailurePending" := TRUE;
"G120_LastFailedAddress" := WORD_TO_INT(#OB86_MDL_ADDR);
"G120_LastEventTime" := #OB86_DATE_TIME;
END_IF;
ELSIF #OB86_EV_CLASS = B#16#39 THEN // Event leaving (return)
IF #OB86_FLT_ID = B#16#C5 THEN // Station return
"G120_FailurePending" := FALSE;
"G120_RestoredAddress" := WORD_TO_INT(#OB86_MDL_ADDR);
"G120_LastEventTime" := #OB86_DATE_TIME;
END_IF;
END_IF;
Using the DeviceStates Function Block
OB86 is event-driven and only reports a single failure at a time. To obtain a complete map of every PROFINET device in a single call, the application should use the DeviceStates instruction located at "Instructions > Communication > PROFINET" (TIA Portal V16 and later) or under "Extended instructions > Distributed I/O" in earlier versions. The block returns a 32-bit word where each bit corresponds to a configured PROFINET device. Bit n is set when the device whose PROFINET interface address (the IO device number) is n is in the requested state.
DeviceStates has four input/output parameters:
| Parameter | Type | Description |
|---|---|---|
| LADDR | HW_IO / WORD | Hardware identifier of the local PROFINET interface. Use 0 for the CPU's onboard PROFINET port. |
| MODE | UINT | 1 = available, 2 = failed, 3 = deactivated |
| RET_VAL | INT | Return value: 0 = OK, 0x80A1 / 0x8090 = parameter error |
| STATE | ARRAY[0..31] of BOOL (or DWORD) | Bit n = 1 means device n is in the requested state |
The typical pattern is to call DeviceStates with MODE = 2 once per OB1 cycle and OR the result with a sticky tag so a transient dropout lasting only a few cycles is still captured. The G120 is usually device number 1 (PROFINET device index 0 in the state mask corresponds to device number 1, so the bit index is device number - 1).
// "PRN_State" is a global data block (DB) with:
// G120_Failed : BOOL - sticky failed flag
// G120_FailedNow : BOOL - transient flag for this cycle
// G120_Available : BOOL - sticky available flag
// Error : BOOL - DeviceStates returned an error
// RawStateDword : DWORD - raw DeviceStates return
IF "PRN_State".Error THEN
"PRN_State".Error := FALSE;
END_IF;
// Query failed devices (MODE = 2)
"DeviceStates_1"(
LADDR := 0,
MODE := 2,
RET_VAL := "PRN_State".Error,
STATE := "PRN_State".FailedArray
);
// Query available devices (MODE = 1) - optional sanity check
"DeviceStates_2"(
LADDR := 0,
MODE := 1,
RET_VAL := "PRN_State".Error,
STATE := "PRN_State".AvailableArray
);
// G120 is IO device #1, so its bit is index 0 in the array
"PRN_State".G120_FailedNow := "PRN_State".FailedArray[0];
IF "PRN_State".G120_FailedNow THEN
"PRN_State".G120_Failed := TRUE;
ELSE
"PRN_State".G120_Available := TRUE;
END_IF;
16#80B1 (invalid mode). Always evaluate RET_VAL before reading the STATE array - the array is not initialized by the block on error.OB82 Diagnostic Error Interrupt Handling
OB82 fires when an IO device sends a PROFINET diagnostic alarm. The G120 CU230P-2 PN raises channel diagnostics whenever the power module reports an overtemperature, the encoder reports a wire break, or the safety channel reports a PROFIsafe fault. The OB82 standard temporary tags include the channel number, the I/O logical address, and the channel fault ID. The OB is called twice: once when the fault appears (event class B#16#38) and once when it clears (B#16#39).
The body in OB82 should:
- Check
OB82_FLT_ID:B#16#42= module fault,B#16#43= module OK,B#16#44= channel fault present,B#16#45= channel fault gone. - Read
OB82_MDL_ADDRto identify the affected G120 logical base address. - Read the channel-specific diagnostic data using SFB 52 (RDREC / RALRM) to extract the PROFIdrive channel diagnostic record 0x000A. The record contains a 32-bit channel properties word and a 16-bit channel error number; on a G120, error number 0x0001 means channel 1 of the safety module is in the fault state.
- Copy the structured data into a global DB so the HMI can display the diagnostic text.
// OB82 - Diagnostic error interrupt (S7-1200)
// Triggered when the G120 reports a channel-level diagnostic alarm
IF #OB82_EV_CLASS = B#16#38 THEN // Fault entering
CASE #OB82_FLT_ID OF
B#16#42: // Module fault
"Diag".LastModuleFaultAddr := WORD_TO_INT(#OB82_MDL_ADDR);
B#16#44: // Channel fault present
"Diag".LastChannelFaultAddr := WORD_TO_INT(#OB82_MDL_ADDR);
"Diag".ChannelFaultPending := TRUE;
ELSE
"Diag".OtherFaultPending := TRUE;
END_CASE;
// Read the standard diagnostic record 0x000A (16-byte channel diagnostic)
"RDREC_DB"(REQ := TRUE,
ID := #OB82_MDL_ADDR,
INDEX := 16#000A,
MLEN := 16,
VALID => "Diag".RecValid,
LEN => "Diag".RecLen,
ERROR => "Diag".RecError,
STATUS => "Diag".RecStatus,
RECORD := "Diag".ChannelDiag);
ELSIF #OB82_EV_CLASS = B#16#39 THEN // Fault leaving
"Diag".ChannelFaultPending := FALSE;
END_IF;
The legacy FAQ "How can you manage peripheral device errors detected by the S7-1200 PLC" (42781105) walks through the same RDREC pattern with a complete SCL example that you can drop into the project. Use it together with the standard RALRM instruction in OB82 if you need the full slot-level diagnostic data, including the slot, sub-slot, channel, and direction (incoming / outgoing).
Combined Code Example: Full Fault Reaction in OB1
Once OB86 and OB82 are loaded and DeviceStates is called once per cycle, the cyclic program can implement a controlled fault reaction. The typical pattern in a fan or pump application is to coast the G120 by clearing the control word bit 0 (OFF1) the moment the drive is unreachable, raise a group fault, and switch the HMI status to "G120 not reachable".
// OB1 cyclic body - fault reaction for unreachable G120
// 1. If OB86 or DeviceStates reported the G120 as failed,
// clear the process output bit for the drive control word bit 0 (ON/OFF1).
IF "PRN_State".G120_Failed OR "Diag".ChannelFaultPending THEN
// Force STW1.0 = 0 (coast to stop) and STW1.3 = 0 (no enable).
// Use the PQW base address of the G120 telegram.
"G120_STW1" := "G120_STW1" AND (WORD#16#FFFF AND (NOT WORD#16#0001));
"G120_STW1" := "G120_STW1" AND (WORD#16#FFFF AND (NOT WORD#16#0008));
"PRN_State".DriveCommandedOff := TRUE;
ELSE
"PRN_State".DriveCommandedOff := FALSE;
END_IF;
// 2. Edge-triggered HMI alarm on rising edge of the failed flag
IF "PRN_State".G120_Failed AND NOT "PRN_State".G120_FailedOld THEN
"HMI".AlarmBit_G120Missing := TRUE;
END_IF;
"PRN_State".G120_FailedOld := "PRN_State".G120_Failed;
// 3. Optional: call GetError / GetErrorID to recover gracefully
// from any I/O access error on a missing PQW
IF "Diag".RecError THEN
"GetErrorInstance"(ERROR := "Diag".LastErrorInfo,
ID := "Diag".LastErrorID);
END_IF;
The companion FAQ "How can you manage block execution errors detected by the S7-1200 PLC" (42908460) provides the GetError and GetErrorID SCL examples used in the last block. Pairing OB86 with GetError is the only safe way to access a process output word on a missing IO device; without it, a read of the PQW inside OB1 raises an I/O access error and - if OB122 is not present - drives the CPU to STOP.
Verifying the Configuration
After downloading the project, the configuration must be verified in three places: the online device view, the diagnostic buffer, and a deliberate drop-and-reconnect test. None of these checks is optional.
- Online > Diagnostics > PROFINET > Topology. The G120 must show "OK" and the PROFINET device name must match the project. If the name field is empty, OB86 will fire the first time the controller ARMs the AR, then never again until the project is downloaded. Open the G120 in the project, set the device name in the Properties > Ethernet addresses tab, and assign it via the online function "Assign PROFINET device name".
- Online > Diagnostics > Diagnostic buffer. Before pulling the cable, the buffer should be empty (or contain only cleared entries). The PROFINET interface should be in "Operational" state. The error LED on the G120 should be OFF.
-
Drop test. With the project running, pull the PROFINET cable at the G120 end. Within one PROFINET update cycle (default 1 ms for IRT, 2 ms for RT), the controller should report "IO device failure" in the diagnostic buffer with event ID 0x013C, OB86 should fire once with
OB86_FLT_ID = B#16#C4andOB86_MDL_ADDR = <G120 logical base address>, and the global tagPRN_State.G120_Failedshould remain TRUE. Reconnect the cable; OB86 fires a second time withOB86_FLT_ID = B#16#C5, and the global tag clears. -
DeviceStates sanity check. Force the project online, open the watch table, and read
PRN_State.FailedArray[0]while the cable is disconnected. It must be TRUE. Reconnect and confirm it returns to FALSE within one PROFINET update cycle. -
OB82 channel alarm test. Force a G120 fault using Startdrive (e.g. simulate a "Speed controller output limited" alarm by setting p2177). OB82 should fire with
OB82_FLT_ID = B#16#44and the channel diagnostic record should report the corresponding channel number and error code.
Troubleshooting Matrix
| Symptom | Likely cause | Verification | Remedy |
|---|---|---|---|
| OB86 never fires; diagnostic buffer shows "IO device not found" | OB86 not present in the project | Project tree > Program blocks - OB86 missing | Add OB86 with priority 16 and the SCL body above |
| OB86 never fires; G120 LED "BF" is solid red | PROFINET device name mismatch | Online > Diagnostics > PROFINET > Device name | Re-assign the PROFINET device name from TIA Portal |
| OB86 never fires; CPU firmware is V3.x | Firmware does not support OB86 | Device properties > Catalog information > Firmware | Update the CPU to V4.0 or later (V4.4 / V4.5 recommended) |
| OB86 fires, but DeviceStates returns all zeros | LADDR set to the wrong HW identifier | Watch the LADDR constant against the online HW identifier list | Use LADDR = 0 (local PROFINET interface) or the proper HW identifier |
| OB86 fires, but the cyclic program still reads the G120 and the CPU goes to STOP | OB122 is missing and an I/O access error is raised | Diagnostic buffer shows "I/O access error" | Add OB122; alternatively guard PQW reads with the failed flag and use a default value |
| OB86 fires only at startup, never during operation | G120 powers up after the CPU; AR is established later | Trace the G120 PROFINET state in Startdrive | Use DeviceStates to refresh the availability flag every cycle; do not rely on a single edge |
| OB82 fires with a channel alarm, but RDREC returns STATUS 0x80A0 | Negative acknowledgement, slot does not support the requested record | Watch STATUS after RDREQ | Use RALRM (SFB 54) inside OB82 to fetch the full alarm header, then read the record with RDREC on the slot / sub-slot the alarm came from |
| OB86 fires on every cycle, even with the cable connected | Duplicate PROFINET device name on the network | Online > Diagnostics > PROFINET > Device list | Rename the conflicting device and re-assign the G120 name |
| CPU goes to STOP at startup with "IO device failure - IO device not found" | OB86 is not present and the drive is not yet up | Diagnostic buffer event ID 0x013C at startup | Add OB86; alternatively delay the I/O start in the device configuration |
| OB86 fires but the application cannot identify the failed device | Multiple IO devices share the same diagnostic buffer entry | Check OB86_NUM_FLTD and OB86_MDL_ADDR | Use DeviceStates inside OB86 to obtain a complete map; the OB86 input only reports the first event |
Field-Engineering Checklist
Use this checklist before site acceptance testing:
- OB82, OB83, OB86, OB100, OB101, OB121, OB122 are all present in the project with non-empty bodies.
- DeviceStates is called at least once per OB1 cycle with MODE = 1 (available) and MODE = 2 (failed).
- The G120 PROFINET device name is assigned from TIA Portal and matches the project name.
- The G120 telegram is set to standard telegram 1 (or 350/352 if the application uses the extended PROFIdrive channel).
- Watch tables
PRN_StateandDiagare pinned and reviewed during commissioning. - HMI alarm "G120 unreachable" is configured with the failed tag and acknowledged via OB86 station return.
- Diagnostic buffer is cleared before final SAT; the next "IO device failure" entry must be the deliberate drop test.
For redundant S7-1500R/H systems, the same principle applies but the OB86 instance is raised against the backup controller first; the official SIMATIC S7-1500R/H manual collection describes this in "Application planning > Failure scenarios > Failure of an IO device in the PROFINET ring" at docs.tia.siemens.cloud. The S7-1200 has no redundant PROFINET interface and is treated as a single-controller system, so the simpler OB86 + DeviceStates pattern is sufficient.
FAQ
Why does my S7-1200 not call OB86 when the G120 drops off PROFINET?
OB86 is not invoked unless the OB exists in the project, the CPU firmware is V4.0 or later, and the PROFINET AR has been established at least once. Add OB86 with priority 16, verify the firmware version in the device properties, and confirm the G120 PROFINET device name matches the TIA Portal configuration.
What is the difference between OB82 and OB86 on a S7-1200 with a G120?
OB86 reports that the entire IO device is unreachable (station failure / station return). OB82 reports that the IO device is reachable but a sub-slot has raised a channel-level diagnostic alarm. Use OB86 for cable / power loss and OB82 for internal drive faults such as encoder wire break, motor overtemperature, or PROFIsafe channel diagnostics.
How do I detect which of several PROFINET devices has failed?
OB86 reports only the first failed device. Call the DeviceStates instruction (Instructions > Communication > PROFINET) once per OB1 cycle with MODE = 2 and read the returned 32-bit state array. Bit n corresponds to the device with PROFINET device number n + 1.
What value of MODE do I use in DeviceStates to detect a failed G120?
Use MODE = 2 to obtain the state array of failed devices. Bit 0 (device number 1) is set whenever the G120 is unreachable. MODE = 1 returns the available devices and can be used as a sanity check, and MODE = 3 returns the deactivated devices.
Do I also need OB122 when I add OB86?
Yes. If your cyclic program reads or writes a PQW / PEW on the missing G120 without a guard, the CPU raises an I/O access error. Without OB122, the CPU goes to STOP. Either add OB122 with an empty body, or guard every PQW / PEW access to the G120 with the failed flag from DeviceStates.
What firmware on the G120 CU230P-2 PN is recommended for this configuration?
Use G120 CU230P-2 PN firmware V4.7 SP13 or later, paired with TIA Portal V17 and the G120 V5.2 GSDML. Earlier firmware versions do support standard telegram 1 and PROFINET diagnostics, but recent firmware adds the extended channel diagnostic record 0x000A used by OB82 + RDREC.