Reading S7 CPU Work and Load Memory Consumption in PCS 7 via SFC 51 (RDSYSST)
Monitoring S7-400 and AS 410 CPU work and load memory consumption dynamically in SIMATIC PCS 7—for display on WinCC faceplates or export to reporting software—is accomplished using System Function SFC 51 RDSYSST (Read System Status List). While the standard driver block @CPU_RT provides organization block execution times and communication partner statistics, it does not output memory utilization metrics. By executing SFC 51 with SSL-ID W#16#0113 and INDEX W#16#0001, a custom SCL or CFC block reads total memory size, used memory, and the largest free contiguous memory block, enabling real-time calculation of percentage memory utilization.
Table of Contents
- Limitations of Standard Diagnostic Block @CPU_RT
- System Status List Architecture: SSL-ID W#16#0113
- Data Record Structure and Memory Metrics
- Implementing the Memory Monitoring SCL Function Block
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Limitations of Standard Diagnostic Block @CPU_RT
SIMATIC PCS 7 automatically integrates the runtime diagnostic block @CPU_RT (FB70) during module driver generation. While @CPU_RT provides vital diagnostics—including OB1 cycle times, cyclic interrupt execution durations, and the top 5 communication partner connections—it deliberately omits memory consumption data.
Engineers managing expanding plants or conducting capacity audits require programmatic access to Work Memory (Code & Data) and Load Memory (RAM/FEPROM) to trigger maintenance warnings before online download changes fail due to memory exhaustion.
System Status List Architecture: SSL-ID W#16#0113
The SIMATIC S7 operating system exposes internal memory partition tables via the System Status List (SZL / SSL). System Function SFC 51 RDSYSST extracts this data dynamically:
- SSL-ID
W#16#0113: Extracts memory area information for a single specified memory type. - INDEX
W#16#0001: Targets Work Memory (RAM allocated for execution of user code and data blocks). - INDEX
W#16#0002: Targets Load Memory (RAM and non-volatile flash memory storing the offline program).
Data Record Structure and Memory Metrics
The table below details the output record returned by SFC 51 for SSL-ID W#16#0113:
IndexW#16#0001 = Work memory).Code1 = Volatile RAM, 2 = Non-volatile FEPROM, 3 = Mixed).SizeModeGranuBer1Belegt1Block1Implementing the Memory Monitoring SCL Function Block
To expose memory consumption as WinCC runtime tags, implement a simple SCL block called cyclically (e.g., every 60 s):
FUNCTION_BLOCK FB_CPU_Memory_Monitor
VAR_OUTPUT
Total_Work_Mem_KB : REAL;
Used_Work_Mem_KB : REAL;
Free_Work_Mem_KB : REAL;
Work_Mem_Pct_Used : REAL;
Largest_Free_Block: DWORD;
END_VAR
VAR_TEMP
RetVal : INT;
Header : STRUCT
SSL_ID : WORD;
Index : WORD;
END_STRUCT;
DR : STRUCT
Idx : WORD;
Code : WORD;
Size : DWORD;
Mode : WORD;
Granu : WORD;
Ber1 : DWORD;
Belegt1: DWORD;
Block1 : DWORD;
END_STRUCT;
END_VAR
// Read Work Memory (Index = 1)
RetVal := RDSYSST(REQ := TRUE, SZL_ID := W#16#0113, INDEX := W#16#0001,
BUSY := #Busy, RET_VAL := #ErrCode, SSL_HEADER := Header, DR := DR);
IF RetVal = 0 THEN
Total_Work_Mem_KB := DINT_TO_REAL(DWORD_TO_DINT(DR.Size)) / 1024.0;
Used_Work_Mem_KB := DINT_TO_REAL(DWORD_TO_DINT(DR.Belegt1)) / 1024.0;
Free_Work_Mem_KB := Total_Work_Mem_KB - Used_Work_Mem_KB;
IF Total_Work_Mem_KB > 0.0 THEN
Work_Mem_Pct_Used := (Used_Work_Mem_KB / Total_Work_Mem_KB) * 100.0;
END_IF;
Largest_Free_Block := DR.Block1;
END_IF;
END_FUNCTION_BLOCK
Verification
To verify that memory consumption reads accurately:
- Instantiate the SCL block in a CFC chart assigned to OB32 (1000 ms) or OB35.
- Compile CFC and download changes to the CPU.
- In SIMATIC Manager, select the AS station and press
Ctrl + Dto open Module Information -> Memory tab. - Note the reported Work Memory: Size, Used, and Free.
- Open CFC Online Test mode on the monitoring block: verify that
Total_Work_Mem_KB,Used_Work_Mem_KB, and percentage match the Module Information hardware dialog to the exact kilobyte.
Limitations and Operational Precautions
Operational boundaries for memory diagnostic calls:
- Contiguous Memory Fragmentation: Download changes can fail even if total free memory is 30% if the
Largest_Free_Blockis smaller than a newly compiled instance DB. Always monitorLargest_Free_Block. - Do Not Call Every Scan: SFC 51 accesses internal kernel tables; calling it cyclically on every 10 ms OB scan consumes significant CPU processing time. Call it every 30 to 60 seconds.
- CPU 410-5H Dynamic Allocation: On the CPU 410-5H, work memory is dynamically sized according to the System Expansion Card (SEC); memory metrics scale with SEC capacity.
Engineer FAQ
Why doesn't the standard block @CPU_RT provide work memory consumption?
@CPU_RT was designed specifically to measure task execution times and communication load. Memory management tables reside in a different System Status List (SSL-ID 0113) accessed via SFC 51.
What does the parameter 'Largest Free Block' indicate?
It indicates the largest contiguous unfragmented memory segment. When downloading a new block to the CPU, it must fit into this single contiguous block, regardless of total accumulated free memory.
Can SFC 51 read memory consumption on redundant S7-400H CPUs?
Yes. When executed on an S7-400H or AS 410-5H redundant pair, SFC 51 returns the memory utilization of the master subsystem executing the block.
Can memory utilization tags be logged into WinCC Tag Logging?
Yes. By exposing Work_Mem_Pct_Used as an S7 tag with the 'Archive' attribute, WinCC automatically logs memory trends over time for capacity planning.
Technical References
- Siemens SIMATIC S7-300/400 System and Standard Functions Manual (A5E00850741 - Chapter 33: SFC 51 RDSYSST)
- Siemens SIMATIC S7-400 CPU Specifications and Memory Architecture Reference
- Siemens Industry Online Support Entry ID 109748907: Reading S7 Memory Areas Dynamically
Related Articles
- Resolving S7 CPU Local Data Stack Overflow Warnings in OB34 Priority Class 11
- Resolving CFC Download Error Block Already Exists in the CPU (FC3220, DB10237)
- AS 410-5H System Expansion Card (SEC) Online PO Upgrade from Laptop with Higher PCS 7 Version
Related Tags
- SFC-51
- RDSYSST
- Work-Memory
- Load-Memory
- CPU_RT
- Memory-Consumption