Explainer
S7-1200 ladder program size limit: what actually constrains it
Short answer
An S7-1200 has no ladder line limit: STEP 7 compiles networks into blocks, so the ceiling is the compiled size of each block, the CPU's permitted block count — on S7-1500 a combined DB+FC+FB total — and the CPU's work and load memory. Count your blocks, compile, and compare against that exact CPU's technical data; the language you chose changes none of these limits.

On this page
An S7-1200 has no ladder line limit: STEP 7 never counts networks, and neither does the CPU. Ladder is a drawing for people; the compiler turns every block into executable code, and the code is what the controller stores and runs. What actually caps a program is the compiled size of each block, the number of blocks that CPU is permitted to hold — on the S7-1500 a combined DB+FC+FB total — and the CPU's work and load memory. None of these moves with the programming language. This article names each limit, shows how to measure a program against it, and works one example through to a CPU decision.
Why no line limit exists #
A ladder network is a grouping the editor draws; the CPU never stores it as a line. A normally open contact, a move instruction, a floating-point division and a string compare each compile to different amounts of code, so two networks that look equally wide can differ in compiled size by an order of magnitude. One dense math network can outweigh a screen of simple rungs. Because the controller enforces limits on compiled blocks and memory, a maximum line count is not a specification any S7 CPU publishes — the question has no number to give, and the compiled block is the unit that does.
The limits the CPU enforces #
Four block types make up a program: the organization block (OB) the CPU calls each cycle or on an event, the function (FC) that runs without memory of its own, the function block (FB) that keeps state in an instance DB, and the data block (DB) that stores data. A global DB is open to any OB, FC or FB in the program; an FB called with its own instance gets a DB of its own.
Per-block compiled size #
Every block compiles to a size, and the CPU refuses any single block that exceeds the per-block allowance that applies to it. You do not estimate this from the drawing: compile, then read the size STEP 7 reports for the block. The compiler polices a minimum too — an OB1 interface under 20 bytes triggers a size message of its own.
Permitted block count #
Count blocks as well as bytes. Every FB instance adds a DB, every recipe or alarm store adds a global DB, and the total must stay inside the CPU's allowance. The counting rule is per family and per CPU: S7-1500 technical data states a combined total for DB+FC+FB — around 200 blocks on a smaller F-CPU such as the CPU 1512-F — and the figure for any other CPU comes from that CPU's own technical data.
Work memory and load memory #
Load memory is the non-volatile storage holding the user program, its data and the configuration; every S7-1200 CPU carries internal load memory sized by that CPU, and a memory card extends it. Work memory is the volatile storage the CPU executes from, holding code and data during the run. A program has to fit both: the download against load memory, the executing code and data against work memory, and the two numbers are independent — more storage does not add execution room. This is the same per-CPU discipline as CPU 1214C expansion limits, where module and PROFINET device allowances belong to that exact CPU rather than to the family.
Measure, don't estimate #
Build the program — or its heaviest representative section, with the real instruction mix, interfaces, retained data and DB structures — compile it for the exact CPU, and read the results. STEP 7 shows each block's size when you right-click it in the project navigation, Main [OB1] for example, and open Properties.... Add the compiled code and data totals and set them against the CPU's work memory; set the whole download against load memory. A network count, a line count or a feeling about rung density is not a measurement; the compile log is.
Worked example: 74 blocks against an S7-1500 F-CPU #
Take an example packaging-station program with one cyclic OB and this inventory:
- 1 OB:
Main [OB1] - 14 FCs: station sequences and conversions
- 22 FBs — drive control, dosing loops, retry logic — each called once, so each generates one instance DB
- 16 global DBs: recipes, alarms, setpoints
Block arithmetic: the DBs are 22 + 16 = 38, so the combined DB+FC+FB count is 38 + 14 + 22 = 74. The CPU 1512-F publishes a combined allowance of around 200 blocks, so 74 fits with about 126 block slots of headroom.
Memory arithmetic, with example compile results: say the compile log reports 480 KB of code and 210 KB of data, so the executing program needs 480 + 210 = 690 KB of work memory. The decision: the block count passes, and the CPU choice then rides on memory — a CPU whose work memory is under 690 KB is excluded even though the block total fits, and the download must also fit load memory. Re-run the same two checks with your own compile log before you fix the CPU.
Language choice does not move the limits #
Ladder, FBD and SCL all compile into the same block code — the CPU never sees the editor. Equivalent logic in two languages can compile to slightly different sizes, so the editor can move a margin by a few percent, but no language raises a block allowance or adds work memory. Pick the language per task — readability, data handling, who maintains it — not for capacity; which IEC 61131-3 PLC language to use for each control task sorts that choice by task type.
When a limit stops the compile #
Fix the resource that actually failed:
- One block over its size allowance: split it along equipment or calculation boundaries into FCs and FBs with explicit interfaces, and preserve the execution order and state handling. A split cures the per-block problem, not total memory — the new interfaces and calls can add a little.
- Combined block count exceeded: merge single-use FCs and embed helper FBs as multi-instances, so their data lives inside the calling FB's instance DB instead of in a separate DB — the pattern used in multi-instance Modbus blocks and MB_DB links in an S7-1200.
- Work memory short: cut duplicated logic and oversized data first; if the totals still fail, the CPU is the constraint — select one with more resources and recompile.
If the program runs on an F-CPU, leave the safety blocks out of any splitting or merging: restructure standard logic only and keep the validated safety function intact.
Size and run time are separate checks #
Fitting in memory does not prove the machine runs: scan time depends on the instructions actually executed, active branches, communication load and interrupts, not on stored rungs. Prove timing with the machine at full load, not idle. The timing half of a CPU decision is its own calculation — how to size an S7-400 CPU against a PLC-5/40 scan time shows that side for a migration.
The decision #
Ignore line counts; they are not a specification. For any S7-1200 or S7-1500 project: compile, count DB+FC+FB against the CPU's allowance, set compiled code and data against work memory and the download against load memory, then fix the failed resource — split an oversized block, merge or multi-instance to cut the count, trim data, or move to a bigger CPU — and prove scan time at full load.
Questions asked
Can a memory card add work memory to an S7-1200?
No. The card extends load memory, the non-volatile storage for the program, its data and the configuration. Work memory is built into the CPU and cannot be extended, so a program that exceeds it will not execute even though the card stores it. When the work-memory check fails, the fix is a CPU with more work memory, not a bigger card.
Do the same limits apply to S7-300 and S7-400 programs?
Yes in kind, no in figures. No S7 CPU has a ladder line limit; the constraints are compiled block sizes, permitted block counts and program memory as published in each CPU's technical data. The counting rules differ by family — the S7-1500 combines DB+FC+FB into one total — so read the allowance from the specific CPU you are fitting, not from a sibling model.
What happens when the program fits but the machine cycles too slowly?
The CPU checks each cycle against its cycle monitoring time; an overrun raises a time fault, and if it repeats the CPU can drop to STOP. Because scan time follows executed instructions, active I/O and communication rather than stored rungs, prove it with the line at full production and adjust the monitoring time only after you know the real cycle.


