ControlLogix IF / THEN Statement


Introduction to ControlLogix IF / THEN Statement

The most common instruction is the ControlLogix IF / THEN Statement. This is for Structured Text routines. Structured Text is an easy way to program complex algorithms. Additionaly, some vendors prefer to use all structured text routines. One of the reasons to use structured text is that you can write logic without using Studio 5000. Later on, the developer will simply past the logic into a structured text routines.

The problem with structured text is that many technicians are intimidated by this programming method. Really, though, it’s just logic that you write in plain English. Ladder logic has the advantages of symbols which make logic easy to troubleshoot. On the other hand, structured text routines can be difficult to follow.

Undeniably, though, you are more likely to call the vendor for support. This could be one of the motives behind vendors that use structured text.

Relating Ladder to Structured Text

Convert XIC to Structured Text

To begin, let’s talk about how we could convert ladder to text. Once you get the hang of this, it will seem very easy. Let’s start with a simple rung:

Let’s convert this to a simple if… then… statement. In this case, we would say “IF A THEN B”. When A (is true), we want to energize B. Likewise, if A goes false, we want B to go false.

Now, let’s look at how we would write logic in structured text for this statement. Structured text will use a similar format. In structured text, however, we must terminate each command with a semicolon. Additionally, we need to state when we wish to shut our output off.

We have an operator ” := “. This sets a tag to a specific value. In this case, when A is true, we set B equal to 1. This will energize the output bit. On the other hand, if A is NOT true, then we shut off B.

Convert XIO to Structured Text (NOT Statement)

At this point, consider the following rung.

First, convert this rung to plain English. We would say, “IF NOT A THEN B”. In other words, we want B to be the opposite of A. There are a couple ways to do this.

When A goes false, we energize B. Likewise, if A goes true, then we shut off B.

Here is another way that we could accomplish this:

Structured Text AND Statement

Next, let’s consider the following logic:

As we did before, we’ll convert this to plain English. In this case, we have an AND statement. Both A AND B need to be high to get C. Just A is not enough, and just B is not enough. We must have both. Let’s see what this would look like in structured text:

When A AND B are true we get C. Otherwise, we shut off C.

OR Statement (ControlLogix IF / THEN Statement)

This time, we’ll look at a branch.

Here, we would simply say, “IF A OR B THEN C”. In other words, if A is true, we would get C. Likewise, if we have B, then we will have C. Additionally both instructions can be true. This is not exclusive.

In structured text, we would write this as:

It’s important to realize that we must shut off our output if the condition is not true.

For more complex logic, you can use parenthesis to group data together. For example: If ((A OR B) and (C OR D) Then E. In this statement A OR B HAS to be true. Likewise, with C OR D. One of those have to be true as well. Once these conditions are met, then our output would energize.

For more information, visit the ControlLogix Category Page!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *