Structured Text in RSLogix 5000 – Complete PLC Programming Guide

Published on Aug 19, 2025 | Category: Introduction

Share this Page:

Structured Text, often called ST, is one of the main programming languages used in RSLogix 5000 for Allen-Bradley PLCs. Unlike ladder logic, which uses graphical rungs, structured text lets you write code in a more traditional, text-based format. It’s designed for situations where complex calculations, decision-making, or repetitive tasks are easier to handle with written logic rather than long ladder diagrams.

Think about a production line where several sensors and motors need to work together in a specific sequence. Instead of building a huge ladder program, engineers can use structured text to write compact code that checks sensor inputs, starts or stops motors, and even performs calculations like cycle counts or production speed. This makes troubleshooting and scaling much simpler in real-world automation systems.

On this page, you’ll learn the essentials of structured text in RSLogix 5000 — from understanding its syntax and data types to writing IF statements, loops, timers, and counters. By the end, you’ll know not only how structured text works, but also how to apply it effectively in your PLC programs for cleaner, smarter, and more reliable automation.

What is Structured Text in RSLogix 5000 PLC Programming?

Structured Text, often shortened to ST, is a high-level programming language used in RSLogix 5000 for Allen-Bradley PLCs. Unlike ladder logic, which relies on graphical rungs and symbols, structured text is written entirely in lines of code. It uses statements, expressions, and instructions in a format that feels familiar if you’ve ever worked with languages like C, Pascal, or Visual Basic.

Because of its text-based nature, Structured Text is especially useful for complex tasks such as mathematical calculations, nested conditional logic, and repetitive operations with loops. Instead of building large and complicated ladder diagrams, you can write compact and readable code that executes the same functions more efficiently.

In short, Structured Text gives PLC programmers a powerful, flexible way to create automation routines that go beyond the limitations of graphical programming. It bridges the gap between traditional coding and industrial control, making it easier to implement advanced logic inside RSLogix 5000.

img/rslogix5000-st/how-to-add-structured-text-in-rslogix5000.webp

How to Make a Program in Structured Text in RSLogix 5000 / Studio 5000

Structured Text (ST) in RSLogix 5000 or Studio 5000 allows you to simplify complex logic and write it as clean, readable code. Instead of building large ladder diagrams, you can create routines in a text-based format similar to languages like C or Visual Basic. This makes your PLC program easier to organize, maintain, and scale.

To create and use a Structured Text routine in Allen-Bradley controllers, follow these steps:

Once the routine is linked, you can begin writing Structured Text instructions using statements such as IF, FOR, and WHILE. This approach reduces programming complexity, makes your logic easier to follow, and provides more flexibility for calculations, decision-making, and repetitive operations compared to ladder logic.

RSLogix 5000 Structured Text Syntax and Examples

Structured Text is a textual programming language in RSLogix 5000 that uses statements to define what the PLC should execute. It works like traditional coding languages and is easier to use for complex logic compared to ladder diagrams. Structured Text is not case sensitive, which means writing “IF” or “if” makes no difference. To improve readability, you can use tabs, spaces, and line breaks, but they do not affect how the program runs.

Structured Text can contain several key components:

By combining assignments, expressions, functions, and control constructs, you can write clear and powerful Structured Text programs. Comments should always be used to document your code, making it easier to read, maintain, and troubleshoot later.

Simple Example of Structured Text in RSLogix 5000

Below is a small Structured Text routine that turns on a motor if a start button is pressed and also counts how many times it has run.

motor_on := start_button;
run_count := run_count + 1;
IF motor_on THEN
   pump_speed := 100;
END_IF;

Here’s what happens in this example:

This simple example shows how Structured Text uses assignments (:=) and expressions (mathematical and logical) to create easy-to-read PLC programs. Even with a few lines, you can handle real machine logic without long ladder diagrams.

Why Use Structured Text for Allen-Bradley PLCs?

Structured Text (ST) is especially valuable when programming Allen-Bradley PLCs in RSLogix 5000 or Studio 5000 because it makes handling complex logic much easier. While ladder logic is great for simple start-stop operations, ST is better suited for calculations, data handling, and repetitive tasks that would otherwise take many rungs of ladder code.

For example, if you need to calculate production rates, compare multiple sensor inputs, or run loops for counting parts on a conveyor, Structured Text allows you to write just a few lines of code instead of building long and hard-to-read ladder diagrams. This not only saves development time but also makes the program easier to understand and maintain later.

By using Structured Text in Allen-Bradley PLCs, you gain more flexibility, cleaner code, and better scalability for large automation projects. It bridges the gap between traditional PLC logic and modern programming techniques, making your control systems more powerful and future-ready.

Structured Text Example with IF, ELSE, Timer, and Counter

Below is a practical example of a Structured Text routine in RSLogix 5000. This program starts a motor when a start button is pressed, uses a timer to keep the motor running for 10 seconds, and counts how many times the motor has completed a cycle.

img/rslogix5000-st/rslogix5000-structured-text-example.webp

Let’s break down what happens in this example:

This example demonstrates how Structured Text reduces complexity. Instead of building multiple rungs of ladder logic with branches, timers, and counters, you can handle the same operation with a few clean lines of code. It is easier to read, modify, and expand as your automation system grows.