PLCcheck

Optimizing PLC Scan Time: Practical Techniques

Practical techniques for reducing PLC cycle time. Covers code structure, conditional execution, data type selection, optimized data blocks, and interrupt-based architecture.

·10 min read
PLCscan timecycle timeoptimizationperformanceS7-1500SCLAWLoptimized data blocks

Diesen Artikel auf Deutsch lesen

Optimizing PLC Scan Time: Practical Techniques

The cycle time (scan time) is how long the CPU needs to execute the complete user program once. Typical industrial PLCs run between 1 and 100 ms. When cycle time is too long, the PLC misses fast signals, response times increase, and in the worst case the CPU triggers a time error (OB 80) or goes to STOP. This guide covers practical techniques to reduce cycle time.

Understanding What Affects Cycle Time

The cycle time consists of:

  1. Process image update (reading inputs, writing outputs) — typically 1–5 ms depending on I/O count
  2. User program execution — the main variable, depends on code size and complexity
  3. Communication processing — HMI, PROFINET, OPC UA — can consume significant time
  4. System tasks — diagnostics, internal housekeeping

You can only directly optimize #2 (and indirectly influence #3).

Technique 1: Conditional Execution (Biggest Impact)

Not all code needs to run every cycle. Code that only runs when specific conditions are met can be skipped entirely:

AWL:

U  M 100.0          // Production mode active?
SPBN =SKIP_PROD     // If not → skip entire production block
SPA PB 10           // Call production program
SKIP_PROD: NOP 0

SCL:

IF #Production_Mode THEN
    "Production_Program"();
END_IF;

Impact: Skipping unused code sections reduces average scan time by 20–40% in programs with multiple operating modes (manual, automatic, setup, cleaning).

Technique 2: Use Optimized Data Blocks (S7-1500)

On S7-1500, optimized data blocks (the default) provide significantly faster access than standard data blocks:

Typical improvement: 10–30% faster DB access on S7-1500 with optimized blocks.

How to verify: Check DB properties → Attributes → "Optimized block access" checkbox should be enabled. If your migrated program uses absolute DB addressing (DBW0, DBD4), you must convert to symbolic access first.

Technique 3: Choose the Right Programming Language

SCL and KOP/FUP are compiled natively on S7-1500. AWL runs in emulation mode with overhead.

LanguageS7-1500 PerformanceWhen to Use
SCLNative, fastCalculations, data processing, algorithms
KOP/LADNative, fastBit logic, simple control
FUP/FBDNative, fastLogic gates, process control
AWL/STLEmulation, 10–30% slowerLegacy compatibility only

Practical impact: Converting AWL blocks to SCL can reduce their execution time by 10–30% on S7-1500.

Technique 4: Move Time-Critical Code to Cyclic Interrupts

Instead of making OB1 faster, move time-critical code to a cyclic interrupt OB (OB30–OB38):

Typical use: PID control loops, high-speed counting, motion control, safety-relevant timing.

Technique 5: Reduce Communication Load

Communication with HMI, SCADA, and other PLCs consumes cycle time:

Technique 6: Avoid Unnecessary Operations

Wasteful PatternBetter Alternative
Reading the same input 10 times in different blocksRead once into a temp variable, use temp everywhere
String operations in OB1Move to a slower cyclic interrupt (OB32, 1s cycle)
Unused blocks still being calledRemove or skip calls with conditional execution
FOR loops with large iteration counts in OB1Distribute across multiple cycles

How to Measure Cycle Time

In STEP 7 Classic: CPU diagnostics → Cycle time (shows min/max/current)

In TIA Portal: Online & Diagnostics → Cycle time → Shows minimum, maximum, and current cycle time

In the program: Read system clock with SFC 64 "TIME_TCK" at the start and end of OB1. Difference = user program execution time.

Warning thresholds:

Frequently Asked Questions

What cycle time does my application need?

Rule of thumb: The cycle time should be less than half the shortest signal duration you need to detect. If your fastest sensor produces 50 ms pulses, your cycle time should be under 25 ms. For safety-critical applications, follow the specific SIL/PL requirements.

Can I set a fixed cycle time?

Yes. In TIA Portal: CPU properties → Cycle → Minimum cycle time. The CPU waits until the minimum time before starting the next cycle. This creates deterministic behavior but does not help if the actual execution time already exceeds the target.


Maintained by PLCcheck.ai. Last update: March 2026. Not affiliated with Siemens AG.

Related Articles

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.