In this article we’ll take an in-depth look at the most popular PLC Programming Languages used today. IEC 61131-3 is the open international standard for programmable controllers.
It was first published in December 1993 by the IEC (International Electrotechnical Commission). The third part of the standard defines three graphical and two textual PLC Programming Language styles, which is the topic of focus in this article.
- Ladder Diagram (LD), graphical
- Function Block Diagram (FBD), graphical
- Structured Text (ST), textual
- Instruction List (IL), textual
- Sequential Function Chart (SFC), graphical
In this article we will look at all of these languages in some detail by providing concrete examples and some additional resources where you can go to get more in-depth information on each style of programming.
PLC Programming Languages – IEC 61131-3
Before we get into any depth regarding each of the PLC Programming Languages defined in IEC 61131-3, let’s take a closer look at the standard itself. The standard is broken down into 10 different parts:
- Part 1 – General Information
- Part 2 – Equipment Requirements and Tests
- Part 3 – Programming Languages (the focus of this article)
- Part 4 – User Guidelines
- Part 5 – Communications
- Part 6 – Functional Safety
- Part 7 – Fuzzy Control Programming
- Part 8 – Guidelines for the Application and Implementation of Programming Languages
- Part 9 – Single-drop Digital Communication Interface for Small Sensors and Actuators
- Part 10 – XML Exchange Formats for Programs
The complete standard or any part thereof can be purchased from the IEC website directly at: https://webstore.iec.ch/searchform&q=61131
Perhaps the biggest advantage to this standard is that it allows for multiple programming languages to be used within the same programmable controller.
This allows the engineer to choose which programming language is best suited for a given task.
Yaskawa America put together a relatively short (20 minute) video that does a reasonably good job explaining the standard, the advantages and its importance.
We’re interested…which PLC Programming Languages do you see or implement most often in the field? Please consider participating in our poll below!
PLC Programming Languages – Ladder Diagram
One of the best ways to get up-to-speed with the IEC 61131-3 Programming Languages is to download and install Codesys. This is an open-source software that allows you to program using any of the programming languages listed here.
It is a great tool to get started into the fascinating world of Programmable Logic Control (PLCs).
Without question, Ladder Diagram or Ladder Logic Programming as it’s commonly referred is the most prevalent of all the PLC programming languages.
If you review the poll results above, I’d be shocked if they didn’t agree with this assertion.
The reason Ladder Logic Programming has such wide-spread appeal is that it evolved almost entirely from the “relay-logic” of old.
This graphical means of programming made it very easy for engineering and skilled trades staff to transition from relay-logic control they were familiar with, to Ladder Logic Programming.
Above is an an example Ladder Logic code snippet from an Allen-Bradley Logix controller.
If you would like to get started using Codesys and Ladder Logic programming, I highly recommend you check out Brian Hobby’s YouTube tutorials that will walk you through how to program the various IEC 61131-3 PLC Programming Languages.
You can check out his first one in the series below.
PLC Programming Languages – Function Block Diagram
Function Block is another one of the graphical PLC Programming Languages discussed in IEC 61131-3.
The main concept with function block programming is that data flow starts with inputs and then is passed into blocks which generate the output.
Function block programming is used extensively in process control. It is ideally suited for processes that utilize closed-loop feedback control.
The big advantage of function blocks is that it can encapsulate many lines of code into a single block or instruction. This greatly simplifies code reuse and standardization.
This concept is now parlaying itself into modern programmable automation controllers (PACs) such as the ControlLogix platform of controllers as well.
In these more modern system you now have the ability to create your own “blocks” of reusable code, through the use of something called “Add-on Instructions”.
This functionality mimics a block of code, however, it can now extend itself into ladder logic programming as well.
If you’re interested in seeing how Function Block Programming works, I would encourage you to check out this video by Brian Hobby.
Or if you’re interested in learning how to implement PID control in an Allen-Bradley ControlLogix controller using Function Block Programming, check out our video series here, starting with this one.
PLC Programming Languages – Structured Text
Structured Text Programming is the first of two text-based PLC Programming Languages defined in IEC 61131-3 that we are going to examine. It is a more “human readable” style of programming derived from procedural languages such as BASIC.
The benefit of of Structured Text Programming is that if you come from a procedural or object-oriented programming background, the transition to this style of programming is very easy.
That said, if you don’t hail from a high-level programming background, structured text will provide a good first introduction into how these languages are used.
The basic syntax of Structured Text can be defined by the following statements:
- All statements are divided by semicolons
- The language is NOT case sensitive
- Space (white spaces) have not function
See if you can figure out what is happening in the following Structured Text program?
Looking at the program code above, you can see that after the PROGRAM statement, the first construct is the variable group denoted by VAR/END_VAR.
This is the section where you would define your variables to be used throughout your program.
Wondering what a variable is, check out this video as a quick intro…
It is clear that only one variable is defined here, namely “x”, and it is of a boolean (BOOL) data type, meaning it can only store binary data – either ON or OFF, or in this case TRUE or FALSE.
You can see right after the END_VAR statement, the variable “x” is initialized to TRUE. Then the code enters into a REPEAT loop. The kicker is this loop will only execute once because the first statement in the loop sets “x” to FALSE. And the loop is set to run UNTIL “x” is FALSE, which it inevitably it is after the first iteration of the loop!
A good article on Structured Text Programming can be found here: Structured Text Tutorial For PLC Programmers Tutorial.
Also, check out Brian Hobby’s YouTube video on Structured Text using Codesys.
PLC Programming Languages – Instruction List
Instruction List (IL) programming is another one of the text-based PLC Programming Languages defined by the IEC 61131-3 standard.
This language, more than any of the other “text-based” languages, most resembles assembly language programming. As its name implies, an IL program is comprised of a series of program instructions, much the same way an it is in assembly programming.
The main benefit of Instruction List programming is its execution speed. Because this language is not “graphical” in nature, there is no significant overhead as a result. Therefore, execution time or “scan” is maximized.
The downside of Instruction List programming is that its not a widely used programming style. Therefore, supporting this form of programming can be a challenge as most people use and prefer the graphical programming languages.
For an introduction into Instruction List programming, I again will defer to Brian Hobby’s YouTube video on how to implement Instruction Lists using Codesys software.
PLC Programming Languages – Sequential Function Chart
SFCs is another of the graphical PLC Programming Languages that was designed to break large complex tasks into smaller more manageable ones. Below is a simple example of a Sequential Function Chart style of programming. Of course these can get very complex and were typically used to implement more advanced type systems.
Sequential Function Charts (SFCs) are similar in structure to flow charts. However, they can be implemented to be much more powerful. Unlike flow charts, sequential function charts don’t have to follow a single path.
The underlying concept behind SFCs are steps and transitions. A step is a state or function of the overall system and a transition is basically the intermediate point between a state or function of the system. Or more simply, a transition is a change from one step to another step.
In the diagram above the steps are S1, S2, S3, S4 and the transitions are t1, t2, t3 and t4 respectively. Every PLC manufacturer that offers SFC programming as an option will have additional documentation and different “flavors” of their particular implementation.
Again, I would defer you to Brian’s YouTube video for more instructional help with Codesys and Sequential Function Chart programming.
PLC Programming Languages – Final Words…
It should be clear from this article that there really isn’t one best PLC Programming Language to choose from. In fact, all the PLC Programming Languages defined in IEC 61131-3 will get the job done. However, depending on your background, preference and specific application, you may lean towards one style over the other.
I hope you have enjoyed this article, and I do encourage you to become a member of our growing community of professional engineers, technicians and technologists, Register Here!
Also, check out our YouTube Channel to see some great videos…and don’t forget to like and subscribe to our channel!
If you enjoyed this article be sure to check out some of these good reads too:
- How To Become A PLC Programmer
- Best Laptops For PLC Programming
- What Is Industrial Control Systems Security?
- How Much Does A PLC Programmer Make
- PLC Versus Microcontroller – What’s In Your Plant?
- Essential Tools Every PLC Programmer Needs
- Difference Between DCS And PLC
- How To Implement A ControlLogix PID Controller
Lastly, if you run into any problems in your day-to-day engineering activities please be sure to check out our Live and Interactive PLC Forum!
And if you so desire, assist other community members by replying or offering helpful information to the questions or challenges they may be facing right now!