ποΈ 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
ποΈ Basic Data Types
BOOL Type
ποΈ Arithmetic and Comparison Operators
Arithmetic Operators
ποΈ 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 TRUE or FALSE.
ποΈ Logical Operators
Logical (Boolean) operators are used to combine or invert conditions that evaluate to TRUE or FALSE. Theyβre essential for writing expressive, multi-condition IF statements.
ποΈ 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.
ποΈ CASE Statements
The CASE statement is used when a variable or expression can have multiple discrete values and you want to execute different logic depending on each value. It's similar to switch statements in other languages.
ποΈ Simple Examples and Patterns
This section provides simple, reusable logic patterns for common PLC programming tasks in Structured Text (ST).