Overview
The Siemens S7-300 and S7-400 families expose operating-hour counters as Runtime Meters (RTM). The standard SFCs that drive these counters are SFC 2 SET_RTM, SFC 3 CTRL_RTM, and SFC 4 READ_RTM. A fourth block, SFC 101 RTM_USAGE, is reserved for CPUs that implement a 32-bit RTC and returns the count of used/available RTM channels. CP (Communication Processor) faults, on the other hand, are not reported through the RTM system; they are exposed through diagnostic interrupts and the Report System Error (RSE) wizard, which formats them for ProTool, WinCC flexible, and TIA Portal HMIs.
This reference covers three problem domains that are frequently mixed in field service tickets:
- Why
SFC 2/3/4appears to stop responding after seven runtime meters are written. - Why
SFC 101compiles on one CPU and is rejected on another. - How to read CP fault data and surface it on a Siemens HMI without writing a custom diagnostic FB.
RTM Architecture in S7 CPUs
Each S7 CPU reserves a non-retentive word (16-bit RTC) or double-word (32-bit RTC) per runtime meter. The hardware stores the meter value in the system memory area of the CPU; the user program can only access it indirectly through the SFC interface. The RTC oscillator keeps the meter running even when the PLC is in STOP, so total operating hours are preserved across power cycles.
Key architectural constraints enforced by the firmware:
- Channel count: Most S7-300 CPUs expose 8 RTM channels (indices 0..7). Some low-end CPUs expose 4, and a few expose only 1. The count is a CPU property, not a project property.
- Bit width: 16-bit RTC CPUs hold each meter as 16 bits; 32-bit RTC CPUs hold it as 32 bits.
- Granularity: The least significant bit represents 1 hour. Sub-hour timing must be done in the application with a cyclic interrupt OB (e.g., OB35 at 1 s) and a software counter.
-
Retentivity: The meter value itself is retained; the
RTMinstance data block is not. Always re-triggerSFC 2on cold restart.
Maximum RTM Count per CPU Family
| CPU Class | Order Number (example) | RTC Width | Max RTMs | SFC 101 |
|---|---|---|---|---|
| CPU 312 IFM | 6ES7 312-5AC02-0AB0 | 16-bit | 8 | No |
| CPU 312C | 6ES7 312-5BD01-0AB0 | 16-bit | 8 | No |
| CPU 313 | 6ES7 313-1AD03-0AB0 | 16-bit | 8 | No |
| CPU 313C | 6ES7 313-5BF03-0AB0 | 16-bit | 8 | No |
| CPU 314 IFM | 6ES7 314-5AE02-0AB0 | 16-bit | 8 | No |
| CPU 314C-2 DP | 6ES7 314-6CF02-0AB0 | 32-bit | 8 | Yes |
| CPU 315-2 DP | 6ES7 315-2AG10-0AB0 | 32-bit | 8 | Yes |
| CPU 317-2 PN/DP | 6ES7 317-2EK13-0AB0 | 32-bit | 8 | Yes |
| CPU 319-3 PN/DP | 6ES7 318-3EL00-0AB0 | 32-bit | 8 | Yes |
| CPU 412-1 | 6ES7 412-1XJ05-0AB0 | 32-bit | 16 | Yes |
| CPU 414-3 PN/DP | 6ES7 414-3EM06-0AB0 | 32-bit | 16 | Yes |
| CPU 416-3 PN/DP | 6ES7 416-3ES06-0AB0 | 32-bit | 16 | Yes |
| CPU 417-4 | 6ES7 417-4XT05-0AB0 | 32-bit | 16 | Yes |
| S7-1200 CPU 1214C | 6ES7 214-1AG31-0XB0 | 32-bit | 8* | No (TIA only) |
| S7-1500 CPU 1515-2 PN | 6ES7 515-2AM02-0AB0 | 32-bit | 16* | N/A (SysHourMeter) |
*S7-1200 and S7-1500 do not expose the legacy SFC2/3/4/101 interface; the equivalent is the RTM instruction in the TIA Portal instruction list and the SysHourMeter tag in the system diagnostics.
SFC 2 SET_RTM
Set the runtime meter at index 0..7 (or 0..15 on S7-400) to a defined hour count. Use this to align multiple meters after a CPU replacement or to seed a maintenance counter.
Call signature (SCL):
IF "FirstScan" THEN
"FirstScan" := FALSE;
RET_VAL := SET_RTM(
NR := 0, // RTM index 0..7
HOURS := 0, // initial hours
RET_VAL := RET_VAL); // error code
END_IF;
RET_VAL error codes (subset):
| W#16# | Meaning |
|---|---|
| 0000 | No error |
| 8081 | Selected RTM does not exist on this CPU |
| 8082 | HOURS out of range (16-bit: > 32767; 32-bit: > 2147483647) |
| 80A1 | Access to internal RTC failed |
SFC 3 CTRL_RTM
Start or stop the meter without changing the stored hours.
Call signature (ST):
// Stop RTM 0 when maintenance is in progress
IF "bMaintenanceActive" THEN
RET_VAL := CTRL_RTM(NR := 0, MODE := 0, RET_VAL := RET_VAL);
// MODE 0 = stop, 1 = start, 2 = set+start
ELSE
RET_VAL := CTRL_RTM(NR := 0, MODE := 1, RET_VAL := RET_VAL);
END_IF;
MODE values: 0 = stop, 1 = start, 2 = set to HOURS and start. RET_VAL codes are identical to SFC 2.
SFC 4 READ_RTM
Read the current hour count plus a STATUS bitfield that reports the run state. STATUS is a WORD with the layout shown below.
RET_VAL := READ_RTM(
NR := 0,
RET_VAL := RET_VAL,
HOURS := "rtHours",
STATUS := "rtStatus");
STATUS bitfield:
| Bit | Meaning |
|---|---|
| 0 | 0 = meter stopped, 1 = meter running |
| 1..15 | Reserved (0) |
SFC 101 RTM_USAGE (32-bit RTC only)
SFC 101 is implemented only on CPUs whose RTC is 32 bits wide. On a 16-bit RTC CPU the call returns W#16#8081 (RTM does not exist) and the output structure is left untouched. The block returns the number of RTMs that have been started, and the number of RTMs available on the CPU.
RET_VAL := RTM_USAGE(
RET_VAL := RET_VAL,
USAGE := "rtUsage", // INT, number of active meters
MAX_USG := "rtMax"); // INT, max meters on this CPU
Field-proven note: Do not treat MAX_USG as a project constant. It changes when the CPU is replaced by a smaller variant during service, which is one of the most common causes of the "I can only see 7 meters" symptom. Always read MAX_USG at startup and store it in a global tag.
Why You See Only 7 Working RTMs
The "only 7" symptom is almost always a mix of two conditions:
- The CPU has 8 RTM slots (indices 0..7). The user program is writing to indices 1..7 and reading index 0, so the maximum is 7 visible meters.
- One RTM was started by the project (e.g., a default from a copied block) and the SFC 2 call overwrites it, but the user expects it to be additive.
To verify the actual upper bound, call SFC 101 on a 32-bit RTC CPU, or read the system data word SD 11 in the CPU's system data (STEP 7 HW Config → CPU Properties → Diagnostics/Clock) where the firmware exposes the installed RTC width.
16-bit vs 32-bit RTC Differences
| Property | 16-bit RTC | 32-bit RTC |
|---|---|---|
| Storage per RTM | WORD (2 bytes) | DWORD (4 bytes) |
| Max hours before wrap | 32 767 h (≈ 3.7 years) | 2 147 483 647 h (≈ 245 000 years) |
| Typical CPUs | 312 IFM, 313, 313C, 314 IFM | 314C-2, 315-2, 317-2, 319-3, all S7-400 |
| SFC 101 | Not available | Available |
| Wraparound behavior | Counters stop at FFFF (or wrap to 0 on some FW versions) | Effectively no wrap |
SFC 4 on the old CPU, store the values in a recipe DB, and write them back with SFC 2 on the new CPU after the first STOP → RUN transition.Report System Error (RSE) for CP Faults
CP faults (CP 340, CP 341, CP 343-1, CP 443-1, etc.) are signalled to the CPU as diagnostic interrupts. The CPU then triggers the corresponding error OB. Report System Error is a STEP 7 / TIA Portal wizard that generates a set of standardized FBs and a text library that translate the raw SF (system fault) data into human-readable messages consumable by ProTool, WinCC flexible, and TIA Portal WinCC.
Hardware Configuration Path (STEP 7 V5.5)
- Open HW Config and select the CPU.
- Open the menu Options → Report System Error.
- Choose the supported OBs: OB 82 (diagnostic interrupt), OB 83 (insert/remove), OB 84 (CPU fault), OB 85 (priority class fault), OB 86 (rack/CP failure), OB 87 (communication fault), OB 121 (programming error), OB 122 (I/O access error).
- Click Generate. STEP 7 creates
FB 49(background), theSFB 100/FB 126diagnostic instance, and aDB 126error text DB. - Compile and download the hardware and the generated blocks.
Hardware Configuration Path (TIA Portal V13+)
- Open the device view of the CPU.
- Right-click the CPU → Properties → Report System Error.
- Enable Report System Error, select the error OBs to monitor, and confirm. TIA Portal generates
FB 1040(orRSE_FBon newer versions) and an associated instance DB. - Download hardware and software to the CPU.
Reading the CP Fault and Routing It to the HMI
Once RSE is generated, two data paths are available:
-
Diagnostic buffer: Every CP fault produces an entry in the CPU diagnostic buffer (accessible via Online → Accessible Nodes → Module Information in STEP 7, or via
RDSYSSTinstruction in TIA). The text library generated by RSE turns the SZL ID 0x0131 / 0x0132 entries into readable strings. -
Acknowledgement tag: RSE provides a single Boolean tag (e.g.,
RSE_CP1_Fault) per monitored module. The HMI displays the tag's status, and the operator can read the full text from the WinCC alarm log.
Programmatic Read via SFC 51 RDSYSST
If you need a custom HMI screen rather than the WinCC alarm view, read the partial system list yourself:
// Read SSL 0x0131 (diagnostic buffer, oldest entry) in OB 82
RET_VAL := RDSYSST(
REQ := TRUE,
SSL_ID := W#16#0131,
INDEX := 1,
RET_VAL := RET_VAL,
BUSY := busy,
SSL_RECORD := "diagBuffer", // 34-byte record
DR := dr);
The 34-byte record contains the event ID, the affected slot, the channel, and the diagnostic data. Parse the first two DWORDS to derive event class (W#16#01 = standard, W#16#02 = CPU fault, W#16#05 = communication) and then surface the string to the HMI over an OP-readable DB.
HMI Integration
ProTool / ProAgent
- Enable ProAgent in the ProTool project options.
- Insert a System Diagnostics screen; ProAgent populates it from the text library generated by RSE.
- Assign a single tag to the HMI polling address for the CP diagnostic bit.
WinCC flexible
- Open the HMI tags and confirm the System Diagnostics area pointer is enabled (default on most Siemens panels).
- Configure alarm routing: Alarms → Settings → System Events → enable System Error.
- Insert the System Diagnostics View control on a screen; WinCC flexible renders the CP fault and the slot number automatically.
TIA Portal WinCC
- In the HMI project, set the HMI connection to the S7 CPU.
- Add a System Diagnostics screen from the Controls palette.
- Compile and download. The control binds itself to the diagnostic buffer and to the RSE-generated tags without further configuration.
Alternative Timing Without RTM
When a project exceeds the available RTM channels, or runs on an S7-1200/1500 that does not expose the SFC interface, fall back to a software integrator. The integral of a constant 1 over a known cyclic interval equals the elapsed time:
// In OB35 (1 s cyclic interrupt)
IF "bEnable" THEN
"swSeconds" := "swSeconds" + 1;
IF "swSeconds" >= 3600 THEN
"swSeconds" := 0;
"swHours" := "swHours" + 1;
END_IF;
END_IF;
Store swHours in a retentive DB so the value survives STOP/RUN and power cycles. For sub-second precision, replace the implicit 1 s with the configured OB35 period and divide the increment by it.
Verification Checklist
- Open Online → Accessible Nodes → Module Information → Diagnostic Buffer and confirm that a CP 1 Fault Incoming event is recorded when the CP is unplugged.
- In OB 82, set a breakpoint on the first line and verify that
OB82_MDL_ADDRmatches the CP's diagnostic address (default for CP 343-1: 2047). - On the HMI, open the System Diagnostics view; the CP slot and the standard text "CP 343-1 (1) communication failure" should appear within one polling cycle.
- From the HMI, acknowledge the fault and confirm that the corresponding bit in DB 126 (STEP 7) or the RSE instance DB (TIA) clears.
Troubleshooting Matrix
| Symptom | Likely Cause | Correction |
|---|---|---|
| SFC 2/3/4 returns W#16#8081 on a valid index | CPU has fewer RTM slots than assumed | Read SZL 0x0011 via SFC 51; reduce index range |
| SFC 101 always returns W#16#8081 | CPU has 16-bit RTC | Replace CPU with 32-bit RTC variant or omit SFC 101 |
| Meter wraps after ~3.7 years | 16-bit overflow | Migrate to a 32-bit RTC CPU (e.g., 6ES7 315-2AG10) |
| CP fault does not show on HMI | RSE wizard not run after hardware change | Re-run Options → Report System Error and re-download blocks |
| WinCC flexible shows a placeholder "%%" string | Text library not downloaded | In STEP 7, mark DB 126 as System Text Library and download the SDB |
| OB 82 does not trigger on CP pull | CP diagnostic interrupt not enabled in HW Config | Open CP properties → Basic Parameters → enable Diagnostic Interrupts |
| Counter increments only every 2 hours | Application polled on OB1 with 2-hour loop | Read once on cold restart, increment locally |
Why can I use only 7 runtime meters in some S7 CPUs even though there are 8 slots?
The eighth slot is typically index 7, which the project either does not write to or which is overwritten by a default SET_RTM call from a copied block. Read SZL 0x0011 with SFC 51 to confirm the actual maximum, and call SFC 101 on 32-bit RTC CPUs for a definitive count.
Why does SFC 101 RTM_USAGE fail on certain CPUs?
SFC 101 is implemented only on CPUs with a 32-bit real-time clock, such as the 6ES7 314-6CF02 (CPU 314C-2 DP) and the entire S7-400 family. On 16-bit RTC CPUs the call returns W#16#8081 (RTM does not exist) and the outputs are undefined.
How do I read a CP fault and display it on a Siemens HMI?
Enable Report System Error in HW Config (STEP 7) or CPU Properties (TIA Portal). STEP 7 generates FB 49, SFB 100, and DB 126; TIA generates FB 1040 and an instance DB. Insert the System Diagnostics view on the HMI and bind it to the diagnostic buffer; the panel renders the CP slot, error class, and standard Siemens text automatically.
Do RTM values survive a CPU replacement?
No. When you swap a CPU, the new module starts with all meters at zero. Read each meter with SFC 4 on the old CPU before the swap, store the hours in a recipe DB, and re-seed the new CPU with SFC 2 on the first STOP to RUN transition.
Can I use the legacy SFC 2/3/4/101 blocks on S7-1200 or S7-1500 CPUs?
No. The S7-1200 and S7-1500 families do not expose the SFC interface. Use the RTM instruction in the TIA Portal instruction list (S7-1200) or the SysHourMeter tag in the PLC tags → System diagnostics area (S7-1500). Both support 8 or 16 meters depending on the CPU variant.