Learn Structured Text

May 27, 2020

I’m excited about the topic of this article, which is….

Structured Text!

Structured Text is an up and coming, popular programming language used in PLCs. This language is much different than ladder logic but it allows you to do all the same things and more with a lot less space (visually and in terms of processor memory). 

It’s been around for a while but it’s getting really popular now, so it will serve you well to at least have a basic familiarity with it.

It’s actually a lot like other more traditional programming languages out there like C++ or Java but it’s specifically designed for PLCs. 

Here’s an example of a really simple Structured Text program in an Allen-Bradley PLC (Studio 5000 Logix Designer):


Motor_Run_Relay := 1;



Motor_Run_Relay := 0;


The logic above turns on the Motor_Run_Relay output when the Start_PB input is on (being pushed) and it turns off the Motor_Run_Relay output when the Stop_PB is is on (being pushed).

Pretty simple right?

This is called an IF...THEN statement, or construct. This is the most basic and commonly used construct for PLC automation but there are many other more advanced constructs you can use too

Now let's dig in a little deeper...


Prefer to read it? Go Ahead…

Hey guys, its Stephen here from myPLCtraining.com with another video to help you become a confident PLC programmer.

I’m excited about today’s topic because this is something I’m still learning about myself. And I’m having fun with it!

That thing is the Structured Text programming language.

Structured Text is a modern PLC or PAC programming language that looks very similar to traditional computer programming languages like Visual Basic or C++.

But we’re not gonna waste anymore time.

Let’s jump right into Studio 5000 Logix Designer and get busy creating a structured text program.

Now, just a quick side-note, if you don’t have access to Studio 5000 Logix Designer be sure to check out myPLCtraining Academy where, as of recording this video, we give every member access to our Rockwell software. This may not last forever but it’s available now, so check it out in the description box below.

So here, we are inside the software. And I want to create a new program. So we’ll right-click the the MainTask and click add new program. Let’s call it “Get Structured”.

Right-click the new program, choose add new routine. Give it a name. We will just call this ‘Main’.

Next, we will go down to ‘type’ and choose “Structured Text” .

Ok great now here we are in a new structured text routine, so from here it’s all about knowing the right syntax for programming your logic. 

So I’m going to do a really simple example. This logic will start a motor when the start push-button is pressed and stop the motor when the stop push button is pressed.

So that looks like this:







Also, just you get an idea of how this translates to ladder logic, this simple IF statement with one BOOL tag would be equivalent to a single XIC on the left side of the rung. 

And the MOTOR_RUN_RELAY := 1; set to 1 would be equivalent to a OTL latching output on a ladder logic rung.

And the next if statement would be similar to the first except instead of a OTL latching instruction it would use a OTU unlatching instruction.

Note that when you’re writing an IF statement, you’re asking if this statement is true then do x. And when you put a BOOL tag in your IF statement you only need to put the tag, it is then assumed that you’re asking if it’s true.

If you wanted the statement to ask if the selected tag is NOT true than you would simply type if “IF NOT Start_PB THEN”

So, continuing with that, let’s add some conditions to our IF statements here.

Let’s make sure we don’t allow the motor to start unless the STOP_PB is NOT pushed so that would change our statement to…




So  this would correspond to changing the ladder logic we created to 

And speaking of things that are last, I need to wrap up this video.

If you want to learn more about structured text programming,  I recommend you check out myPLCtraining Academy which is a our membership site for helping electricians, technicians and engineers become confident automation professionals.

I hope you enjoyed this video and learned something. We will see you in the next video!

Want to learn more about structured text for free?

Get the FREE Structured Test Bonus Lesson

Get the Free PLC Cheat Sheet

PLCs are really not that complicated. If you are new to PLCs or just looking to get a better handle on how they work, check out this free cheat sheet, called the "Motivated Electrician's Guide to Understanding ANY PLC System."

Grab the Cheat Sheet

Where should we send it?