IEC 61131-3 · Programmierung

Strukturierter Text (ST) Programmierung

Strukturierter Text ist die leistungsfähigste IEC 61131-3-Sprache. Sie liest sich wie Pascal oder C und ist ideal für komplexe Logik, Mathematik und Algorithmen.

1

📺 Video Lesson

Watch the video first, then work through the interactive exercises below. Each section builds on the previous one.

⚡ Why Structured Text?

ST is one of five languages defined in IEC 61131-3. Unlike Ladder Logic (graphical) or Instruction List (assembly-like), ST is a high-level textual language — making it ideal for complex calculations, state machines, and reusable function blocks.

LADDER LOGIC

I1 Q1 Sensor_OK Motor_Run

STRUCTURED TEXT

IF Sensor_OK AND NOT E_Stop THEN
  Motor_Run := TRUE;
END_IF;

Both do the same thing — ST is more readable for complex logic.

Variablen & Datentypen

In ST muss jede Variable mit einem Typ deklariert werden. Die häufigsten Typen sind BOOL, INT, DINT, REAL, STRING und TIME.

Structured Text
VAR
  motor_drehzahl : REAL := 0.0;
  laeuft         : BOOL := FALSE;
  zyklus_zaehler : DINT := 0;
END_VAR

Common Data Types

TypeSizeRange / ExampleUse case
BOOL1 bitTRUE / FALSEDigital signals, flags
INT16 bit-32768 to 32767Counters, small values
DINT32 bit±2.1 billionLarge counters, positions
REAL32 bit3.14, -0.001Speeds, temperatures, ratios
STRINGvariable'Conveyor A'Labels, messages
TIME32 bitT#500ms, T#2sTimers, delays
Exercise 1

Deklarieren Sie eine Variable "temperatur" vom Typ REAL mit einem Anfangswert von 20.0

Verwenden Sie den VAR...END_VAR-Block mit dem :=-Operator für die Initialisierung.

🎯 Quick Quiz

Test your knowledge before moving on.

Q1. What keyword ends an IF block in ST?

Q2. Which data type would you use for a motor speed of 1450.5 RPM?

Q3. What does the := operator do in ST?