What is Structured Text?
Structured Text (ST) is a high-level text-based PLC language similar to Pascal or C. Learn the basics and run ST programs in the rungs.dev browser-based simulator.
Structured Text (ST) is a high-level, text-based programming language used to program PLCs (Programmable Logic Controllers).
Unlike visual languages like Ladder Logic (LD), ST resembles traditional programming languages such as Pascal, C, or Python. It’s ideal for engineers and developers who prefer code over diagrams and need to implement complex control logic, calculations, or data handling.
ST vs Ladder Logic
While both Structured Text (ST) and Ladder Logic (LD) are widely used in PLC programming, they differ significantly in approach and style:
| Feature | Structured Text (ST) | Ladder Logic (LD) |
|---|---|---|
| Style | Text/code-based | Graphical/rung-based |
| Best for | Math, loops, conditional logic | Simple sequences, relay-style logic |
| Scalability | Highly scalable for complex systems | Becomes hard to maintain at large scale |
| Debugging | Easier for programmers | Easier for technicians |
When to Use ST
You should consider using Structured Text when:
-
Your logic involves mathematical operations.
-
You need looping structures, like iterating through arrays or conditions.
-
Your program contains complex conditional logic (nested IF/ELSE, CASE statements).
-
You're integrating with external data sources or performing data transformations.
-
You or your team have software engineering experience.
ST may not be ideal if:
-
Your team is composed of technicians or electricians more comfortable with visual logic.
-
You’re working on a small system with simple I/O logic that fits cleanly into a few rungs.
Advantages of ST
Structured Text shines in situations where Ladder Logic becomes unwieldy. Here are some of its key advantages:
-
Complex Math: ST handles floating-point operations, trigonometry, and signal processing with ease.
-
Control Structures: IF, THEN, CASE, WHILE, and REPEAT allow for compact and readable logic.
-
Modularity: Functions and function blocks make it easy to reuse and organize code.
-
Maintainability: Easier to document, version-control, and scale for large projects.
In summary, Structured Text is the right choice for developers who want to express logic clearly, efficiently, and at scale — especially when projects outgrow what’s practical in Ladder Logic.
Practice
Write your first ST program in the Lamp Follow exercise — drive a lamp straight from a button input.
Logical & Bit Instructions
Reference for Ladder Logic bit instructions in rungs.dev — AND, OR, XOR, NOT, CLR, and BTD — combining, flipping, clearing, and relocating the individual bits of a DINT word.
Basic ST Syntax
Statement structure, semicolons, expressions, and basic syntax rules for Structured Text in rungs.dev — the foundation every ST program in the simulator follows.