Resolving S7 CPU Local Data Stack Overflow Warnings in OB34 Priority Class 11

Resolving S7 CPU Local Data Stack Overflow Warnings in OB34 Priority Class 11

The Continuous Function Chart (CFC) compiler warning 'Local data requirements for priority class 11... exceed the configured local data stack of the corresponding priority class in the connected stand-alone CPU' occurs when the cumulative temporary local variable memory (L-stack) demanded by blocks assigned to cyclic interrupt OB34 surpasses the allocated stack space configured in HW Config. Modifying the CPU local data stack partitions in Hardware Configuration requires a CPU STOP to download. To resolve this condition online without halting production, engineers must audit Chart Reference Data, identify heavily nested block calls in OB34, and redistribute non-critical blocks to OB35 or OB32 to reduce local data stack consumption below the configured hardware threshold.

Table of Contents

Local Data Stack (L-Stack) Architecture in S7-400 CPUs

In SIMATIC S7-400 and AS 410 controllers, the operating system assigns a dedicated portion of system RAM to each priority class known as the Local Data Stack (L-stack). Temporary variables (TEMP / local data), block call parameter transfer structures, and interrupt organization blocks (OB121, OB122) execute inside this stack.

The CPU hardware configuration partitions total local data memory across priority classes (typically Priority 1 to 28). Priority Class 11 corresponds to cyclic interrupt OB34 (default 200 ms). When complex nested function blocks are added to OB34, the call depth and local variable allocations can exceed the hardware partition limit (e.g., 512 bytes).

Root Causes of Stack Allocation Overflow

Stack overflow warnings during compilation originate from three primary causes:

MechanismTechnical CauseConsequenceBlock Copying Between ControllersCopying complex CFC charts from high-end CPUs (e.g., CPU 410 with large default L-stack) into controllers with smaller L-stack allocations.Compiler warning/error: required stack (e.g., 604 bytes) exceeds configured size (512 bytes).Deep Call NestingMultiple nested function calls within OB34 accumulating temporary storage.If executed online, risks CPU Stop due to OB85 / OB121 stack overflow error.Compiler Safety ReservePCS 7 compiler reserves mandatory stack space for asynchronous error OBs (OB121, OB122).Usable user stack is lower than total configured partition size.

Resolving Local Data Stack Errors Without CPU STOP

When production is running and modifying HW Config (which mandates a CPU STOP) is unacceptable:

Step 1: Audit Local Data Requirements in Chart Reference Data

  1. In the CFC Editor, open Chart Reference Data (Ctrl + Shift + R).
  2. In the menu, select View -> Local Data (Ctrl + Shift + L).
  3. Locate OB34 (Priority Class 11) in the list.
  4. Inspect the call tree: identify the specific chart branches and nested blocks consuming the highest byte count.

Step 2: Redistribute Blocks to Other Cyclic Tasks

  1. Open the run sequence editor in CFC (Options -> Customize -> Run Sequence or click the Run Sequence icon).
  2. Identify blocks in OB34 that do not require high-speed 200 ms execution (e.g., slow calculation blocks, message blocks).
  3. Move those blocks from OB34 into OB35 (100 ms) or OB32 (1000 ms), provided the target OB has adequate stack margin.

Step 3: Recompile and Verify

  1. Compile CFC (Compile -> Changes only).
  2. Confirm that the local data warning disappears as OB34 stack requirements drop safely below the configured threshold.

Verification

To verify that the local data stack is properly balanced:

  1. Re-open Chart Reference Data -> Local Data view.
  2. Verify that OB34 (Priority Class 11) indicates configured capacity exceeds required capacity by at least 20%.
  3. Initiate a CFC download of changes (Download Changes).
  4. Check the controller diagnostic buffer (Ctrl + D): verify that no Event ID 16#4541 (Local data stack overflow) or 16#2522 events are logged.
  5. Confirm all blocks in OB34 execute online with normal cycle times.

Limitations and Operational Precautions

Operational boundaries when adjusting controller tasks:

  • Hardware Configuration Download Constraint: Modifying the CPU Memory tab in HW Config (to permanently expand Priority Class 11 stack size) cannot be downloaded via CiR (Configuration in RUN). It requires a complete CPU STOP.
  • Scan Time Balance: When relocating blocks from OB34 to OB35, verify that the added load does not cause OB35 execution time to exceed its cyclic interval.
  • Do Not Ignore Compiler Warnings: Disregarding local data warnings can lead to catastrophic controller stops during complex multi-alarm plant trips when OB121/OB122 fire simultaneously.

Engineer FAQ

Can local data stack sizes be modified in HW Config without stopping the CPU?

No. The local data stack partition table is an operating system kernel configuration that can only be restructured during a CPU STOP and warm restart.

What happens if local data stack capacity is exceeded in runtime?

The CPU attempts to call OB85 or OB121 (Programming Error). If the error OBs are missing or lack stack space themselves, the CPU immediately enters STOP mode to prevent memory corruption.

Why does the compiler add bytes for OB121 and OB122 to the total?

The operating system requires guaranteed stack headroom to execute asynchronous error handling routines if a peripheral addressing fault or block parameter error occurs during task execution.

Where do I view the current local data allocation in HW Config?

In HW Config, double-click the CPU -> navigate to the Memory tab -> click the Local Data button to view byte allocations per priority class.

Technical References

Related Articles

Related Tags

  • Local-Data-Stack
  • L-Stack
  • OB34
  • Priority-Class-11
  • CPU-Memory
  • CFC-Compiler
8 respuestas