What is Structured Text?
Structured Text (ST) is a high-level, text-based programming language used to program PLCs (Programmable Logic Controllers).
Basic ST Syntax
In Structured Text (ST), each line of logic is written as a statement. Statements define what the PLC should do β such as setting values, evaluating conditions, or calling functions β and must follow a consistent format.
Variables and Assignment
Variable Naming
Arithmetic and Comparison Operators
Most logic eventually comes down to math: counting, scaling, comparing. This page covers the operators you'll use, the built-in math functions, and the rounding rules you need to know when integers and decimals meet.
Logical Operators
Logical operators combine or invert BOOL expressions that evaluate to 1 or 0. They are essential for writing expressive, multi-condition IF statements.
IF...THEN...ELSE Statements
The IF statement is the primary way to implement conditional logic in Structured Text. It allows the program to make decisions based on conditions that evaluate to 1 (taken) or 0 (not taken).
CASE Statements
CASE checks one numeric expression and runs the statements that match the first selector. It keeps branching tidy compared to a long IF...ELSIF chain.
Loop Statements
FORβ¦DOβ¦END_FOR;
Comments and Documentation
Comments are an essential part of writing maintainable, readable, and collaborative PLC programs. While Structured Text is readable compared to graphical languages, clear comments help explain why something is done β not just what is happening.
Instructions
4 items
Simple Examples and Patterns
This section provides simple, reusable logic patterns for common PLC programming tasks in Structured Text (ST).