Resolving S7-400 Local Data Stack Exceeded in Priority Class 27 (OB100) During CFC Compilation
In SIMATIC PCS 7, the compilation error 'Local data requirements (848 bytes...) for organization block OB100 is larger than the local data stack configured in the connected online CPU for corresponding priority class 27' occurs when the cumulative local variable (L-stack) demand of startup initialization blocks exceeds the memory quota assigned to Priority Class 27 in HW Config. Simply increasing Class 27 memory fails if the total allocated local data exceeds the CPU's total memory ceiling. To resolve this, decrease local data allocations on unused priority classes (such as OB20, OB30, OB31) to balance the total memory budget, execute 'Save and Compile' in HW Config, and download the updated hardware configuration.
Table of Contents
- Architecture of the S7-400 Local Data Stack (L-Stack)
- The Priority Class Allocation Mechanism in HW Config
- Why Priority Class 27 (OB100 Startup) Exhausts Memory Quotas
- The Total Local Data Memory Ceiling and Allocation Balancing
- Priority Classes, Organization Blocks, and Recommended Allocations
- Step-by-Step Procedure to Reallocate Local Data and Recompile
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Architecture of the S7-400 Local Data Stack (L-Stack)
In SIMATIC S7-400 controllers (e.g., CPU 416-5H 6ES7416-5HT06-0AB0 or CPU 417-4), temporary variables (VAR_TEMP), block call parameters, and system function interfaces do not reside in permanent Data Blocks. Instead, they execute in a dedicated, high-speed CPU memory area known as the Local Data Stack (L-Stack):
* The Call Stack: When a block executes, its temporary variables are pushed onto the L-stack. When the block completes, the stack unwinds.
* Nesting Depth: If Block A calls Block B, which in turn calls Block C, the local data requirements accumulate sequentially:
$$\text{Total L-Stack} = L_A + L_B + L_C + \dots + L_{\text{OB121/122}}$$
* Inclusive Fault Overhead: In PCS 7, the compiler automatically reserves headroom (typically 64 to 128 bytes) within the calculation to guarantee that synchronous error blocks (OB121 Programming Error and OB122 I/O Access Error) have sufficient memory to execute if a fault occurs during block processing.
The Priority Class Allocation Mechanism in HW Config
Unlike smaller PLCs where a single local data pool is shared dynamically, the S7-400 hardware operating system strictly partitions its local data memory across Priority Classes (1 to 28):
* Hardware Configuration: In HW Config > CPU Properties > Memory, the table allocates a fixed byte quota to every individual priority class.
* The Static Quota Rule: A priority class cannot borrow unallocated memory from another class during runtime. If Priority Class 27 is allocated 512 bytes, and the compiled call chain requires 848 bytes, the CPU will trip on an L-stack overflow.
* CFC Compiler Verification: During CFC compilation, the compiler parses all block execution trees. If the calculated nesting depth for any task exceeds the quota defined in the offline hardware configuration, compilation aborts with a fatal class error.
Why Priority Class 27 (OB100 Startup) Exhausts Memory Quotas
Priority Class 27 is exclusively assigned to Organization Block 100 (OB100: Complete Restart):
- Startup Execution Complexity:
When an S7-400 CPU transitions from STOP to RUN, OB100 executes once to initialize hardware, parameterize communication channels, reset interlocks, and configure driver blocks. - Advanced Process Library (APL) Impact:
Modern APL blocks execute extensive initialization routines in OB100. When hundreds of technological blocks (MotL,VlvL,PIDConL) are instantiated, the CFC compiler groups their startup logic into cascading runtime groups. - The 848-Byte Threshold:
The default S7-400 hardware configuration allocates only 512 bytes to Priority Class 27. An APL project with multi-instance nesting quickly reaches 800 to 1,200 bytes, exceeding the factory default and halting compilation.
The Total Local Data Memory Ceiling and Allocation Balancing
Why did increasing Class 27 from 512 to 1024 bytes fail in the reported incident?
- The Hardware Memory Ceiling:
Every S7-400 CPU model has a strict, unexpandable maximum limit on total local data memory (e.g., 16 KB on older CPUs, 32 KB on mid-range, and 64 KB on CPU 416/417). - The Allocation Balance Constraint:
The sum of memory allocated across all 28 priority classes must not exceed the CPU's total local data memory ceiling:
$$\sum_{i=1}^{28} \text{AllocatedMemory}_i \le \text{MaxLocalData}$$ - The Failure Mechanism:
If the memory table was already fully allocated, increasing Class 27 pushes the total sum above the hardware limit. HW Config either rejects the change, or the engineer modifies the table without clicking Save and Compile, leaving the offline compiled database out of sync with the CFC compiler.
Priority Classes, Organization Blocks, and Recommended Allocations
The following table details the mapping of priority classes to Organization Blocks and verified allocation strategies:
Step-by-Step Procedure to Reallocate Local Data and Recompile
Follow this verified engineering workflow to resolve Priority Class 27 memory exhaustion:
- Calculate Required Memory:
* Inspect the error message:Local data requirements (848 bytes, inclusive OB121 and OB122)....
* Add a 20% engineering margin: Target allocation for Class 27 = 1024 to 1536 bytes. - Open HW Config and Modify Memory Table:
* In SIMATIC Manager, open HW Config for the S7-400 AS.
* Double-click the CPU to open Object Properties.
* Navigate to the Memory tab.
* Under the Local Data table:- Locate Priority Class 27 and set value to 1536.
- To compensate and balance the total memory budget, locate unused priority classes (e.g., Classes 2, 3, 4, 14, 15) and reduce them from 256 to 0 or 128.
- Verify that the sum does not exceed the maximum allowable total displayed at the bottom of the dialog.
- Save and Compile Hardware Configuration:
* In HW Config, click Save and Compile (Ctrl+S).
* Critical: Ensure compilation finishes with 0 errors so the offline database updates. - Download Hardware Configuration to the CPU:
* Download the updated HW Config to the CPU (requires CPU in STOP mode during commissioning, or planned maintenance window). - Recompile CFC Program:
* Open any CFC chart.
* Select Chart > Compile > Entire program (or Changes only).
* Verify that the compilation finishes successfully with 0 Errors.
Verification
Verify that local data stack allocation is compliant:
1. In the CFC compilation log, verify that compilation completes with 0 Errors and 0 Warnings.
2. In SIMATIC Manager, select the CPU and press Ctrl+D (Module Information); open the Memory tab and confirm that the online CPU reports updated local data quotas matching HW Config.
3. Switch the CPU to RUN mode; verify that OB100 executes cleanly during warm restart without triggering an L-stack overflow or calling OB121.
4. Open the CPU Diagnostic Buffer; confirm that zero entries referencing 16#4541 (Priority class error) or 16#2522 are recorded.
Limitations and Operational Precautions
- Hardware Download Requires CPU STOP: Modifying the CPU Memory properties table in HW Config cannot be downloaded dynamically in RUN mode. Plan a maintenance shutdown window to transition the controller to STOP mode for download.
- Never Zero Out Active Classes: Never reduce allocations on priority classes assigned to active Organization Blocks (such as Class 12 for OB35 or Class 25 for OB86). Doing so causes instant CPU halts when those interrupts fire.
- Recursive Call Traps in SCL: If custom SCL blocks use deep recursion or declare massive arrays under
VAR_TEMP(e.g.,temp_buffer : ARRAY[1..1000] OF REAL), the L-stack will be exhausted regardless of allocation. Move large temporary arrays into static data block memory (VAR). - Commercial Accuracy: High-performance S7-400 controllers (e.g.,
6ES7416-5HT06-0AB0or CPU 410-5H6ES7410-5HX08-0AB0) require authorized licensing and certified engineering workflows. Procure hardware through an authorized Siemens distributor quotation.
Engineer FAQ
Why does the compiler error mention OB121 and OB122 if they are not in OB100?
The CFC compiler adds the local data requirement of OB121 (Programming Error) and OB122 (Access Error) to every task's calculation to guarantee that if an unexpected instruction fault occurs, the CPU has enough remaining stack space to execute the error handler.
Can I avoid restarting the CPU by reducing local data in the CFC blocks instead?
Yes. If you inspect the blocks called in OB100 and refactor custom blocks to move large VAR_TEMP arrays into VAR (instance DB), the required L-stack can drop below 512 bytes, allowing compilation without modifying HW Config.
What is the maximum local data memory on an S7-410-5H controller?
The SIMATIC S7-400 CPU 410-5H features an expanded local data architecture supporting up to 64 KB of total local data, providing ample headroom for massive APL multi-instance projects.
Why did the CFC compile error persist if the CPU was already running with 1024 bytes?
The CFC compiler evaluates the offline HW Config database in the project directory, not the physical online CPU registers. If HW Config was not saved and compiled offline, the compiler still reads the old 512-byte limit.
Technical References
- SIMATIC S7-400 Automation System Module Data Manual - Siemens AG
- SIMATIC STEP 7 V5.5 / V5.6 System Architecture and Local Data Guide
- SIMATIC Process Control System PCS 7 Engineering System Manual
Related Articles
- Diagnosing Unscheduled S7-400 CPU STOP Mode Events via Diagnostic Buffer and Organization Blocks
- Resolving S7-400 CFC Compile Error: Maximum Length of Code Area Reached
- Preventing Engineering Station Crashes and Fatal Exceptions During S7-400 Downloads
Related Tags
- Local Data Stack
- Priority Class 27
- OB100
- HW Config Memory
- CFC Compile Error
- S7-400 Architecture