Hermes OSIndustrial Intelligence Platform
Back to the library

PLC

Structured Text (SCL)

High-level PLC language: control flow, data handling, and pitfalls.

PLC

Overview

Structured Text (SCL in Siemens dialect) is the IEC 61131-3 high-level language: typed variables, control flow, and arithmetic for the logic that ladder handles poorly.

Engineering purpose

Recipe handling, calculations, data structures, and state machines — implemented compactly and reviewably as code.

How it works

ST compiles into the same block model as ladder; CASE statements over named state constants build auditable state machines; loops execute fully within one scan, charging their cost to cycle time.

  • SCL suits calculations, data handling, and state machines; ladder remains clearer for discrete interlocks.
  • CASE-based state machines with named constants are auditable; nested IF chains are not.
  • Loops run within one scan — an unbounded WHILE can exceed cycle time and trip the watchdog.

Common faults

Unbounded WHILE loops tripping the watchdog; implicit INT/REAL conversions truncating silently; deeply nested IF chains hiding dead branches; array indices unchecked at runtime boundaries.

Diagnostic checks

  1. 1Check cycle-time load after adding loops or heavy string/array operations.
  2. 2Review implicit type conversions — mixed INT/REAL math silently truncates.
  3. 3Step through CASE state transitions online and confirm every state has a defined exit path.

Safety notes

Keep ST computation out of safety paths unless written in certified F-blocks; complex code in protective logic defeats validation.

Commissioning notes

Measure cycle-time impact of each heavy ST block under worst-case data; enable range checks during commissioning runs even if disabled later for performance.

Related concepts

IEC 61131-3, state machines, CASE/IF control flow, data types and conversion, cycle-time budget.

structured text · scl · st code · case statement · متن ساختاریافته · اس‌سی‌ال

Related engineering cases

  • S7-1200 BF after CPU swapSiemensPLC
  • S7-1500 cycle watchdog from SCL loopSiemensPLC
  • FX5 output flicker from double coilMitsubishiPLC

Related articles

When Hermes Brain uses this article

Cited for SCL/ST questions: loops affecting scan time, type-conversion surprises, and state-machine design in code.