Structured Text (ST) is the IEC 61131-3 text language supported by Automation Builder. Assignments use :=, every statement ends with a semicolon, decisions use IF … THEN … ELSIF … END_IF and CASE … OF … END_CASE, and timer instances are called like functions: T_Warn(IN := Start_Req, PT := T#3s). ST suits calculations, sequences and reusable function blocks; ladder suits simple interlocks that maintenance staff read online.
- Use := for assignment and = for comparison
- Call each timer/counter instance once per scan, then read its outputs
- CASE on an integer step is the cleanest way to write sequences
- Package reusable logic as an ST function block and call it from ladder
You already wrote small ST snippets in earlier labs. This lab makes them systematic so you can choose the right language for each POU. For a deeper course, see Softwell's SCL/ST programming training.
Step 1: ST Syntax You Need
| Construct | ST | Notes |
|---|---|---|
| Assignment | DO_Lamp := TRUE; | Semicolon ends every statement |
| Boolean logic | A := B AND NOT C OR D; | AND binds stronger than OR; use brackets |
| Comparison | IF Step = 30 THEN | = compares, := assigns |
| IF | IF … THEN … ELSIF … ELSE … END_IF; | First true branch only |
| CASE | CASE Step OF 10: …; 20: …; END_CASE; | Integer selector |
| FOR | FOR i := 0 TO 7 DO … END_FOR; | Keep loops short in a cyclic task |
| Timer call | T1(IN := X, PT := T#2s); | Then use T1.Q / T1.ET |
| Comment | (* comment *) | Also // in V3 editors |
Step 2: Convert Ladder to ST
| Ladder rung | Structured Text |
|---|---|
| Start/stop seal-in (Lab 7) | DO_Motor_Run := (DI_Start_PB OR DO_Motor_Run) AND DI_Stop_PB AND DI_EStop_OK; |
| SET / RESET alarm (Lab 13) | IF NOT DI_MPCB_OK THEN Alm_MPCB := TRUE; END_IF; |
| TON warning (Lab 11) | T_Warn(IN := Start_Req, PT := T#3s); |
| Interlocked jog (Lab 16) | DO_Motor_Rev := Manual AND DI_Jog_Rev_PB AND NOT DI_Jog_Fwd_PB AND NOT DO_Motor_Run; |
ST execution demo
This simulator runs the ST below each 100 ms scan. Press Start, wait for the warning, then press Stop.
Start_Req := (DI_Start_PB OR Start_Req) AND DI_Stop_PB AND DI_EStop_OK;
T_Warn(IN := Start_Req, PT := T#3s);
DO_Buzzer := Start_Req AND NOT T_Warn.Q;
DO_Motor_Run := T_Warn.Q;Step 3: Build a Reusable Motor Function Block in ST
FUNCTION_BLOCK FB_Motor
VAR_INPUT
Start, Stop_OK, Permissive, Feedback, Reset : BOOL;
FB_Time : TIME := T#2s;
END_VAR
VAR_OUTPUT
Run, Fault : BOOL;
END_VAR
VAR
T_FB : TON;
END_VAR
Run := (Start OR Run) AND Stop_OK AND Permissive AND NOT Fault;
T_FB(IN := Run AND NOT Feedback, PT := FB_Time);
IF T_FB.Q THEN Fault := TRUE; END_IF;
IF Reset AND NOT T_FB.Q THEN Fault := FALSE; END_IF;- Add a POU of type Function Block, language ST, name
FB_Motor, and paste the code. - Declare an instance in Motor_Logic:
M1 : FB_Motor; - In a ladder network, insert the block
M1, connect inputs to your tags andRuntoCmd_Motor_Run. - Add a second conveyor later with
M2 : FB_Motor;: same tested logic, one more line.
Step 4: Choose the Right Language
| Task | Best choice | Why |
|---|---|---|
| Interlocks, E-stop monitoring, simple outputs | Ladder | Maintenance reads it online at a glance |
| Sequences with many steps | ST (CASE) or SFC | Compact, easy to extend |
| Scaling, maths, data handling, loops | ST | Ladder becomes huge |
| Reusable device logic | ST function block called from LD | Best of both |
| Communication blocks (Modbus) | ST or FBD | Many parameters |
Practice Exercise
Rewrite the Lab 14 tower lamp logic in ST in a POU called Tower_Lamp_ST. Run it alongside the ladder version with different output tags and prove both give the same result.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Syntax error: expected ; | Missing semicolon or END_IF | Check the line above the error |
| Assignment does nothing | Used = instead of := | Use := for assignment |
| Timer never runs | Instance not called every scan | Call the instance unconditionally, then read Q |
| Logic works in LD, not in ST | Operator precedence | Add brackets around OR terms |
Frequently asked questions
Does ABB Automation Builder support Structured Text?
Yes. ST is one of the IEC 61131-3 languages supported for AC500 and AC500-eco, alongside LD, FBD, IL, SFC and CFC.
Is SCL the same as Structured Text?
SCL is Siemens' name for its IEC 61131-3 ST implementation. The syntax is very close, so skills transfer between ABB and Siemens.
Can I mix ladder and ST in one project?
Yes. Each POU has its own language, and a ladder network can call a function block written in ST.
Should beginners learn ladder or ST first?
Ladder first for basic I/O logic, then ST for sequences, calculations and reusable blocks.