Overview
On a SIMATIC S7-1500F CPU (for example CPU 1511F-1 PN, CPU 1515F-2 PN, CPU 1516F-3 PN/DP, CPU 1517F-3 PN/DP, CPU 1518F-4 PN/DP), the safety program runs inside an F-runtime group. During engineering and first-stage commissioning, an F-CPU can be operated with safety functions deactivated so that program changes can be downloaded in RUN. Production must never start in that state, so the standard (non-safety) user program must be able to detect whether the safety program is active, passivated, or disabled, and surface this state to the operator via HMI and alarm logging.
Three independent mechanisms are available:
- F-runtime group status tags – a structured tag block exposed by TIA Portal that reflects the live state of each F-runtime group; directly readable from the standard user program.
-
Diagnostic interrupt handling via
OB82– fires when an F-module changes its diagnostic state, is passivated, or is reassigned. -
Diagnostic buffer evaluation – the CPU stores safety-mode change events that can be read on demand with
RDSYSST(SFC51) or via the web server / TIA Portal information API.
This reference describes all three mechanisms, the relevant tag layout, code samples in LAD and SCL, the HMI configuration, and the verification procedure you should run before handing the cabinet over to production.
Prerequisites
| Item | Requirement |
|---|---|
| CPU | S7-1500F family (any variant with Safety Integrated) |
| Firmware | F-CPU firmware V2.0 or higher (V2.9 recommended for current F-runtime group tag layout) |
| TIA Portal | V17 or higher (V18 / V19 required for newer CPU types) |
| STEP 7 Safety | Optional package installed (mandatory for F-programming) |
| Safety program | At least one F-runtime group compiled without errors |
| Standard program | OB1 / OB82 / OB100 in the standard task |
| HMI | Comfort Panel, WinCC Runtime, or Unified Comfort Panel with tag interface |
F-Runtime Group Status Tags
The most direct method. TIA Portal automatically creates a structured status block for each F-runtime group. The tag is configured under Safety Administration > F-Runtime Group > Properties > F-Runtime Group Status. Enable the option "Generate status for F-runtime group" and assign a name (default F_RTG1_STATUS).
The generated status is a WORD or DWORD with the following bit layout (firmware-dependent; values shown correspond to firmware V2.9):
| Bit | Symbolic name | Meaning when TRUE |
|---|---|---|
| 0 | RTG_RUN | F-runtime group is in RUN, safety program executing |
| 1 | RTG_ERROR | F-runtime group has an error (e.g. F-I/O passivation, F-monitoring time exceeded) |
| 2 | RTG_PASSIVATED | At least one channel of an F-module is passivated |
| 3 | RTG_SAFETY_DEACTIVATED | Safety mode is deactivated for this F-runtime group (commissioning state) |
| 4 | RTG_SIGNATURE_OK | F-signature of the runtime group matches the compiled signature |
| 5 | RTG_DB_ERROR | F-instance DB / F-DB shows inconsistency |
| 6 | RTG_COMM_ERROR | PROFIsafe communication error to a distributed F-device |
| 7 | RTG_FIO_FORCE | Forcing is active on at least one F-I/O |
| 8–15 | Reserved | Reserved by Siemens; do not evaluate |
The status tag is declared as a standard-accessible variable, so a normal BOOL read from OB1 works without any F-knowledge. Sample SCL snippet for OB1:
// "SafetyModeActive" TRUE only when runtime group is RUN
// and safety is not deactivated, no passivation, no error.
IF "F_RTG1_STATUS".RTG_RUN
AND NOT "F_RTG1_STATUS".RTG_SAFETY_DEACTIVATED
AND NOT "F_RTG1_STATUS".RTG_PASSIVATED
AND NOT "F_RTG1_STATUS".RTG_ERROR
THEN
"SafetyModeActive" := TRUE;
"SafetyModeAlarm" := FALSE;
ELSE
"SafetyModeActive" := FALSE;
"SafetyModeAlarm" := TRUE;
END_IF;
If you have multiple F-runtime groups (typical with two F-runtime groups for redundancy or splitting standard and process safety), repeat the same logic for F_RTG2_STATUS, F_RTG3_STATUS, etc.
Diagnostic Interrupt via OB82
OB82 fires whenever an F-module's diagnostic state changes – for example when safety inputs are passivated, when an F-DO channel is forced, or when the module detects an internal diagnostic event. The local temporary variables of OB82 provide the slot, event type, and channel diagnostics of the affected module.
| OB82 local variable | Data type | Meaning |
|---|---|---|
| OB82_EV_CLASS | BYTE | Event class (0x38 = outgoing, 0x39 = incoming diagnostic) |
| OB82_FLT_ID | BYTE | Fault ID (e.g. 0x05 = channel error, 0x06 = channel diagnostics lost) |
| OB82_IO_FLAG | BOOL | Input module flag |
| OB82_MDL_ADDR | UINT | Logical base address of the F-module |
| OB82_RACK_NUMBER | UINT | Rack / station number |
| OB82_MDL_TYPE | UINT | Module type identifier (e.g. 0x8000 = ET200S F-DI) |
| OB82_CHANNEL | UINT | Channel number |
| OB82_IO_STATE | BOOL | I/O state (TRUE = good) |
| OB82_DIAG_FLAGS | BYTE | Diagnostic flags (sequence, channel, module, submodule) |
Use OB82 to:
- Set a sticky
BOOLflag (e.g.SafetyIOEvent) that the standard program can poll. - Write the offending logical address into an array so the operator can see exactly which F-channel went into passivation.
- Trigger an HMI alarm using
ALARM_8Por the newerProgram_Alarmwith the affected module address concatenated into the alarm text.
// OB82 - Diagnostic Interrupt
#lError := #OB82_FLT_ID <> 0;
IF #lError THEN
// Capture address and fault code
"diagEvent".mdlAddr := #OB82_MDL_ADDR;
"diagEvent".channel := #OB82_CHANNEL;
"diagEvent".fltId := #OB82_FLT_ID;
"diagEvent".eventTs := RTM_T_RETCODE_OF_RUNTIME; // optional timestamp
// Increment event counter for HMI
"SafetyEventCount" := "SafetyEventCount" + 1;
// Raise HMI alarm via Program_Alarm (TIA V17+)
"instProgramAlarm"();
END_IF;
OB82_EV_CLASS – only act on the transition that actually indicates the new state, otherwise you will get duplicate alarms when the fault clears.Diagnostic Buffer Evaluation
The CPU's diagnostic buffer contains a chronological list of events, including safety-related ones. Read entries with RDSYSST (SFC51) using SSL ID W#16#0132 for the partial list or W#16#00B2 for the diagnostic buffer.
The relevant event IDs for safety mode transitions (from the Siemens "SIMATIC S7-1500F System Manual"):
| Event ID | Description |
|---|---|
| 0x9F11 | Safety mode activated for F-runtime group n |
| 0x9F12 | Safety mode deactivated for F-runtime group n |
| 0x9F22 | F-monitoring time exceeded |
| 0x9F31 | Passivation of F-I/O channel |
| 0x9F32 | Reintegration of F-I/O channel after error clear |
| 0x9F41 | F-signature mismatch detected |
| 0x9F50 | Forcing active on F-I/O |
Sample call:
// Read last 10 diagnostic buffer entries
iRet := RDSYSST(REQ := TRUE,
SSL_ID := W#16#0132,
INDEX := 0,
LEN := 80,
BUSY := xBusy,
SZL_HEADER := sHeader,
DR := aDiagBuf);
IF NOT xBusy AND (iRet = 0) THEN
FOR i := 1 TO 10 DO
IF aDiagBuf[i].EventID = W#16#9F12 THEN
// Safety was JUST deactivated - log to HMI
"HMI_SafetyDeactivated" := TRUE;
END_IF;
END_FOR;
END_IF;
For real-time alarming without polling, prefer the OB82 mechanism; use the buffer only for forensic logging (audit trail) of when safety mode was toggled.
Passivation Status Per Channel
Each F-module exposes a per-channel passivation bit. You can query the status via:
-
RDREC(SFB52) reading record index0x8000(F-I/O passivation status) from the F-module's slot. - The VALUE_STATUS tag automatically generated by TIA Portal for ET 200SP F-modules. The bit
QUALITY= bad indicates a passivated channel.
Useful for HMI screens that color-code individual channels:
// F-DI 16x24VDC HF (slot 4), base address 100
// Read record 0x8000 once per OB1 cycle for passivation bitmap
iRet := RDREC(REQ := TRUE,
IOID := 0,
LADDR := 100,
RECNUM := 16#8000,
RET_VAL := iRetVal,
BUSY := xBusy,
RECORD := aRec);
F-Signature Verification
Every F-runtime group has a 32-bit F-signature computed at compile time. If a programmer downloads a modified safety program without re-validating the F-signature in TIA Portal, the F-runtime group enters an error state. You can mirror the expected signature into a standard DB at compile time and compare it at runtime:
// Compile-time constant from TIA Portal "Safety > F-Signature"
#ExpectedSig := 16#A1B2_C3D4;
IF "F_RTG1_STATUS".RTG_SIGNATURE_OK
AND ("ActualSignature" = #ExpectedSig)
THEN
"SignatureValid" := TRUE;
ELSE
"SignatureValid" := FALSE;
END_IF;
This is independent from the OB82 mechanism and catches the case where someone re-flashed the safety project without coordinating with operations.
HMI Configuration and Alarm Generation
Create the following HMI tags in WinCC / Unified Comfort:
| HMI tag | PLC address | Type | Use |
|---|---|---|---|
| SafetyModeActive | DB100.DBX0.0 | BOOL | Status indicator on overview screen |
| SafetyModeAlarm | DB100.DBX0.1 | BOOL | Trigger for Alarm_8 word |
| SafetyEventCount | DB100.DBD4 | DINT | Counter shown on diagnostic screen |
| SafetyRTGStatus | DB100.DBW8 | WORD | Raw status word for engineering view |
| LastEventTime | DB100.DBX12.0 | DTL | Timestamp of last safety event |
Configure two HMI alarms:
-
Alarm 1 – "Safety mode deactivated", class "Error", triggered by rising edge of
SafetyModeAlarm. Text must include the actual reason:'Safety runtime group 1 is not active (RTG_RUN=0 / SAF_DEACT=1). Production lockout engaged.' -
Alarm 2 – "F-I/O passivation", class "Warning", triggered by rising edge of
SafetyEventCount. Include channel fromdiagEvent.mdlAddranddiagEvent.channel.
For Unified Comfort Panels use the Program_Alarm instance for fully dynamic alarm text with embedded module address and channel number.
Commissioning Sequence and Verification
Validate the detection logic before you allow the line to enter production:
- Compile the F-runtime group, note the F-signature, store it in
ExpectedSig. - Download both safety and standard program. In TIA Portal, go online and verify that
F_RTG1_STATUS.RTG_RUN = TRUEandRTG_SAFETY_DEACTIVATED = FALSE. - Force
SafetyModeActivevia the watch table toFALSE– confirm that HMI alarm 1 appears with the correct text and that any production-start permissive tied toSafetyModeActiveis blocked. - In TIA Portal, choose Safety > Deactivate safety mode for the F-runtime group. Confirm that
RTG_SAFETY_DEACTIVATEDbecomesTRUEand the alarm fires within one OB1 cycle. - Pull an F-DI module or disconnect the PROFIsafe cable to an ET 200SP station. Verify OB82 triggers,
SafetyEventCountincrements, and alarm 2 appears with the correct module address. - Reconnect / rein – confirm the outgoing diagnostic also fires (clear the alarm message manually if your HMI is configured to auto-ack).
- Re-activate safety mode in TIA Portal, perform a signature acceptance download, and verify
SafetyModeActivereturns toTRUEand the alarm clears.
Troubleshooting Matrix
| Symptom | Likely cause | Check / fix |
|---|---|---|
| SafetyModeActive never goes TRUE in standard program | F-runtime group status not generated in TIA Portal | Open F-runtime group > Properties > Status, tick "Generate status" and recompile |
| Status tag shows all zeros after download | Standard program block was downloaded without recompiling the safety project | Recompile all blocks, perform full download of both safety and standard programs |
| OB82 never fires despite passivation | OB82 missing or not assigned in CPU properties | CPU > Properties > System and Clock Memory > OB82 = "OB82 is called" |
| F-signature mismatch alarm on every restart | Compile-time constant not updated after F-program change | Copy new F-signature from TIA Portal into ExpectedSig constant |
Reading F_RTG1_STATUS from SCL triggers "Access to safety tag from standard program not allowed" |
Status tag was not enabled as standard-accessible in the F-runtime group properties | Check the option in TIA Portal: Standard user program can read F-runtime group status |
| HMI alarm text shows raw placeholder instead of module address | Alarm configured as static text instead of Program_Alarm
|
Switch to Program_Alarm with format string containing %d for address |
| SafetyModeAlarm latched ON after a brief transient | Alarm tag was set as non-retriggering | Use a one-shot rising-edge evaluation in OB1; clear the alarm only after a sustained RUN condition for N cycles |
Safety-Program Constraints You Cannot Bypass
The standard user program can read safety state but cannot modify it. The following are enforced by the F-CPU regardless of your logic:
- You cannot set
RTG_RUNorRTG_SAFETY_DEACTIVATEDfrom a standard FB/FC. - You cannot write to F-DB variables except through the F-block interfaces.
- You cannot acknowledge passivation of an F-channel from the standard program – only the F-runtime group itself can reintegrate.
- Modifying the standard program does not require an F-signature acceptance; modifying the safety program does.
See the Siemens manual collection for the F-CPU family at the official TIA Portal help and the F-CPU system manual for full rules on what is and is not accessible across the safety boundary. A documented configuration reference for the disabling safety mode workflow is published at SIMATIC Safety: Disabling safety mode.
FAQ
Can the standard user program force the safety runtime group to RUN?
No. F-runtime group state is controlled exclusively by the F-CPU operating system and the F-protection password. The standard user program can only read the status tags generated by TIA Portal under F-runtime group properties.
Which firmware version introduced the structured F-runtime group status?
F-runtime group status tags were introduced with the first S7-1500F firmware V2.0 and have been extended since. The exact bit layout shown in this article matches firmware V2.9. Check the F-CPU manual for your specific firmware if bit assignments differ.
Is OB82 the same as a PROFIsafe error?
OB82 is a generic diagnostic interrupt. It fires for F-module events but also for non-safety diagnostics. You must filter on the module address range or on OB82_FLT_ID to distinguish safety-related events from standard diagnostics.
How do I log when safety mode was disabled so the auditor can see it?
Read the diagnostic buffer with RDSYSST (SFC51) SSL W#16#0132 on a scheduled basis (for example every 100 ms in OB1) and write any entry with event ID 0x9F12 to your central log DB with a DTL timestamp. This gives a tamper-resistant audit trail.
Can I block production start when safety mode is deactivated?
Yes. Tie the start permissive in your standard logic to SafetyModeActive = TRUE. Many plants also wire a hard-wired permissive from the safety relay output so that the line cannot start even if the PLC logic is bypassed.