ST

Structured Text (ST) is a high-level textual programming language for PLCs and industrial control systems based on the IEC 61131-3 standard. The language is syntactically similar to programming languages such as Pascal and Ada and is used for complex logic, mathematical calculations, data processing, algorithms and advanced process control within Industrial Automation and Process Automation.

In OT environments, ST is used for:

  • Complex process logic
  • PID control
  • Data processing
  • Motion control
  • Recipe management
  • Algorithmic control
  • Industrial AI integrations

ST is often combined with other IEC 61131-3 languages such as:

Where Ladder Logic is particularly strong in discrete logic and maintainability, ST excels at scalability, reusability and complex calculations.


⚙️ What is Structured Text

Structured Text is a textual programming language based on structured programming principles.

Characteristics:

Property Description
Text-based Source code
High abstraction Complex logic
IEC 61131-3 Industry standard
Modular Functions and blocks
Deterministic Real-time execution

Example:

IF Temperature > 80 THEN    Alarm := TRUE;END_IF;

ST supports:

  • IF statements
  • CASE constructs
  • Loops
  • Arrays
  • Structures
  • Functions
  • Function blocks

🧱 Structure of ST programs

An ST program consists of:

  • Variables
  • Programs
  • Functions
  • Function blocks
  • Logical instructions

Example structure:

VAR    Temperature : REAL;    Alarm : BOOL;END_VAR

The code is executed cyclically by the PLC runtime.


🔄 PLC scan cycle

Like other PLC languages, ST runs cyclically.

Typical scan:

Read inputs    ↓Execute ST code    ↓Write outputs    ↓New scan

Important parameters:

Parameter Typical value
Scan time 1-100 ms
Determinism High
Jitter Low

Real-time behaviour remains essential in industrial OT processes.


🧠 Programming constructs

IF statements

Conditional logic:

IF Pressure > 10 THEN    Valve := FALSE;END_IF;

CASE statements

Used for state machines:

CASE State OF    0:        Motor := FALSE;    1:        Motor := TRUE;END_CASE;

Widely used for:

  • Sequence control
  • Batch control
  • Process steps

Loops

For iterative processing:

FOR i := 1 TO 10 DO    Total := Total + Values[i];END_FOR;

Applications:

  • Data processing
  • Arrays
  • Buffer management
  • Statistical calculations

⚡ Data types

ST supports extensive data types.

Data type Description
BOOL Boolean
INT Integer
REAL Floating point
STRING Text
ARRAY Arrays
STRUCT Structures
TIME Time values

This makes ST far more powerful for complex data handling than classic ladder logic.


🏭 ST in industrial automation

ST is widely used in complex OT applications.

Process industry

For:

  • PID control
  • Process models
  • Batch control
  • Recipe management

Motion control

For:

  • Kinematics
  • Trajectory calculations
  • Speed profiles
  • Robot control

Power supply

For:

  • Energy optimisation
  • Load calculations
  • Turbine control

Industrial data analysis

For:

  • Trending
  • Statistical analyses
  • Predictive maintenance
  • Edge analytics

🎛️ PID control in ST

Complex control engineering is often written in ST.

Example:

Error := Setpoint - ProcessValue;Output := Kp * Error;

ST supports:

  • Floating-point calculations
  • Advanced filtering
  • Adaptive control
  • MPC algorithms

Applications:

  • Chemical processes
  • Power plants
  • HVAC
  • Water treatment

🔌 Integration with field devices

ST processes signals from:

Communication via:


📡 Integration with SCADA and MES

ST code provides data to:

Examples:

Data Use
KPIs MES
Process values Historian
Alarm status SCADA
Predictive data AI models

🔄 ST versus Ladder Logic

Property ST Ladder Logic
Complex calculations Excellent Limited
Maintenance readability Lower High
Scalability High Limited
Data processing Strong Weaker
Process algorithms Very strong Less suitable
Visual debugging Less strong Very strong

Many modern projects combine both languages.


🧠 Modular software architecture

ST supports reusable software components.

Examples:

  • Function blocks
  • Libraries
  • Object-like structures
  • State machines

Benefits:

  • Faster engineering
  • Reusability
  • Better maintainability
  • Scalability

⚡ Performance and real-time behaviour

Complex ST code affects PLC performance.

Important factors:

  • CPU load
  • Cycle times
  • Floating-point calculations
  • Arrays
  • Communication load

Issues can lead to:

  • Long scan times
  • Higher Latency
  • Process instability
  • Missed events

Real-time optimisation remains essential.


🛡️ ST in safety systems

ST is also used in Safety PLC systems.

Applications:

  • Safety interlocks
  • Safe motion control
  • SIL logic
  • Shutdown systems

Important standards:

Standard Description
IEC 61508 Functional safety
IEC 61511 Process safety
ISO 13849 Machine safety
IEC 62061 Safety systems

Safety ST requires certified runtimes.


🧪 Diagnostics and troubleshooting

Benefits of ST:

  • Compact code
  • Powerful debugging
  • Good error handling

Challenges:

  • Less visual
  • More complex troubleshooting
  • More programming knowledge required

Common errors:

Problem Possible cause
Infinite loops Programming error
Overflow Wrong data type choice
Long scan time Complex calculations
Race conditions Poor state handling
Memory issues Large arrays

⚠️ Common design errors

No modular structure

Monolithic code becomes hard to maintain.


Poor naming

Unclear variables make troubleshooting difficult.


Excessive use of loops

Can negatively impact real-time performance.


No state management

Uncontrolled state machines cause instability.

Best practices:

  • Modular architecture
  • Clear naming conventions
  • Limited cyclic load
  • Standardised libraries

🔐 Cybersecurity risks

ST code is an important OT security target.

Attacks can:

  • Manipulate process values
  • Modify safety logic
  • Disrupt motion control
  • Sabotage production

Risks:

  • Unauthorised changes
  • Malware
  • Compromised engineering workstations
  • Insider threats

Known malware such as Stuxnet manipulated PLC code at low level.


🧱 Security measures

Important measures:

Measure Purpose
Network Segmentation Isolation
Application Whitelisting Software control
MFA Authentication
Version Control Change management
Logging Auditing
Patch Management Vulnerability reduction
Backup Recovery

ST projects usually fall under formal Change Management.


🌐 ST in Industry 4.0

In Industry 4.0, the importance of ST is growing strongly.

New applications:

  • AI integrations
  • Edge computing
  • Digital twins
  • Virtual PLCs
  • Cloud-based control

ST is suitable for modern software-based OT architectures.


📈 Benefits of ST

Key benefits:

  • Very powerful
  • Highly scalable
  • Excellent for complex logic
  • Suitable for algorithms
  • Strong data processing
  • Modular architectures

⚡ Limitations

Key limitations:

  • Less visual
  • Higher programming complexity
  • Less accessible to electrical engineers
  • More difficult real-time troubleshooting

For these reasons, ST is often combined with: