Curious About Structured Text Programming? Try Productivity PLCs
In one of the most recent software revisions, structured text (ST) was added to the Productivity Suite software for AutomationDirect’s Productivity PLC family. Learn how to create a simple program.
Structured text (ST) programming is rapidly growing in popularity in the PLC world. While some claim that ladder (LD) is overall preferable for PLC programming from an electrical perspective, most people agree that mathematical calculations are much easier to program in ST.
We won’t try to evaluate the pros and cons of ST vs. LD in this tutorial; plenty of convincing debate can be found online. No matter what your personal preference is, today’s PLC programmers must be comfortable with both LD and ST.
Many engineers consider that only the more advanced, capable PLCs can be programmed in both language types, and until very recently, AutomationDirect’s Productivity PLC family lacked this feature.
In this tutorial, we will show how to perform a simple Celsius to Fahrenheit conversion in AutomationDirect’s Productivity Suite with a Productivity PLC, comparing both ST and LD.
Prerequisites and Hardware/Software Required
- Laptop/PC with Productivity Suite (must be version 4.7 or higher)
- Productivity PLC (in this tutorial we will use a P1-540 CPU)
- Programming cable for connecting PLC to PC/laptop
- Power supply for the PLC
- Wire, screwdriver, and tools
Getting Started with Productivity Suite
First, download Productivity Suite.
Note that structured text capability was added in v. 4.7. If you try to use an older version, it will not have this option.
Programming the PLC
Our program will consist of a very simple degrees Fahrenheit to degrees Celsius conversion; the formula for this is: F = C * 9/5 + 32.
We will build this operation in a ladder routine first, and then within a structured text routine.
Programming a Ladder Routine
Open Productivity Suite. On the window that follows, select “Start a New Project”. You will be prompted to select your specific CPU model.
In the lower left, under “Task Management”, select “New Task - LD” to create a new ladder logic routine.

Figure 1. Productivity Suite allows you to add new LD or ST routines.
To be able to use the “Math Editor” instruction in an LD routine, you must create the relevant tag names (in our case, the tags corresponding to Fahrenheit and Celsius values).
On the left hand side of the programming environment, click on “Tag Database”. On the pop-up window that follows, click “Add Tags”. Add the tags corresponding to your Fahrenheit and Celsius values. We will call them “F_ladder” and “C_ladder”. Remember to make them Float data type.

Figure 2. Adding tags in Productivity Suite. Image used courtesy of the author
Once the tags are added, you can proceed with the programming. On the right, under “Instructions”, scroll down until you see “Math Functions”. Drag and drop the “Math Editor” instruction into your program.
In the “Result” field at the top, enter the tag name you created for your Fahrenheit tag.
Entering the formula itself can be a bit tricky. First, in the drop-down menu below the formula box, select the tag corresponding to your Celsius value (C_ladder) and click “Insert”. Now enter the rest of your formula in the “Formula” field and click “OK”.

Figure 3. Using the “Math Editor” instruction in Productivity Suite.
Your program will now look as shown in Figure 4 below:

Figure 4. LD program with degrees C to degrees F conversion logic.
Programming a ST Routine
This time, select “New Task - ST” in the lower-left Task Manager to create a new structured text routine.
Simply type in (or copy/paste) the following (note the colon before the equal sign and the semicolon at the end)
F_st := C_st * 9/5 + 32;
Choose descriptive tag names for your C and F terms, and choose different names than you used in your LD routine so they can run concurrently without overwriting. We will use “C_st” and “F_st”.
Unlike in the LD routine, you do not have to predefine the tag names in advance.
Now click on “Validate” directly above your programming window.

Figure 5. ST programming of degrees C to degrees F conversion.
In the next window, you will be prompted to define your tags. Be sure to change them to Float data types.

Figure 6. Validating and defining the tags in the ST routine.
After you define the tags, the red lines under the tag names will disappear. This means that your code is properly validated and ready to download to the PLC.
That’s it! The ST routine programming was much faster and more straightforward than LD for this simple math expression.
Downloading and Testing the Program
Now we are ready to download the project to the PLC.
From the top menu bar, click on “Choose CPU”. Assuming the PLC is powered and connected via USB, select the CPU, then click “Connect”. You should see the status change to “Connected”, as shown below.

Figure 7. Selecting the CPU before a project download.
Now, from the top menu bar, navigate to File -> Transfer Project -> To CPU, and wait for the download to complete.

Figure 8. Transferring (downloading) the project to the PLC CPU.
If needed, move the physical Run/Stop switch on the front of the PLC CPU to Run mode. Finally, right above your programming window, click on “Monitor”. You will now see your F and C values. Since the initial Celsius value was 0.0, your Fahrenheit values will be 32.0 (these correctly correspond to the freezing point of water).

Figure 9. Monitoring the ST program in real time.
Switch to the LD program, and monitor it as well:

Figure 10. Monitoring the LD program in real time.
Conclusion
We hope you’re convinced that ST can speed up your programming in some scenarios, especially those calling for math calculations. Of course, ladder logic has its strengths also, and it’s definitely not falling out of use anytime soon.
For larger PLC projects, it’s common for programmers to use a “mix” of LD and ST. For example, one could use ST for routines that are calculation-heavy and LD for routines copied from legacy projects.
As well as LD and ST, IEC 61131-3 includes Function Block Diagram (FBD) and Sequential Function Chart (SFC) programming language standards.
If your PLC has all four options, then it’s certainly possible to use all four within the same PLC project. As you become a more experienced programmer, you will get a better feel for what kind of language standard is the best fit for your particular needs.
All images used courtesy of the author