Which Language is Best for PLC Programming?

Choose the right PLC language for programming.
Listen to this article

At RealPars, we are often asked which PLC programming language is the best to learn.

Although the students who ask that question want a definitive answer, the only correct answer is It depends on the context.

In many ways, it’s like asking what is the best tool in a toolbox. Just like the tools in your toolbox, every PLC programming language exists for a reason and is suitable for specific applications.

Making it even more difficult for us to answer that question is the fact that different programming languages are more popular in some countries and industries than others.

So the best PLC programming language for you to learn may vary depending on where you live and what industry you are interested in.

In this article, I will explain the main features of the 5 IEC 61131-3 programming languages along with their strengths and weaknesses and where they are used to help you decide which PLC programming languages to focus on first.

IEC 61131-3 programming languages

In case you are not familiar with it, IEC 61131-3 is the standard that defines all of the PLC programming languages.

Remember that to be a complete PLC programmer, you should be able to use all of the tools that are available to you.

This means that you should be proficient at writing logic in any of the major PLC programming languages so that you can always use the optimal language for a specific application.

Let’s start by talking about Ladder Diagram (LD).

Ladder Diagram (LD)

Ladder Diagram, or LD, is the most commonly used PLC programming language. It is a high-level, graphical programming language that is designed to be easy to read and understand for easy maintenance and troubleshooting.

Ladder Diagram is the first PLC programming language that many PLC programmers will learn because most companies want to hire engineers who can program with Ladder Diagram. This is especially true in North America.

In this snippet, you can see an example of Ladder Diagram logic.

Each line of code is a rung and each rung starts with a power rail.

On the right of the rung are output instructions called coils that turn physical outputs on and off. On the left of the rung are input instructions that permit or block the logical flow from the power rail along the rung.

When there is a complete path from the power rail to the coil, the output turns on.

Ladder Diagram (LD)

As you can see, the biggest advantage of Ladder Diagram is its graphical nature. It is very easy to look at a rung and debug the logic even if you are not a programmer.

Ladder Diagram is a great programming language for complex Boolean logic.

For other applications, I prefer to use other IEC 61131-3 programming languages, like Function Block Diagram (FBD).

Function Block Diagram (FBD)

Function Block Diagram, or FBD, is another graphical programming language for PLCs.

In Function Block Diagram, Function Blocks are placed on a sheet and wired together. The end result looks very similar to a Piping and Instrumentation Diagram.

The big advantage of FBD over LD is that the outputs of one Function Block can flow into the next or be used as feedback without using intermediate variables.

This feature makes FBD great for controlling continuous processes where analog values are constantly being monitored and outputs adjusted to keep the value within a range.

Because of its resemblance to P&IDs and its ability to easily control continuous processes, FBD is commonly used in process industries.

FBD

In this example, you can see a snippet of FBD which is being used to monitor the level of a tank.

In this case, analog input from the filling valve is scaled to an engineering value. The engineering value is fed into a function block that converts the data type of the scaled value to an integer data type.

This value is then compared to pre-defined set points to set flags indicating the tank level.

Function Block Diagram (FBD)

FBD is great for continuous process controls but for complex arithmetic operations like calculating the level of a tank, Structured Text is more suitable.

Structured Text (ST)

Structured Text, or ST, is a text-based programming language for PLCs and is popular with younger PLC programmers who are comfortable with text-based programming languages like Python.

Many older engineers tend to avoid Structured Text because it is harder for maintenance engineers to understand and debug.

In general, ST is very powerful for performing complex arithmetic operations and for looping over data structures like arrays.

In this snippet of ST, we are calculating the fill level of a tank based on the volume being added to the tank every time the POU is scanned.

Structured Text (ST)

Sequential Function Chart (SFC)

Sequential Function Chart, or SFC, is a flowchart-like programming language that is used to build state machines and sequencers for processes.

SFC is an incredibly easy language to design in. You create a block for each state that is supported by your process, program the actions that are executed while the machine is in each state, and the conditions that are required to transition from one state to another.

As you can imagine, SFC is also easy to monitor and debug at runtime since you can see exactly what state is active and what conditions must be true to transition to the next state.

SFC is only suitable for defining high-level state machines and sequencers.

In most platforms, the actions that are executed while a step is active are written in ST and many programmers will call a POU written in another programming language like LD or FBD to manage the actions that occur when a step is active.

In this snippet of SFC, we are controlling a sequencer that fills and empties a tank continuously.

When the tank is filling or emptying, actions are to open and close valves and the conditions to move from one step to another depend on the level of the tank or the actions taken by the operator.

Sequential Function Chart (SFC)

Instruction List (IL)

Finally, instruction list, or IL, is an obsolete programming language that was very similar to an assembly language.

You may encounter an instruction list if you are working in a maintenance role, but the recommendation from most manufacturers is not to use Instruction List for new projects.

Instruction List (IL)

Wrap-Up

In this article, I explained the advantages and disadvantages of the IEC 61131-3 PLC programming languages and where each programming language is best applied.

CODESYS 1: Introduction to PLC Programming

If you want to learn more about PLC programming using IEC 61131-3 programming languages, then check out our course CODESYS 1: Introduction to PLC Programming. It’s a great opportunity to learn and master the Ladder Diagram programming language and start writing your first PLC program.

Join the Top 1% of Automation Engineers

Try for Free

Learn from
Industry Experts

Start your learning journey today!
With a 7-day trial, then 25/month
Start Free Trial Now