If-Else Conditions in Structured Text (ST) – RSLogix 5000 & Studio 5000 Programming

Published on Aug 19, 2025 | Category: if else

Share this Page:

In RSLogix 5000 / Studio 5000 Structured Text (ST) programming, an If-Else condition is a fundamental decision-making statement used to control program execution based on logic. It checks whether a condition is TRUE or FALSE, and depending on the result, the PLC executes one block of instructions or another.

We use If-Else statements in Structured Text because they make complex logic easier to manage compared to Ladder Logic. Instead of relying on long rungs with multiple contacts and coils, you can directly write clear text-based conditions. This approach simplifies motor control, safety checks, alarms, interlocks, and decision-based sequences in industrial automation.

By using If-Else conditions in Structured Text, programmers can reduce ladder clutter, increase readability, and implement advanced logic such as nested conditions, loops, and calculations. This makes it one of the most powerful tools for Allen-Bradley PLC programming inside RSLogix 5000 / Studio 5000.

What is If-Else in Structured Text?

In Structured Text (ST) programming for RSLogix 5000 / Studio 5000, the If-Else statement is a conditional instruction that lets the PLC make decisions. It checks if a condition is TRUE; if so, the defined action executes. If the condition is FALSE, the program can either do nothing or follow an alternate action defined by the ELSE or ELSIF branch.

You use IF...THEN to complete an action when specific conditions occur, such as turning on a motor, starting a timer, or triggering an alarm. If the condition is not met, the ELSE part allows you to define what should happen instead.

This makes If-Else in Structured Text similar to decision-making statements in traditional programming languages, but adapted for industrial control systems. It improves readability and is especially useful for handling complex logic without long ladder diagrams.

Expression of If-Else in Structured Text

The If-Else expression in Structured Text is written using logical conditions that evaluate to TRUE or FALSE. Based on the result, the PLC executes the corresponding block of code.

img/rslogix5000-st-if-else/expression-of-if-else-in-structured-text.webp

What is IF Statement in Structured Text (Without ELSE)?

The IF statement in Structured Text is used to perform an action only when a specific condition is TRUE. Unlike If-Else, it does not provide an alternative action if the condition is FALSE. This makes it very useful for simple checks where only one action is required.

img/rslogix5000-st-if-else/if-statement-in-structured-text-example.webp

In this example:

The above image shows a simple IF statement in Studio 5000 Structured Text (ST) where only a single action is executed when a condition is TRUE. This is the most basic form of conditional logic in ST.

What is IF-ELSE Condition in Structured Text?

The IF-ELSE statement in Structured Text (ST) is used to perform one action when a condition is TRUE, and a different action when the condition is FALSE. It provides a complete decision-making structure, making it more flexible than a simple IF statement.

img/rslogix5000-st-if-else/if-else-statement-in-structured-text-example.webp

The above image shows an IF-ELSE condition in Studio 5000 Structured Text (ST). With IF-ELSE, you can design powerful decision-making logic for machine control, safety interlocks, and conditional operations.

What is Multiple IF-ELSE (ELSIF) Condition in Structured Text?

In Structured Text (ST), you can use ELSIF statements when you need to check more than one condition in sequence. This is similar to Else If in traditional programming languages.

img/rslogix5000-st-if-else/multiple-if-else-condition-in-structured-text.webp

Example 1 – Temperature Control System

Example 2 – Motor Speed Selection

Explanation:

The above image shows how multiple IF-ELSE conditions (with ELSIF) are used in Studio 5000 Structured Text (ST) to handle complex decision-making logic in industrial automation.

What is Nested IF-ELSE in Structured Text?

A Nested IF-ELSE condition means placing one IF statement inside another IF. This is useful when you need to check a second condition only if the first condition is already true.

General Syntax:

IF condition1 THEN
   IF condition2 THEN
      (* action when condition1 AND condition2 are TRUE *)
   ELSE
      (* action when condition1 is TRUE but condition2 is FALSE *)
   END_IF;
ELSE
   (* action when condition1 is FALSE *)
END_IF;

Example 1 – Motor Control with Safety

Explanation:

  • First, the PLC checks if the Start_Button is pressed.
  • If yes, then it checks if Safety_Switch is ON.
  • Motor only runs when both conditions are true.
  • Example 2 – Tank Level Control

    img/rslogix5000-st-if-else/nested-if-else-condition-in-structured-text.webp

    The above image demonstrates how nested IF-ELSE structures are used in Studio 5000 Structured Text programming to create safer and more reliable automation logic.

    Conclusion – When to Use IF, IF-ELSE, ELSIF, and Nested IF-ELSE in Structured Text

    In Studio 5000 Structured Text (ST), conditional statements allow you to make decisions and control program flow. Each type of condition has its best use case:

    -

    Choosing the right structure keeps your Structured Text program clean, readable, and reliable for industrial automation tasks in RSLogix 5000 or Studio 5000.