Detecting S7-400 PROFIBUS DP Slave Communication Loss for CEMAT

David Krause15 min read
S7-400SiemensTechnical Reference
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

Detecting S7-400 PROFIBUS DP Slave Communication Loss for CEMAT Alarms

When a Siemens SIMATIC S7-400 PLC loses its distributed I/O over PROFIBUS DP — typically because of a power-supply failure on the DP slave, a disconnected bus cable, or a failed slave station — the CPU reports the event through a family of error and diagnostic organization blocks (OB82, OB85, OB86, OB87, OB122). Each OB exposes a standardized set of start information that lets user logic latch a per-slave fault bit, which can be forwarded to the SIMATIC CEMAT operator system as a documented alarm. This reference covers the four practical ways to detect a DP-slave failure on an S7-400 (PROFIBUS DP and PROFINET IO), the start-information fields you must evaluate, the code patterns for each method, and the recommended approach for CEMAT integrations.

CEMAT context: SIMATIC CEMAT is the Siemens process-control library for cement, mining and bulk-material plants. It runs on PCS 7 V8/V9 with S7-400 CPUs (CPU 410-5H, CPU 416, CPU 417). Plant-side alarm generation in CEMAT depends on the user program setting clearly identifiable bits in the CFC chart that the WinCC faceplate evaluates; a single DP-slave loss event must therefore set exactly one bit per slave, must be self-clearing when the slave returns, and must be edge-stable so the OS does not generate flooding alarms.

1. Problem Definition and Failure Modes

A S7-400 connected to distributed peripherals over PROFIBUS DP can lose communication in several distinct ways. Each failure type triggers a different organization block, and choosing the right OB is the first engineering decision when designing the alarm.

Failure Mode Typical Cause Triggering OB Event Class
DP slave station failure (entire slave drops) Power loss on slave, bus connector removed, slave CPU in STOP OB86 B#16#39 (incoming) / B#16#38 (outgoing)
Channel / module diagnostic on slave Wire break on analog channel, module removed under power OB82 B#16#39 / B#16#38
Communication fault on master interface PROFIBUS master module hardware fault, redundant partner failure OB87 B#16#39 / B#16#38
I/O access error during process image update Direct I/O access to a slot whose slave is gone OB122 (in conjunction with OB85) n/a (synchronous fault)
Update of process image failure PI update cannot write to a slot OB85 B#16#39 / B#16#38 (depending on priority)

For CEMAT alarm purposes the most useful signal is OB86 with the diagnostic address of the failing DP slave, because it fires once on entry and once on exit, and the start information contains the logical base address of the slave that failed. This matches the architecture CEMAT expects: one bit per slave, edge-stable, set/reset from OB86 only.

2. Prerequisites and Engineering Setup

Before writing any OB code, complete the following in the SIMATIC Manager (or TIA Portal where applicable to the project vintage):

  1. Open HW Config and select the DP slave that must be monitored. Note its Diagnostic Address (for example, 2035). This is the value loaded into #OB82_MDL_ADDR / #OB86_MDL_ADDR.
  2. Verify that OB82, OB86 and OB87 are inserted into the S7 program (right-click the S7-400 station, Insert > S7 Block, OB82, OB86, OB87). If the OB is missing the CPU goes into STOP on the first fault.
  3. Identify the PROFIBUS / PROFINET subnet number in HW Config (Properties of the DP master interface, "Network" tab). This is the value used for SFC51 INDEX.
  4. Reserve a fault data block (for example DB100, DB200) sized at 1 bit per DP slave plus 1 word for the network-fault summary. CEMAT expects stable, mapped addresses for OS variables.
  5. Wire the fault bits to CFC so the CEMAT chart can publish them to WinCC; see the CEMAT manual block "CEMAT_ALARM_8P" or the equivalent alarm driver in the library.
Firmware note: On S7-400 CPUs from firmware V5.x onward, OB86 fires for every DP-slave station failure with the failing station's diagnostic address in OB86_MDL_ADDR. CPUs older than V4 may only fire a generic OB86 without the address — verify the CPU order number and firmware version against the SIMATIC S7-400 CPU manual before relying on the address test.

3. Method A — OB82 Channel-Diagnostic Detection

OB82 (Diagnostic Interrupt) fires when a channel or module on a DP slave reports a diagnostic event, even if the slave as a whole is still cyclic on the bus. CEMAT operators often want this separately from a full station loss, because it indicates "degraded" rather than "lost." The block's local data contains the diagnostic address of the affected module and the channel number.

3.1 OB82 Start Information

Temporary Variable Type Meaning
OB82_EV_CLASS BYTE Event class: B#16#39 incoming / B#16#38 outgoing
OB82_MDL_ADDR INT Logical base address of the faulty module
OB82_IO_FLAG BYTE Input / output flag (B#16#54 = input module, B#16#55 = output module)
OB82_MDL_DEFECT BOOL Module defective
OB82_INT_FAULT BOOL Internal module fault
OB82_EXT_FAULT BOOL External fault (e.g. wire break, short circuit)
OB82_CH_FAULT BOOL Channel fault present

3.2 STL Implementation (OB82)

//--------------------------------------------------------------
//  OB82 – Diagnostic Interrupt
//  Latch one bit per DP-slave diagnostic address in M 91.0..M 91.7
//  2035 = example diagnostic address of slave #1 in HW Config
//--------------------------------------------------------------
A(
L #OB82_MDL_ADDR
L 2035                       // Diagnostic address of DP slave
==I
)
= #fault_1                   // Intermediate flag

A #fault_1
A(
L #OB82_EV_CLASS
L B#16#39                    // Fault incoming
==I
)
S M 91.0                     // Set M91.0 (slave 1 fault)

A(
L #OB82_EV_CLASS
L B#16#38                    // Fault outgoing
==I
)
R M 91.0                     // Reset M91.0 when fault clears
NOP 0

Repeat the same block for each DP slave. Each slave's diagnostic address becomes one set/reset pair in a dedicated data block. CEMAT OS variable mapping reads DB100.DBX0.0..DB100.DBXn.0 for slave 1..n.

4. Method B — OB86 Rack Failure / DP Slave Station Failure

OB86 is the recommended primary detector for whole-station failures. The block fires exactly once per failure entry and once per recovery, and the start information contains the logical base address of the station that failed. This is the CEMAT-preferred path because one slave in / out equals one set / reset on one bit.

4.1 OB86 Start Information

Temporary Variable Type Meaning
OB86_EV_CLASS BYTE B#16#39 incoming / B#16#38 outgoing
OB86_FLT_ID BYTE Fault ID: B#16#C1 loss of rack / B#16#C2, B#16#C3 DP slave diagnostic / B#16#C4, C5 etc.
OB86_MDL_ADDR INT Logical base address of the DP slave
OB86_Z23 BYTE Additional fault info (sub-module status)

4.2 STL Implementation (OB86)

//--------------------------------------------------------------
//  OB86 – Rack / DP station failure
//  One entry, one exit, one address – one bit per slave
//--------------------------------------------------------------
A(
L #OB86_FLT_ID
L B#16#C4                    // Fault ID for DP-slave station failure
==I
)
A(
L #OB86_MDL_ADDR
L 2035
==I
)
= #dp1_fault

A #dp1_fault
A(
L #OB86_EV_CLASS
L B#16#39                    // Station failure incoming
==I
)
S DB100.DBX0.0               // Slave 1 fault bit – CEMAT reads this

A #dp1_fault
A(
L #OB86_EV_CLASS
L B#16#38                    // Station failure outgoing
==I
)
R DB100.DBX0.0
NOP 0
Fault IDs to evaluate in OB86: B#16#C1 (rack failure), B#16#C2 (rack reappears after B#16#C1), B#16#C3 (DP slave diagnostic), B#16#C4 (DP station failure), B#16#C5 (DP station reappears). S7-400 firmware V5/V6 also reports B#16#C6..B#16#C9 for redundant DP slaves. Always check the SIMATIC S7-400 Automation System manual, section on OB86, for the full list that applies to your CPU order number.

5. Method C — OB85 / OB87 / OB122 + SFC51 RDSYSST Polling

Where the project requires a per-channel fault bit rather than a per-station fault bit — for example, when CEMAT must report exactly which input word on a slave became invalid — use the combination of OB85 / OB87 / OB122 to wake the program and then call SFC51 (RDSYSST) to read the system state list (SZL). SZL sublist W#16#294 reports the status of every station on a PROFIBUS subnet; W#16#292 reports the same for a PROFINET IO subnet. The sublist contains one record per station with status code, vendor ID and station address.

5.1 SFC51 Parameter Mapping

Parameter Value Meaning
REQ BOOL, TRUE Start the read
SZL_ID W#16#294 (PROFIBUS) / W#16#292 (PROFINET) Sublist identifier
INDEX INT, subnet number Network number from HW Config
RET_VAL INT Return value (W#16#0000 = OK)
BUSY BOOL TRUE while read in progress
SZL_HEADER STRUCT LENGTH_DR, N_DR returned by SFC
DR ANY Target area – must be large enough for N_DR records

5.2 STL Implementation (OB86 + SFC51)

//--------------------------------------------------------------
//  OB86 – Trigger SFC51 read on station failure
//--------------------------------------------------------------
A(
L #OB86_EV_CLASS
L B#16#39
==I
)
S M 100.0                    // "Read SZL request" flip-flop

//--------------------------------------------------------------
//  OB1 / OB35 – poll SFC51 until BUSY=FALSE, then evaluate
//--------------------------------------------------------------
CALL "RDSYSST"
REQ := M 100.0
SZL_ID := W#16#294           // PROFIBUS subnet station status
INDEX := MW 102              // Subnet number from HW Config
RET_VAL := MW 104
BUSY := M 106.0
SZL_HEADER := DB200.DBX0.0   // LENGTH_DR, N_DR
DR := P#DB200.DBX10.0 BYTE 256

A M 106.0                    // BUSY
R M 100.0                    // Clear request when done
NOP 0

5.3 Decoding the Station-Status SZL Record

Each station-status record returned by SFC51 with SZL_ID = W#16#294 is 28 bytes long. The fields used for CEMAT alarming are:

Byte Offset Field Meaning
0 Logical address Diagnostic address of the station (compare against your DP-slave list)
2..3 Status W#16#0000 OK / W#16#0010 not reachable / W#16#0011 faulty / W#16#0110 slave diag
4..5 Ident number Vendor / device GSD ident number
6 PROFIBUS address 0..125 on the segment

For PROFINET IO, set SZL_ID = W#16#292. The record layout differs (uses device number and slot information); see the S7-300/400 System and Standard Functions reference manual.

OB87 — Communication Fault: OB87 fires for master-interface faults (e.g. loss of redundant DP partner, interface module hardware fault). For a single-slave failure OB87 alone is not sufficient; combine it with OB86 to cover both single-slave and master-side conditions. CEMAT installations typically OR OB86 + OB87 status bits into one "DP network fault" summary bit that is then displayed on a dedicated network-status faceplate.

6. Method D — Standard FB125 / FC125 from Siemens

Siemens ships a free, ready-made standard block for exactly this task: FB125 "DP_SLAVE_DIAG" (sometimes distributed as FC125 depending on package) plus accompanying WinCC faceplates. The block encapsulates OB82 + OB86 evaluation, the SFC51 polling, and the per-slave status flags. For CEMAT projects this is the path of least engineering risk because the faceplate data block layout is already documented.

The block is delivered in the standard library "SIMATIC S7 Modulating / Standard PID Control" and on the Siemens Industry Online Support portal under entry ID 387257 (search "FB125 DP_SLAVE_DIAG"). It is free of charge, runs on CPU 41x and CPU 410-5H, and the WinCC-side includes pre-built screens for single and redundant DP slaves.

6.1 FB125 Interface

I/O Type Meaning
MAX_SLAVE INPUT INT Maximum number of slaves to monitor (e.g. 32)
NET_NUMBER INPUT INT PROFIBUS subnet number
SLAVE_STATE OUTPUT WORD Bit n = status of slave n (0 = OK, 1 = fault)
RET_VAL OUTPUT INT Return value of the block
FAULT OUTPUT BOOL True if any slave is in fault

6.2 Call Pattern in OB1 / Cyclic Task

CALL "DP_SLAVE_DIAG"
MAX_SLAVE := 32
NET_NUMBER := 1
SLAVE_STATE := MW 200
RET_VAL := MW 202
FAULT := M 110.0
NOP 0

Map M 110.0 (FAULT summary) to a CEMAT message class "Communication fault – DP1" and map individual bits in MW 200 to per-slave messages. This gives operators a clear top-level alarm plus one drill-down line per slave.

7. CEMAT Alarm Mapping

CEMAT expects the alarm information to be exposed in two layers: a high-level "network fault" message that triggers from any DP failure, and one detailed message per slave. The wiring from the PLC fault bits to the CEMAT faceplate is performed in CFC.

7.1 Mapping Table

CEMAT Variable Source Meaning
DP1_FAULT DB100.DBX0.0 (OR of OB86 faults) Any slave on DP subnet 1 faulted
DP1_S01..DP1_S32 DB100.DBX0.1..DB100.DBX3.7 Per-slave fault, set by OB86 or FB125
DP1_IF_FAULT OB87 evaluation (M91.7) Master-interface hardware fault
DP1_NET_OK Inverse of M 110.0 Used by sequence-control interlocks in CEMAT

In CFC, place the standard CEMAT block CEMAT_DIAG_8P on a chart in the plant area, connect its MSG_1..MSG_8 inputs to the per-slave bits, and connect the SUMMARY_FAULT input to the OR of all eight slaves. The OS will then display the messages on the plant area faceplate with the standard CEMAT alarm colors (red = fault, yellow = warning, no color = OK).

Edge-stable alarms: CEMAT uses OS-level message acknowledgement. Because OB86 fires on both entry (B#16#39) and exit (B#16#38), an outgoing event resets the bit and the operator sees the message go from "Pending" to "Cleared" automatically — no additional acknowledgement is required at the PLC level. Do not use rising-edge latches in OB86; the block is itself the edge source.

8. Method Comparison and Selection Guide

Method Detection Granularity Engineering Effort Diagnostic Address Available CEMAT Suitability
OB82 only Per channel / module Medium Yes (#OB82_MDL_ADDR) Good for channel-level diagnostics
OB86 only Per station Low Yes (#OB86_MDL_ADDR) Excellent — recommended default
OB85 / OB122 Per I/O access error Medium Yes (synchronous fault) Use only when OB86 is not available
OB87 only Master interface Low Yes Use as supplement to OB86
SFC51 polling Per station + status detail High Decoded from SZL Good for diagnostics, overkill for alarms
FB125 standard block Per station + summary Lowest Encoded in SLAVE_STATE Best for new projects

Recommended architecture for a new CEMAT project: FB125 for per-station bits + summary + OB87 evaluation for the master-interface fault + a single CFC chart that publishes the result via CEMAT_DIAG_8P blocks. This minimises hand-written code, uses certified Siemens standard blocks, and matches the OS faceplate that ships with FB125.

9. Verification Procedure

  1. Compile and download the OB82, OB86, OB87 blocks, the SFC51 call (if used), and the fault DB to the S7-400.
  2. Online view: open the OB86 in STEP 7 with "Monitor" — verify the temporary variables OB86_FLT_ID and OB86_MDL_ADDR populate when you power-cycle a DP slave.
  3. Force the fault bit on a slave that is actually present to confirm the OS message appears in WinCC with the correct color and class.
  4. Power-down test on one ET200S / ET200M / DP slave — confirm the corresponding fault bit sets, the CEMAT faceplate shows "Faulted," and the OS message arrives with the right instance name.
  5. Restore test — re-energise the slave and confirm the bit resets automatically without operator intervention (OB86 outgoing event).
  6. Bus-cable disconnect test — pull the PROFIBUS connector at the slave. Confirm OB86 fires and that the OS message arrives within one DP cycle (typical cycle on a 1.5 Mbit/s segment with 16 slaves = 5–10 ms; CPU-side detection latency on S7-400 firmware V5 = 10–20 ms).
  7. Master-interface fault simulation — unplug the master DP module. Confirm OB87 fires and the summary "DP network fault" message appears.
  8. Diagnostic-buffer inspection: in STEP 7, PLC > Diagnostic Buffer. Each DP-slave loss should be logged with an "OB86 – Rack failure / DP station failure" entry and the diagnostic address.

10. Troubleshooting Matrix

Symptom Likely Cause Correction
OB86 never fires although slave is offline OB86 not inserted in S7 program; CPU goes to STOP silently Insert OB86, re-download
OB86 fires but #OB86_MDL_ADDR is 0 CPU firmware < V4 or DP master is configured as non-diagnostic Upgrade CPU firmware or set "Diagnostic address" in DP slave properties
Fault bit sets but CEMAT faceplate does not update OS variable not mapped or wrong type Verify in WinCC tag management that the tag points to DB100.DBX0.0 with length 1 bit
Bit does not reset when slave returns OB86 outgoing not evaluated (only incoming code written) Add the reset branch on OB86_EV_CLASS = B#16#38
SFC51 returns RET_VAL = W#16#80B1 SZL_ID invalid for the configured subnet (e.g. W#16#294 used on PROFINET) Use W#16#292 for PROFINET IO, W#16#294 only for PROFIBUS
OB87 fires repeatedly on a redundant master Partner interface reports OB87 during failover Filter OB87 by FLT_ID in OB start information
CEMAT alarm shows wrong text CEMAT message class configuration not regenerated Re-run "OS Compile" in PCS 7 after CFC changes

11. Performance and Timing Considerations

OB86, OB82 and OB87 are interrupt OBs with priority 26 (OB82), 26 (OB86), 26 (OB87) on S7-400; they interrupt the cyclic OB1. Each invocation is typically 50–150 µs on a CPU 416, dominated by the address comparison. With 32 DP slaves on a single subnet the combined worst-case execution is below 5 ms per fault event, well inside the DP cycle. The SFC51 read, however, can run 2–50 ms depending on the number of stations — call it from OB35 (cyclic interrupt at 1 s) rather than from OB86, and use the BUSY flag to avoid blocking OB1.

For redundant H-CPUs (CPU 410-5H, CPU 417-4H) the OB86 fires on both sides; coordinate the fault-bit handling to avoid two simultaneous updates of the OS variable. The standard FB125 already handles H-mode correctly.

Question: Which OB fires first when a DP slave loses power — OB82 or OB86?

OB86 fires first, because it reports the loss of the entire slave station. OB82 follows only if the still-powered bus detects a channel-level diagnostic from another slave. For a single ET200M power loss, expect exactly one OB86 invocation with the slave's diagnostic address in OB86_MDL_ADDR and one OB86 invocation on recovery with event class B#16#38.

Question: Can I use one FB125 instance to monitor slaves on two PROFIBUS subnets?

Yes — call FB125 once per subnet with a different NET_NUMBER input. The SLAVE_STATE outputs are independent, so you can OR them into one summary bit if CEMAT must aggregate them into a single "DP fault" message, or keep them separate for per-area messages.

Question: My OB86 fires but OB86_MDL_ADDR is zero. Why?

The DP slave's "Diagnostic Address" was not assigned in HW Config, or the CPU firmware does not report the address for non-DP-IFA-capable slaves. Open the DP slave properties in HW Config, enter a diagnostic address (for example 2035), and recompile the HW. Re-download to the CPU.

Question: Should I reset the fault bit from OB1 or from OB86?

Reset from OB86 only. OB86 fires once with B#16#38 when the slave is reachable again, so the reset is edge-stable and self-clearing. Resetting from OB1 introduces a one-cycle window in which the bit can flicker and trigger spurious OS messages.

Question: Where can I download FB125 and the WinCC sample screens?

FB125 and the accompanying WinCC sample screens are published on the Siemens Industry Online Support portal under entry ID 387257 (search "FB125"). The package includes STL source, the WinCC graphics for the slave-status faceplate, and a STEP 7 sample project showing typical CEMAT wiring.

Question: Does this work the same way on an S7-400H redundant system?

Yes. On an S7-400H the OB86 fires on the active CPU; the passive CPU suppresses OB86 because it does not own the DP master. FB125 is H-aware. If you write OB86 manually, do not also evaluate OB86 on the passive side, or the fault bit will be cleared while the active CPU still reports the failure.

Back to blog