Skip to content

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 lessonsComplete: every lesson is available now

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 image10 min
  3. 03Program structure: POUs, PROGRAM, FUNCTION and FUNCTION_BLOCK10 min
  4. 04Your first program: starting a pump with seal-in logic11 min

01Data and variables

  1. 05Data types: BOOL, INT, REAL, TIME and the rest11 min
  2. 06Declaring variables: VAR, VAR_INPUT and RETAIN11 min
  3. 07Literals and constants: 16#FF, 2#1010 and T#5s9 min
  4. 08Type conversion and scaling a 4-20 mA signal12 min

02Expressions and operators

  1. 09Assignment and arithmetic in ST: := and operator precedence10 min
  2. 10Boolean logic, comparisons and bit operations11 min
  3. 11Standard functions: ABS, SQRT, MIN, MAX, LIMIT, SEL, MUX11 min

03Control flow

  1. 12IF, ELSIF and ELSE: the rules and when to avoid them10 min
  2. 13The CASE statement and your first state machine12 min
  3. 14The FOR loop and the watchdog11 min
  4. 15WHILE, REPEAT, EXIT, CONTINUE and RETURN12 min

04Standard function blocks

  1. 16Edge detection: R_TRIG, F_TRIG and the "it fired every scan" bug10 min
  2. 17Timers: TON, TOF and TP12 min
  3. 18Counters: CTU, CTD and CTUD11 min
  4. 19SR and RS flip-flops: which one wins10 min

05Structured programs

  1. 20Writing your own function10 min
  2. 21Writing a function block13 min
  3. 22Arrays in Structured Text12 min
  4. 23Structs and enumerations11 min
  5. 24References and pointers10 min

06Industrial patterns

  1. 25The state machine pattern: a batch sequence that cannot get stuck13 min
  2. 26Alarm management to ISA-18.2: delay, deadband, latch, acknowledge, first-out14 min
  3. 27Analogue signal processing: counts to engineering units, NE43 and filtering14 min
  4. 28Closed-loop control in ST: hysteresis first, then a practical PID14 min
  5. 29Motors and valves in practice: permissives, feedback and travel time13 min

07From the lab to the plant

  1. 30The same ST on every platform: SCL, Studio 5000, CODESYS, TwinCAT14 min
  2. 31Testing and debugging ST: the watch table, forcing and simulation15 min
  3. 32An ST style guide: naming, comments, constants and version control13 min
  4. 33Final project: a complete tank station with a state machine and alarms16 min
  5. 3420 interview questions on ST and PLC programming, with answers15 min

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, on a virtual process that suits it, shown beside it as ladder. 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, and every lesson is available now.