No. 70 Queens Street, Yaba, Lagos
+234 (0) 806 568 6953


If you’ve spent more than five minutes in the industrial automation world, you would have come across the great Ladder Logic vs Structured Text Debate. There are those that are team ladder no matter what (usually older engineers or technicians) while there are those who are team Structured Text and couldn’t care less if anybody could read their code. As with most matters the truth is usually somewhere in the middle. There are some cases where ladder would be more appropriate while there are some cases where structured text would be more suitable. The mark of a good engineer is picking the right tool for the right job and not insisting on using an Allen-key to loosen a screw.

In this article we would be considering two scenarios and try to see where ladder would be more suitable and where we might want to use structured text.

Consider a simple machine that has a motor and a pump that has start and stop buttons and an emergency stop.   The first network shows the program for the motor written in Ladder (LAD).

Figure 1 Ladder Logic for Pump Control

Anyone looking at the program can understand the program and easily follow the logic and debug it in the event of a fault.

The program for the pump follows exactly the same logic but the program is written in structured text. The logic can not be followed quite as easily and it would even be more difficult to troubleshoot in the event of a fault.

Figure 2 Pump Control Logic written in structured text

As a general rule, we can see that ladder logic works better with binary logic that involves digital signals.

Let us now consider a situation where we have a temperature transmitter reporting its values in Celsius. Suppose we have an application that needs the value in Fahrenheit.

The Ladder/FBD and Structured Text program to carry out this conversion is shown in Fig 3.

Figure 3 Temperature Conversion Logic written in Ladder and Structured Text

From the above diagram it should be immediately obvious that the Ladder/FBD block is not quite as intuitive while it’s structured text variant is understood at first glance.

To take the example further, let us now consider a situation where we now have 5 transmitters

In Ladder Logic/FBD, we would need to call the Calculate block 5 times as shown in Fig 4.

This would usually mean copying and pasting which is prone to error

Figure 4 Ladder Logic/FBD temperature conversion

The implementation of the same task in structured text is shown in Fig 5. It takes only three lines of code.

Figure 5 Ladder Logic/FBD temperature conversion

Suppose the plant expands and the number of transmitters increases to 10. All we would need to do is to change the array index for the program to (0 to 9). The lines of code would remain exactly the same. The same task in Ladder/FBD is shown in Figure 6 just for effect. Now imagine a situation with 200 meters. We can very quickly see that it doesn’t scale well.

Figure 6 Temperature Conversion for 10 meters

The optimal way to use structured text

Structured text works best when it is not directly visible in the main program (usually by hiding it in a function). This allows the plant engineer interact with the program through the input and output parameters of the block interface without trying to understand the code.

In a project I did a while back, I had to write a function to swap every real value coming from a flow computer before using them in the plc due to the difference in the way different devices structure their data(this is called endianness).

The code is shown in Figure 7 below. 

Figure 7 Array Real Data Swapping

The code was then hidden in a function that allows the user input the Input array, output array and start and stop values. This is shown in Figure 8 below.

Figure 8 Swapping function instance in the main program

This hides the complexity of the code from the final user allowing them to interact with the program from a system level view. I believe this is the best way to use structured text.

In conclusion,Ladder is best used for binary on/off logic or programs with many digital interlocks. Structured is best used for scenarios that involve complex calculations, loops, batch data processing e.g. bulk tag mapping and so on.

There is a lot more to be said about the choice of language to use in your future automation projects but I hope this would help you use the appropriate language for each task.

You might want to check out our article on Functions vs Function Blocks here.

Leave a Reply

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