Overview
Diagnostic interrupts on a Siemens SIMATIC S7-1500 analog input module such as the 6ES7531-7KF00-0AB0 (AI 8xU/I/RTD/TC ST) are aggregated into a single OB82 call when configured. By default, the diagnostic error interrupt OB only tells the user program that some diagnostic event occurred, not which channel or which fault type was responsible. To distinguish between No supply voltage L+, Wire Break, Overflow, Underflow, Common Mode error, and Reference channel error, the application must read the diagnostic data records out of the affected channel or module using SFB54 RALRM and parse data records DS0 (channel-related diagnostics) and DS1 (module-specific diagnostics).
This reference applies to PROFINET distributed I/O such as the ET 200SP station built around the IM155-5 PN HF (6ES7155-5AA00-0AC0) interface module, returning diagnostics over PROFINET to a CPU 1516F-3 PN/DP (6ES7516-3FN01-0AB0). The same mechanism applies to central S7-1500 AI modules.
Prerequisites
- STEP 7 Professional V16 or later (TIA Portal). The mechanisms described work back to V13.1 SP1.
- S7-1500 CPU firmware V2.0 or later (CPU 1516F-3 PN/DP 6ES7516-3FN01-0AB0 ships with firmware V2.6+).
- AI 8xU/I/RTD/TC ST module 6ES7531-7KF00-0AB0 firmware V1.0 or later.
- IM 155-5 PN HF (6ES7155-5AA00-0AC0) firmware V4.0 or later.
- Hardware configuration of the AI module with Diagnostics enabled for each channel-level event (Wire Break, Overflow, Underflow, Reference channel error) and module-level events (No supply voltage L+, Common mode error).
- OB82 (Diagnostic error interrupt) added to the program blocks; otherwise the CPU transitions to STOP on the first diagnostic event.
- SFB54 (RALRM) library block, included automatically with STEP 7.
Diagnostic Interrupt Sources on the 6ES7531-7KF00
The AI 8xU/I/RTD/TC ST module generates diagnostic interrupts for the events listed below. The events are subdivided into module-level and channel-level diagnostics:
| Event | Scope | Channel-Related Bit | Module-Related Bit |
|---|---|---|---|
| No supply voltage L+ | Module | — | Bit 0 in DS1 byte 0 |
| Wire Break | Channel | Bit 8 in DS0 | — |
| Overflow | Channel | Bit 4 in DS0 | — |
| Underflow | Channel | Bit 5 in DS0 | — |
| Common Mode error | Module | — | Bit 7 in DS1 byte 0 |
| Reference channel error | Channel (channels 6/7 used as reference) | Bit 7 in DS0 | — |
| Short circuit to M (for voltage/current mode) | Channel | Bit 10 in DS0 | — |
| High limit exceeded | Channel | Bit 0 in DS0 | — |
| Low limit exceeded | Channel | Bit 1 in DS0 | — |
Hardware Configuration in TIA Portal
- Open the device view of the AI 8xU/I/RTD/TC ST module.
- Select each channel (0 through 7) and open Properties > Diagnostics.
- Enable the diagnostic events required: Wire Break, Overflow, Underflow, Reference channel error, and Common Mode error.
- For module-level events, navigate to Module parameters > Diagnostics and enable No supply voltage L+.
- Confirm that PROFINET diagnostic interrupts are forwarded (default behaviour with the IM155-5 PN HF).
- Compile and download the hardware configuration to the CPU.
OB82 Startup Information and SFB54 RALRM
The diagnostic error interrupt OB82 fires on both the occurrence and the removal of a diagnostic event. Its startup information identifies the logical address of the slot reporting the fault:
| OB82 Input | Length | Meaning |
|---|---|---|
| IOFLAGS | BYTE | Bit 0 = incoming event, Bit 1 = outgoing event |
| EVENT_SUP | DWORD | Bit-coded, indicates whether module, channel, or external diagnostics are pending |
| HW_ID (IO_LADDR) | DWORD | Hardware identifier of the module |
| CHANNEL | DWORD | Channel number; 0x8000 = module-level |
| DIAG_EVENT | DWORD | Channel-specific error code (matches DS0 bit pattern) |
For PROFINET I/O, OB82 alone cannot decode every concurrent channel fault. The official Siemens recommendation is to use SFB54 RALRM, which reads the complete alarm record (including all queued channel diagnostics) from the distributed module. According to the official Siemens documentation on Diagnostic Error Interrupt OB, the OB includes startup information that helps determine whether the event is due to occurrence or removal of an error.
SFB54 RALRM Interface
| Parameter | Type | Description |
|---|---|---|
| MODE | INPUT BYTE | 0 = all data, 1 = no TINFO/AINFO, 2 = only TINFO, 3 = only AINFO |
| F_ID | INPUT DWORD | Logical address of the module (e.g. OB82 HW_ID) |
| MLEN | INPUT INT | Max length of AINFO buffer (use 65535) |
| TINFO | IN/OUT ANY (STRUCT) | Task information (e.g. OB start info) |
| AINFO | IN/OUT ANY | Alarm information (raw diagnostic data records) |
| STATUS | OUTPUT WORD | Call status / error code |
Set MODE = 0 so that the AINFO buffer is filled with the queued diagnostic data records. Use MLEN = 65535 to ensure all records are captured. Without RALRM, OB82 only exposes a single fault event at a time because PROFINET alarms are queued and the OB only reads the first one.
Diagnostic Data Record Layout
The AINFO buffer returned by RALRM contains a header followed by chained data records. The header layout for PROFINET alarms is:
| Offset | Length | Description |
|---|---|---|
| 0 | WORD | Block type (0x0001 = diagnostics) |
| 2 | WORD | Block length |
| 4 | WORD | Block version (0x0100) |
| 6 | WORD | Alarm type / specification |
| 8 | DWORD | API number |
| 12 | WORD | Slot number |
| 14 | WORD | Subslot number |
| 16 | DWORD | Module identification |
| 20 | WORD | Number of diagnostics records following |
| 22 | DWORD | Alarm state / specifier |
Data Record 0 (DS0) — Channel Diagnostics
| Offset | Bit | Meaning |
|---|---|---|
| Byte 0 | 0 | High limit exceeded |
| Byte 0 | 1 | Low limit exceeded |
| Byte 0 | 4 | Overflow |
| Byte 0 | 5 | Underflow |
| Byte 0 | 7 | Reference channel error |
| Byte 1 | 0 | Wire Break |
| Byte 1 | 2 | Short circuit to M |
| Byte 2-3 | — | Channel number (bit-encoded) |
| Byte 4-5 | — | Direction (incoming/outgoing) |
Data Record 1 (DS1) — Module Diagnostics
| Offset | Bit | Meaning |
|---|---|---|
| Byte 0 | 0 | No supply voltage L+ |
| Byte 0 | 7 | Common Mode error |
| Byte 0 | 4 | Internal module error |
| Byte 1-3 | — | Module status / specifier |
Structured Text (SCL) Implementation
The following SCL block, invoked from OB82, demonstrates how to parse multiple simultaneous faults using RALRM and the DS0/DS1 records. The implementation is based on the official Siemens sample program referenced in Entry 109480387.
// OB82 call context
#iOB82_HW_ID := #OB82_HW_ID; // IO_LADDR from OB82 startup
#iMaxLen := 65535;
// RALRM returns concatenated diagnostic records
RALM_DB.RALRM_Instance(MODE := 0,
F_ID := #iOB82_HW_ID,
MLEN := #iMaxLen,
TINFO := #tinfoBuffer,
AINFO := #ainfoBuffer,
STATUS => #wStatus);
IF (#wStatus = 0) THEN
// Header at offset 0 is 24 bytes; first DS follows at offset 24
#wNumRecords := WORD_TO_INT(#ainfoBuffer[20]);
#iRecordPtr := 24;
FOR #iLoop := 1 TO #wNumRecords DO
// Each record header: 6 bytes (USI x2, USI x2, USI x1, pad x1)
#wRecType := WORD_TO_INT(#ainfoBuffer[#iRecordPtr]);
// DS0 = 0x0010 (channel diag), DS1 = 0x0011 (module diag), DS2 = 0x0012 (extended)
CASE #wRecType OF
16: // DS0 channel diagnostics
#wChannel := WORD_TO_INT(#ainfoBuffer[#iRecordPtr + 6]);
#dwDiag := DWORD_AT(#ainfoBuffer[#iRecordPtr + 8]);
IF (#dwDiag.0) THEN "dbAlarm".HighLimitExceeded[#wChannel] := TRUE; END_IF;
IF (#dwDiag.1) THEN "dbAlarm".LowLimitExceeded[#wChannel] := TRUE; END_IF;
IF (#dwDiag.4) THEN "dbAlarm".Overflow[#wChannel] := TRUE; END_IF;
IF (#dwDiag.5) THEN "dbAlarm".Underflow[#wChannel] := TRUE; END_IF;
IF (#dwDiag.7) THEN "dbAlarm".RefChannelError[#wChannel] := TRUE; END_IF;
IF (#dwDiag.8) THEN "dbAlarm".WireBreak[#wChannel] := TRUE; END_IF;
IF (#dwDiag.10) THEN "dbAlarm".ShortCircuitM[#wChannel] := TRUE; END_IF;
#iRecLen := 14;
17: // DS1 module diagnostics
#dwDiag := DWORD_AT(#ainfoBuffer[#iRecordPtr + 6]);
IF (#dwDiag.0) THEN "dbAlarm".NoSupplyVoltage := TRUE; END_IF;
IF (#dwDiag.4) THEN "dbAlarm".InternalModuleErr := TRUE; END_IF;
IF (#dwDiag.7) THEN "dbAlarm".CommonModeError := TRUE; END_IF;
#iRecLen := 12;
ELSE
// Read DS length field at offset 2 of record header
#iRecLen := WORD_TO_INT(#ainfoBuffer[#iRecordPtr + 2]);
END_CASE;
#iRecordPtr := #iRecordPtr + #iRecLen;
END_FOR;
END_IF;
This pattern preserves every concurrent diagnostic event in a structured tag array (dbAlarm) where each bit corresponds to a distinct event-channel combination. The user program can then trigger individual HMI alarms or push them into the diagnostic buffer.
Multiple Simultaneous Fault Handling
The default behaviour of OB82 without RALRM returns only the most recent alarm. The PROFINET alarm queue holds multiple records, but OB82 startup information only contains a snapshot of one. To read all queued faults in a single OB82 pass:
- Always pass
MLEN = 65535to RALRM. - Parse the chained records starting at AINFO offset 24.
- Maintain a latch/tag array; the array is reset after each OB82 pass only if all bits are zero (i.e. the events have cleared).
- Track
IOFLAGS.0(incoming) andIOFLAGS.1(outgoing) to know whether to set or clear each alarm bit.
Verification Procedure
- Build the project with the new OB82, RALRM instance, and alarm DB.
- Download to the CPU 1516F-3 PN/DP and place the CPU in RUN.
- Force a Wire Break on channel 0 by disconnecting the signal wire. Confirm that
dbAlarm.WireBreak[0]sets and that the HMI alarm text appears. - Force an Overflow on channel 1 by applying > 10 V on a ±10 V input. Confirm both
WireBreak[0]andOverflow[1]are latched after a single OB82 pass. - Disconnect the L+ terminal on the AI module to trigger No supply voltage L+. Confirm
dbAlarm.NoSupplyVoltagesets and channels stop updating. - Reconnect L+. Confirm the bits clear on the outgoing event.
- Use the watch table to monitor
dbAlarmagainst the LEDs on the AI module (DIAG LED red on the module).
Troubleshooting Matrix
| Symptom | Likely Cause | Remediation |
|---|---|---|
| CPU goes to STOP on first diagnostic event | OB82 is missing or has wrong number | Insert OB82 in the project, ensure priority is correct, recompile and download |
| Only one fault visible per OB82 pass | RALRM not called or MLEN too small | Call RALRM with MODE = 0 and MLEN = 65535; parse the entire AINFO buffer |
| Wire Break bit not set despite open signal | Wire Break not enabled in channel diagnostics configuration | Re-open hardware properties, enable Wire Break, recompile, download |
| Overflow / Underflow bits set on every cycle | Wrong measurement range or overdriven sensor | Verify channel measurement type vs transducer; check full-scale limit settings |
| Common Mode error after L+ removal | Expected with floating L+; not a fault | Either accept as informational event or disable in HW config if intentional |
| Reference channel error on channels 0-5 | Channels 6/7 configured as reference and reporting | Disable reference channel mode or accept and alarm as informational |
| RALRM STATUS = 8080 / 8081 | Module address mismatch with HW_ID | Verify HW_ID; pass OB82 IO_LADDR as F_ID, not the diagnostic address |
| Module DIAG LED stays on after fault cleared | CPU did not acknowledge DS0/DS1 read | Ensure RALRM completed inside OB82 with STATUS = 0 |
| Alarm DB bits never clear | Outgoing event not handled | Track IOFLAGS bit 1 (outgoing) and reset the corresponding bits on removal |
Field-Proven Caveats
- Different firmware revisions of the AI module can shift the bit positions inside DS0. Always reference the Siemens Industry Online Support manual for your exact firmware release.
- On highly fragmented PROFINET topologies with strict priority enforcement, OB82 may not be called fast enough. Increase OB82 priority (lower number) if necessary, but never above the hardware interrupt OBs.
- For F-runtime CPUs (such as the CPU 1516F-3 PN/DP), OB82 must be a failsafe-aware OB. Use the F-OB82 if your project is configured with safety mode.
- On SIL3 / PROFIsafe projects, the diagnostic evaluation itself is non-safety; alarms are only informational. Never derive safety actions from OB82 data.
- Module-level diagnostics (No supply voltage L+, Common Mode error) are reported once for the entire module; channel-level diagnostics (Wire Break, Overflow, etc.) include the channel number in the DS0 record header.
Integration with HMI / Alarm Systems
Once dbAlarm contains the per-event, per-channel bits, the HMI application can subscribe via WinCC Professional or Unified to those tags. Recommended practices:
- Use
GetDiagnosisStateon the AI module symbol to drive the HMI channel status indicator. - Map each
dbAlarmbit to a discrete alarm with its own text buffer in the HMI alarm log. - Avoid using the default system diagnostic buffer view as the only alarm source — it does not guarantee per-event per-channel granularity.
Standards and References
The diagnostic record layout implemented above follows the PROFINET specification IEC 61158-6-10 (PROFINET IO application layer) for record types DS0 and DS1. The S7-1500 AI module implements this profile directly. For details on triggering and configuring diagnostic interrupts, see the official Siemens entry Entry 109011420 — Triggering diagnostics interrupts.
FAQ
Can OB82 alone identify which AI channel triggered the diagnostic interrupt?
OB82 startup information only exposes the channel number for the first queued alarm. To resolve all simultaneous faults you must call SFB54 RALRM inside OB82 and parse DS0/DS1 records returned in the AINFO buffer.
What is the difference between DS0 and DS1?
DS0 contains channel-specific diagnostics (Wire Break, Overflow, Underflow, Reference channel error, High/Low limit). DS1 contains module-level diagnostics (No supply voltage L+, Common Mode error, internal module fault). Both are returned in the AINFO buffer of RALRM.
Why does my CPU go to STOP when a diagnostic interrupt occurs?
The CPU transitions to STOP when no OB82 exists in the program. Insert OB82 with the correct priority (default 9) and the CPU will remain in RUN while invoking the OB on each incoming or outgoing diagnostic event.
Can I use RALRM from OB1 instead of OB82?
Calling RALRM from OB1 is possible but may miss transient alarms because the CPU acknowledges alarms when OB82 exits. For deterministic capture of every diagnostic event, call RALRM directly inside OB82.
What is the Siemens reference example for this implementation?
Siemens provides a complete TIA Portal sample including SCL source, FB, and documentation at Entry 109480387. It demonstrates multi-channel evaluation on ET 200SP and S7-1500 stations.