Resolving Local Data Stack Memory Exhaustion for OB35 in SIMATIC S7-400 and PCS 7
In SIMATIC PCS 7 and STEP 7, when compiling or downloading CFC charts fails with an error indicating that local data requirements for OB35 exceed the configured stack memory, the CPU's temporary local data (L-stack) allocation for Priority Class 12 must be increased. This is resolved in HW Config by opening CPU Properties, navigating to the Memory tab, increasing the local data bytes assigned to Priority Class 12 (corresponding to cyclic interrupt OB35) within the hardware memory limits, and downloading the updated hardware configuration to the CPU.
Table of Contents
- Local Data (L-Stack) Architecture in S7-400 Controllers
- Step-by-Step Procedure to Increase OB35 Local Data Allocation
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Local Data (L-Stack) Architecture in S7-400 Controllers
In SIMATIC S7-400 and S7-410 automation stations, the CPU reserves temporary stack memory known as Local Data (L-Stack):
* Function of Local Data: Local data stores temporary variables (TEMP), parameter transfer addresses, and function call return pointers during block execution. Unlike static data in instance data blocks (DBs), local data exists only during the active execution lifetime of the block.
* Partitioning by Priority Class: The CPU divides its total available local data memory across execution priority classes:
* OB1: Priority Class 1 (Main scan)
* OB38: Priority Class 25 (10ms interrupt)
* OB35: Priority Class 12 (100ms standard process control interrupt)
* OB34: Priority Class 11 (200ms interrupt)
* OB32: Priority Class 9 (1000ms interrupt)
* OB8x: Priority Classes 26-28 (Diagnostic and hardware fault interrupts)
* Root Cause of Exhaustion in PCS 7: Complex CFC charts containing deeply nested macro blocks, extensive Advanced Process Library (APL) calls, or multiple cascading channel drivers consume significant temporary stack memory per call depth. If the accumulated stack depth exceeds the default memory allocated to Priority Class 12 (typically 1024 or 2048 bytes), the CFC compiler or download engine blocks the operation to prevent runtime stack overflow and CPU STOP crashes.
Step-by-Step Procedure to Increase OB35 Local Data Allocation
Follow this procedure in SIMATIC Manager HW Config to expand the local data allocation.
Prerequisites
- SIMATIC Manager open with write permissions to the AS project.
- Controller status evaluated: updating CPU local data requires downloading HW Config, which typically necessitates a CPU STOP or planned maintenance window.
Step 1: Open CPU Properties in HW Config
- In SIMATIC Manager, navigate to the target automation station and open HW Config.
- Locate the central controller (e.g.,
CPU 410-5HorCPU 417-4H) in the central rack. - Double-click the CPU module to open its Properties dialog.
Step 2: Navigate to Memory Tab and Adjust Priority Class 12
- Select the Memory tab.
- In the Local Data section, locate the table listing priority classes and their byte allocations.
- Identify Priority Class 12 (which directly governs
OB35execution). - Review the current allocated bytes (e.g.,
1024or2048bytes). - Increase the allocation to satisfy compiler requirements (e.g., increase to
4096or8192bytes). - Verify that the sum of all priority classes does not exceed the Total local data memory supported by the CPU model (displayed at the top of the table). If necessary, reduce allocations from unused priority classes (e.g.,
OB1or unused interrupt OBs) to balance the total. - Click OK to accept the parameters.
Step 3: Save, Compile, and Download Hardware Configuration
- In HW Config, select Station -> Save and Compile.
- Put the automation station into a planned maintenance state.
- Select PLC -> Download to Module... and download the updated configuration to the CPU.
- If prompted that the CPU must transition to
STOP, confirm the restart sequence.
Step 4: Recompile and Download CFC Charts
- Return to SIMATIC Manager.
- Select the Chart folder in the S7 Program.
- Execute a full compilation:
Chart -> Compile -> Entire Program. - Verify that the compilation log reports
0 Errors. - Download the CFC program to the CPU:
CPU -> Download.
Verification
- In SIMATIC Manager, open the module information dialog (
Ctrl + D) for the CPU. Navigate to the Memory tab: confirm that the allocated local data reflects the updated values. - Review the CPU diagnostic buffer: verify that no event entries for
Event ID 16#4541(Local data allocation error) or16#2522(Stack overflow) exist. - In CFC, run
Chart -> Check Consistency -> Entire Program: confirm that zero local data warning flags appear. - Transition the CPU to
RUNand verify that allOB35chart blocks execute dynamically without cycle time overruns.
Limitations and Operational Precautions
- Total Local Data Limit: Each CPU hardware revision has a fixed global local data ceiling (e.g., 64 KB or 128 KB for modern S7-400/410 CPUs). You cannot allocate more local data than the physical memory limits of the processor.
- CPU STOP Requirement: Modifying memory allocation in HW Config changes the core operating system memory partition of the S7-400 processor. In standard single-CPU systems, this strictly requires a CPU STOP. In redundant S7-400H/410H systems, evaluate whether Type Change in Run (TCiR) or a staged redundancy switchover is permitted.
- Deep Call Stacks in Custom Blocks: If user-created SCL blocks utilize deep recursive calls or massive local arrays, refactor the code to move temporary arrays into static data blocks (
STATvariables) rather than exhausting the L-stack.
Engineer FAQ
- Which priority class corresponds to OB35?
In SIMATIC S7-400 controllers, cyclic interruptOB35runs at execution Priority Class 12. - Can I increase local data memory online without stopping the CPU?
In standard S7-400 processors, no. Memory table reconfiguration requires a hardware download in STOP mode. In S7-410H redundant systems with appropriate firmware, configuration changes may be accommodated via redundant failover procedures. - Why does CFC use so much local data compared to classic ladder logic?
CFC generates extensive intermediate parameter connections, structured variable wrappers, and diagnostic pointers that are transferred on the temporary stack between interconnected blocks. - How do I find out exactly how many bytes OB35 requires?
During CFC compilation, if local data is exceeded, the compiler log reports the exact number of bytes required by the deepest block call tree versus the currently configured limit. - Can I reduce local data on OB1 to give more to OB35?
Yes. In PCS 7, process logic executes in cyclic OBs, soOB1has minimal logic. You can safely reduce Priority Class 1 (OB1) allocation to free bytes for Priority Class 12.
Technical References
- Siemens Industry Online Support Entry ID 109801081: Configuring Local Data for Organization Blocks in S7-400.
- Siemens System Manual: SIMATIC S7-400 CPU Specifications and Memory Architecture.
- Siemens SIMATIC PCS 7 CFC Manual: Compiler Memory Requirements and Stack Allocation.
Related Articles
- [[Understanding and Configuring Process Image Partitions for PCS 7 Channel Blocks]]
- [[Optimizing S7-400 Cycle Times and Execution Sequences in PCS 7]]
- [[Troubleshooting S7-400 CPU Stop Errors and Diagnostic Buffer Faults]]
Related Tags
- PCS 7
- S7-400
- OB35
- Local Data
- L-Stack
- CFC
- HW Config
- Industrial Automation