IEC 61131-3 · Programmation
Le Texte Structuré est le langage IEC 61131-3 le plus puissant. Il ressemble à Pascal ou C et est idéal pour la logique complexe, les mathématiques et les algorithmes.
Watch the video first, then work through the interactive exercises below. Each section builds on the previous one.
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.
Both do the same thing — ST is more readable for complex logic.
En ST, chaque variable doit être déclarée avec un type. Les types les plus courants sont BOOL, INT, DINT, REAL, STRING et TIME.
VAR
vitesse_moteur : REAL := 0.0;
en_marche : BOOL := FALSE;
nb_cycles : DINT := 0;
END_VAR
Common Data Types
| Type | Size | Range / Example | Use case |
|---|---|---|---|
| BOOL | 1 bit | TRUE / FALSE | Digital signals, flags |
| INT | 16 bit | -32768 to 32767 | Counters, small values |
| DINT | 32 bit | ±2.1 billion | Large counters, positions |
| REAL | 32 bit | 3.14, -0.001 | Speeds, temperatures, ratios |
| STRING | variable | 'Conveyor A' | Labels, messages |
| TIME | 32 bit | T#500ms, T#2s | Timers, delays |
Déclarez une variable "temperature" de type REAL avec une valeur initiale de 20.0
La logique conditionnelle en ST suit une syntaxe claire et lisible. Terminez toujours votre bloc IF par END_IF.
IF capteur_ok AND vitesse > 0.0 THEN
sortie := TRUE;
ELSIF arret_urgence THEN
sortie := FALSE;
ELSE
sortie := dernier_etat;
END_IF;
↑ Live state machine — click a state to simulate the IF logic
Écrivez une instruction IF qui met "alarme" à TRUE si "temperature" dépasse 80.0
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?
Now that you understand ST fundamentals, here's where to go next: