S7-1200 Cycle Time Optimization: Modbus TCP Tuning Guide

David Krause12 min read
Best PracticesS7-1200Siemens
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

An S7-1212 CPU running 75 KB of work memory at 88% utilization can produce 40–50 ms OB1 scan times when five Modbus TCP (MB_CLIENT) connections drive Festo stepper motor controllers. Reducing active MB_CLIENT instances to a single motor drops the cycle time to 5–10 ms, but enlarging work memory to the 125 KB offered by an S7-1215 will not change scan time. This reference explains why memory size is not the bottleneck, how the Communication load parameter trades OB1 throughput against connection throughput, why optimized block access matters, and how to verify improvements with the diagnostic buffer and Trace functions.

Why Work Memory Size Does Not Affect Cycle Time

S7-1200 CPUs use a fixed work-memory architecture: the program code is compiled to MC7 and executed from a dedicated code memory region, and the data block image is stored in a separate data work memory. Both regions are sized by the CPU's silicon — they cannot be expanded by a firmware option, SD card, or SIMATIC memory card once the device is manufactured.

CPU Work Memory (Program) Work Memory (Data) Total Work Memory Load Memory
S7-1212 DC/DC/DC (6ES7212-1AE40-0XB0) 50 KB 25 KB 75 KB 2 MB internal + SIMATIC card
S7-1212 DC/DC/Rly (6ES7212-1BE40-0XB0) 50 KB 25 KB 75 KB 2 MB internal + SIMATIC card
S7-1215 DC/DC/DC (6ES7215-1AG40-0XB0) 100 KB 25 KB 125 KB 4 MB internal + SIMATIC card
S7-1215 DC/DC/Rly (6ES7215-1BG40-0XB0) 100 KB 25 KB 125 KB 4 MB internal + SIMATIC card

Because both the S7-1212 and S7-1215 share the same processor core, instruction-execution engine, and backplane architecture, the cycle time of OB1 depends on:

  1. The number and type of instructions executed per scan (ladder/FBD/ST/SCL/GRAPH).
  2. The volume of I/O and tag memory read/writes, including MB_CLIENT function block processing.
  3. Whether data blocks use optimized (symbolic, S7-1200/1500 style) or non-optimized (absolute, classic S7-300 style) access.
  4. Communication stack load and active connections.

Migrating a 75 KB program onto an S7-1215 frees approximately 50 KB of additional code and data work memory, but the instruction stream and active connections — and therefore scan time — remain identical. The correct intervention is not more memory, but a leaner instruction path and lower communication load.

Identifying the Bottleneck: MB_CLIENT Connection Cost

Each active MB_CLIENT instance in the user program reserves an internal connection resource, a TCP socket, and a request/response state machine. With five concurrent MB_CLIENT connections to Festo stepper controllers (typical configuration: CMMO-ST-C5-1-LKP or similar CMMS-ST/CMMO-ST family units), the OB1 cycle inflates roughly linearly with the number of in-flight transactions per scan.

Field observation from the source case:

Configuration OB1 Cycle Time Motor Smoothness
5 MB_CLIENT instances + related code 40–50 ms Jerky, missed setpoints
1 MB_CLIENT instance + minimal code 5–10 ms Smooth, no skipped setpoints

The 5–10× scan-time delta does not come from "5× more code". It comes from the communications scheduler: with five open sockets, the MB_CLIENT background task schedules multiple transmit/receive events per scan, and the user program must service five separate busy/done state machines. Reducing to one socket collapses the scheduling overhead.

Communication Load Parameter (S7-1200)

The Communication load is set in TIA Portal under:

  1. Project tree → Devices & Networks → select the S7-1200 CPU.
  2. Inspector window → PropertiesGeneralSystem and clock memory or, depending on TIA Portal version, Cycle time / Communication load.
  3. Locate the Communication load field (valid range 15 % – 50 %, default 15 %).

Internally the runtime reserves a percentage of the scan time for the communication stack:

Effective OB1 scan = Base scan × (1 / (1 − CommunicationLoad))

At the default 15 %, the user program is allotted 85 % of the effective scan; at 50 %, the user program gets only 50 %, and cycle time is allowed to lengthen as long as it keeps the communication budget satisfied. To accelerate OB1, lower the Communication load value (e.g., to 15 %).

Important: Communication load is a reservation, not a hard cap. The CPU will exceed the budget if the user program needs more time, and it will shorten the effective scan when communications are idle. Do not set it below 15 % — TIA Portal enforces the lower bound.

Optimized vs Non-Optimized Block Access

Optimized block access is the default for new data blocks in S7-1200/1500 projects and stores tags symbolically in a self-describing layout. Non-optimized (classic) access stores tags with fixed offsets and is required only when a third-party device or older code expects absolute addressing, or when you interface with an OPC server using the S7-300/400 memory model.

Aspect Optimized Access Non-Optimized Access
Tag addressing Symbolic only Absolute (e.g., DB1.DBD0) or symbolic
Memory layout Compiler packs for alignment, fills gaps automatically Fixed offset, no reordering
Read/write speed (typical) Faster — single MOV/LDR for entire tag Slower — bit/byte/word/dword boundaries cost extra instructions
Download to modified Yes (with possible value reset) No — full download required
OPC UA / S7-1500 symbolic Native Requires mapping

Converting DBs from non-optimized to optimized in the source program (right-click DB → Properties → Attributes → untick Optimized block access off / on) typically yields 5–15 % OB1 cycle improvement when the program reads many structured tag groups per scan.

Modbus TCP Polling Discipline for MB_CLIENT

MB_CLIENT is an asynchronous instruction: when REQ = TRUE, the request is enqueued and the block returns immediately with BUSY = TRUE. The next call with the same instance ID must wait for DONE or ERROR before issuing a new request. Common cycle-time pitfalls:

  1. Polling every scan. Triggering MB_CLIENT from OB1 with REQ unconditionally re-issues requests before the previous transaction completes. Use a slower trigger (e.g., a 50 ms cyclic interrupt OB33, or a self-resetting timer).
  2. Multiple instances per controller. Opening more than one MB_CLIENT per physical drive multiplies the request rate. Use a single instance and a multiplexer (read all registers in one PDU, parse into separate tags).
  3. Large PDU per request. A 125-register Modbus read (the Festo default max for many CMMS-ST/CMSO controllers) takes 1 round-trip; ten small 1-register reads take 10 round-trips. Consolidate.
  4. Unconnected sockets. When MB_CLIENT is disabled or the controller powers off, the connection half-closes until the next connect. Configure the connection watchdogs in the Festo controller and in the TIA Portal connection properties.

Recommended Polling Pattern

// Cyclic OB33 (50 ms) — slow polling for non-critical data
IF "poll_50ms_tick" THEN
    "poll_50ms_tick" := FALSE;
    IF NOT "mb_client_1".Busy AND NOT "mb_client_1".Error THEN
        "mb_client_1".REQ := TRUE;
    END_IF;
END_IF;

// OB1 — fast update for motion setpoint only, single register
IF "fast_setpoint_trigger" THEN
    "fast_setpoint_trigger" := FALSE;
    IF NOT "mb_client_motion".Busy AND NOT "mb_client_motion".Error THEN
        "mb_client_motion".REQ := TRUE;
    END_IF;
END_IF;

S7-1200 vs S7-1500: When Migration Is Justified

S7-1500 CPUs use a different execution engine, a faster backplane (PROFINET with IRT, dedicated isochronous bus), and an instruction set with hardware-assisted bit, byte, and floating-point operations. Typical step improvements over the S7-1215 of the same vintage:

CPU Class Bit Operation Word Operation Typical OB1 (comparable code)
S7-1212C / S7-1215C 0.08 µs 1.7 µs 40–50 ms (this case)
S7-1511-1 PN 0.06 µs 0.72 µs ~3–6 ms
S7-1513-1 PN 0.04 µs 0.45 µs ~2–4 ms
S7-1516-3 PN/DP 0.03 µs 0.32 µs ~1–2 ms

Before recommending a hardware change, rule out software-side wins. Migration is justified only when the application exceeds 75–125 KB work memory, requires isochronous mode for high-speed motion, or needs PROFINET IRT and 8+ motion axes. For five Festo steppers using only Modbus TCP and open-loop pulse direction, software optimization should reach 5–15 ms without a platform change.

Step-by-Step Optimization Procedure

  1. Capture the baseline. In TIA Portal: Online → Online & diagnosticsCycle time. Record OB1 min, max, and average over 30 seconds. Capture the diagnostic buffer entries for OB1 cycle overflow (event ID 0x1080 / 0x1581 range).
  2. Lower Communication load to 15 %. PLC properties → Communication load → enter 15 → download to PLC. Verify OB1 cycle change with the same measurement.
  3. Convert all DBs to optimized access. Right-click each DB → Properties → Attributes → enable Optimized block access. Recompile and download. If a third-party tool requires absolute addressing, split out a single non-optimized shadow DB for the interface tags only.
  4. Decouple MB_CLIENT polling from OB1. Move Modbus triggers to a cyclic interrupt OB (e.g., OB35 at 100 ms, or OB33 at 50 ms). Keep one fast-update MB_CLIENT in OB1 only for the active motion setpoint.
  5. Consolidate Modbus reads. Read all status and configuration registers in a single multi-register request per controller. Use the Festo controller's Group Read or arrange registers contiguously to fit in a single PDU.
  6. Audit the instruction mix. Replace nested string and array operations with direct tag references. Avoid calling MB_CLIENT inside a multi-instance DB whose call hierarchy reaches more than 2 levels — each F-block call adds overhead.
  7. Disable unused web server, OPC UA, and PG/OP connections. In PLC properties → Web server → uncheck Enable web server if not used. In OPC UA server, set session limits to the minimum.
  8. Re-measure. Confirm OB1 max under load. If the cycle time remains > 25 ms with five motors, profile each MB_CLIENT call's contribution using Trace (OB1 instruction timing, available in TIA Portal V17+ with S7-1500; for S7-1200 use a software counter toggled around each call and read via HMI).

Verification and Measurement

Metric How to Measure Target
OB1 current cycle time Online & diagnostics → Cycle time Min ≤ 5 ms, max ≤ 20 ms with 5 MB_CLIENTs
Communication load actual Same panel, Communication load utilized ≤ 20 % of scan
MB_CLIENT request latency Timestamp REQ edge and DONE edge, subtract in PLC < 50 ms p95
MB_CLIENT error rate Increment counter on ERROR = TRUE, HMI display < 0.1 % of transactions
Diagnostic buffer overflow Online & diagnostics → Diagnostic buffer No OB1 cycle overflow events

To confirm the trade-off the original poster noticed — faster cycle time but slower machine run time — add an HMI tag for "OB1 idle time" (the gap between OB1 end and the next start). A shorter OB1 with the same number of Modbus requests means the CPU spends the saved time servicing the comm scheduler, not running motion. The cure is not to slow OB1; it is to batch MB_CLIENT requests so each scan commits fewer transactions with more useful data per transaction.

Troubleshooting Matrix

Symptom Likely Cause Action
Cycle time increases 5× when 5 MB_CLIENTs are enabled Five sockets serviced per scan Decouple 4 MB_CLIENTs to cyclic interrupt OB; keep one in OB1
Cycle time still high after lower comm load Non-optimized DB access forcing extra instructions Convert all DBs to optimized block access
MB_CLIENT reports STATUS = 0x80C8 Connection timeout, Festo controller offline Check Festo controller IP, check TCP keep-alive, verify port 502
MB_CLIENT reports STATUS = 0x80C7 TCP connection actively refused Confirm Festo Modbus TCP server is enabled in Festo Configuration Tool (FCT)
OB1 cycle fluctuates 5–50 ms OB1 triggered by communication events Confirm OB1 priority 1 and OB33/OB35 priorities lower; verify cyclic OB intervals
Motor jerks despite low cycle time Modbus read latency dominates; OB1 idle is high but setpoint arrives late Switch motion setpoint to a single-register fast read on OB1; move status reads to 100 ms OB35
Work memory 88 % full on S7-1212 Large program, many FBs, multi-instance DBs Refactor to multi-instance FBs; remove unused libraries; consider S7-1215 only if the program exceeds 75 KB after refactor
Communication load setting rejected by TIA Portal Value out of 15–50 range Re-enter; values < 15 are clamped to 15

Edge Cases and Field-Proven Caveats

  • MB_CLIENT reuse across OBs. Calling the same MB_CLIENT instance from OB1 and OB33 simultaneously causes a watchdog fault in the runtime. Use one OB per instance, or implement a mutual-exclusion semaphore in your user code.
  • Setting Communication load to 15 % is not always the optimum. If your application has heavy passive communication (HMI polling, PG online functions, OPC DA/UA), the lower bound is fine. If you only have MB_CLIENT, 20–25 % sometimes yields a more deterministic worst-case scan.
  • Optimized DB download-to-modified. Switching a non-optimized DB to optimized and downloading "to modified" resets tag values. Plan a stop-and-restart or accept the value reset.
  • Festo controller timeout defaults. The CMMS-ST and CMMO-ST families default to a 3 s Modbus timeout. If OB1 is faster, the controller may interpret the burst of requests as a fault and drop the connection. Adjust the controller's inter-character timeout in FCT.
  • S7-1212C vs S7-1212 AC/DC/Rly. The work-memory size is identical; the relay variant only differs in onboard I/O. Memory is not a factor when comparing these.

Programming Style Resources

Siemens publishes the "SIMATIC S7-1200/1500 Programming Guideline" and the "S7-1200/1500 Styleguide for TIA Portal" in the Siemens Online Support portal. These documents cover block sizing, optimized access, naming conventions, and the recommended approach for cyclic interrupts vs OB1. When troubleshooting cycle time, start with the Styleguide checklist before measuring or recoding.

Does moving from an S7-1212 to an S7-1215 reduce cycle time?

No. Both CPUs share the same execution engine and instruction-per-bit timing. The S7-1215 only offers more work memory (125 KB vs 75 KB) and load memory (4 MB vs 2 MB); the scan time of a given program is unchanged. Reduce OB1 time by lowering Communication load, converting DBs to optimized access, and decoupling Modbus polling from OB1.

What Communication load value should I set on an S7-1200?

Valid range is 15 % to 50 %; default is 15 %. To accelerate OB1, set 15 % if your application does not need large communication time slices. Verify with Online & diagnostics → Cycle time that OB1 max improves and the diagnostic buffer has no OB1 overflow events.

Why is my OB1 faster but my machine run time slower after optimization?

Faster OB1 frees time for the communication scheduler to service more Modbus requests, which means the motion setpoint poll may still be queued behind housekeeping reads. Move non-motion Modbus reads to a 50–100 ms cyclic interrupt OB (OB33/OB35) and keep the motion setpoint read on OB1.

How many MB_CLIENT instances can an S7-1200 handle?

An S7-1212/S7-1215 supports up to 8 active Open User Communication connections, but only 4 can be Modbus TCP. Performance, not the connection limit, is the constraint; 4–5 active MB_CLIENTs per scan is the practical ceiling before OB1 is dominated by communication.

Should I migrate to S7-1500 to solve cycle-time issues?

Only after exhausting software optimizations: Communication load tuning, optimized block access, OB decoupling, and Modbus PDU consolidation. S7-1500 (1511 or higher) is justified when work memory exceeds 125 KB, when isochronous mode is required, or when PROFINET IRT is needed for synchronized drives.

Back to blog