IEC 61131-3 · free · Arabic & English

The complete Structured Text (ST) course

Learn Structured Text step by step: from the scan cycle and data types to timers, state machines and PID, with a program in every lesson that you run in the lab.

34 lessons1 out nowA new lesson every day at 12:00 UTC

Start lesson 1

What is Structured Text?

Structured Text (ST) is one of the PLC programming languages defined by the international standard IEC 61131-3. It reads like Pascal, with expressions, IF, CASE and loops, but it runs inside the PLC scan cycle. Siemens calls it SCL, and CODESYS, Rockwell, Beckhoff, Schneider, Omron and Mitsubishi all support it.

Course outline

00Getting started

  1. 01What is Structured Text, and when to use it instead of ladder9 min
  2. 02How a PLC runs your code: the scan cycle and the process imageOut 6 October
  3. 03Program structure: POUs, PROGRAM, FUNCTION and FUNCTION_BLOCKOut 7 October
  4. 04Your first program: starting a pump with seal-in logicOut 8 October

01Data and variables

  1. 05Data types: BOOL, INT, REAL, TIME and the restOut 9 October
  2. 06Declaring variables: VAR, VAR_INPUT and RETAINOut 10 October
  3. 07Literals and constants: 16#FF, 2#1010 and T#5sOut 11 October
  4. 08Type conversion and scaling a 4-20 mA signalOut 12 October

02Expressions and operators

  1. 09Assignment and arithmetic in ST: := and operator precedenceOut 13 October
  2. 10Boolean logic, comparisons and bit operationsOut 14 October
  3. 11Standard functions: ABS, SQRT, MIN, MAX, LIMIT, SEL, MUXOut 15 October

03Control flow

  1. 12IF, ELSIF and ELSE: the rules and when to avoid themOut 16 October
  2. 13The CASE statement and your first state machineOut 17 October
  3. 14The FOR loop and the watchdogOut 18 October
  4. 15WHILE, REPEAT, EXIT, CONTINUE and RETURNOut 19 October

04Standard function blocks

  1. 16Edge detection: R_TRIG, F_TRIG and the "it fired every scan" bugOut 20 October
  2. 17Timers: TON, TOF and TPOut 21 October
  3. 18Counters: CTU, CTD and CTUDOut 22 October
  4. 19SR and RS flip-flops: which one winsOut 23 October

05Structured programs

  1. 20Writing your own functionOut 24 October
  2. 21Writing a function blockOut 25 October
  3. 22Arrays in Structured TextOut 26 October
  4. 23Structs and enumerationsOut 27 October
  5. 24References and pointersOut 28 October

06Industrial patterns

  1. 25The state machine pattern: a batch sequence that cannot get stuckOut 29 October
  2. 26Alarm management to ISA-18.2: delay, deadband, latch, acknowledge, first-outOut 30 October
  3. 27Analogue signal processing: counts to engineering units, NE43 and filteringOut 31 October
  4. 28Closed-loop control in ST: hysteresis first, then a practical PIDOut 1 November
  5. 29Motors and valves in practice: permissives, feedback and travel timeOut 2 November

07From the lab to the plant

  1. 30The same ST on every platform: SCL, Studio 5000, CODESYS, TwinCATOut 3 November
  2. 31Testing and debugging ST: the watch table, forcing and simulationOut 4 November
  3. 32An ST style guide: naming, comments, constants and version controlOut 5 November
  4. 33Final project: a complete tank station with a state machine and alarmsOut 6 November
  5. 3420 interview questions on ST and PLC programming, with answersOut 7 November

Structured Text terms

Every term in the course, each on a short glossary page.

Structured Text FAQ

What is Structured Text in PLC programming?

Structured Text (ST) is a high-level text language from IEC 61131-3 for programming PLCs. You write lines such as Pump := Start AND NOT Stop; instead of drawing rungs as in ladder logic.

Is Structured Text the same as Siemens SCL?

Almost. SCL is Siemens' name for ST in TIA Portal and STEP 7, with small differences such as the # before local variables and block names like TON_TIME.

Do I need a real PLC to learn Structured Text?

No. Every lesson in this course has a program you run in the ST lab on this site, against a virtual tank with a pump and a valve. Later you can use the free CODESYS IDE or Siemens PLCSIM.

Structured Text or ladder logic: which is better?

Ladder is clearer for simple interlocks and for maintenance technicians; Structured Text is better for maths, loops, state machines and data handling. Most modern projects use both.

Is the course free?

Yes. The whole course is free, in Arabic and English, and the lab runs in the browser with no sign-up.

How long is the course?

34 lessons, each 8 to 15 minutes of reading plus a lab experiment. A new lesson is published every day.