PLC programming languages – Function Block Diagram, Instruction List, and Ladder Diagram
Hallo, Leute. ¿Cómo están ustedes? Espero que estejam bem. Did you understand anything I said? If you didn’t, don’t worry. I just said hi and asked how y’all are doing! But I said that in German, Spanish, and Portuguese. These are the languages I speak besides English.
Just like talking to a person, when you talk to a machine, you need to know its language. And I don’t mean English, Portuguese, or any of these languages. You need to know programming languages, especially for programmable logic controllers (PLCs). And just like ours, there a quite a few out there.
Luckily, the IEC 61131-3 (International Electrotechnical Commission) standardized a few PLC programming languages in 1993: instruction list (IL), ladder diagram (LD), function block diagram (FBD), structured text (ST), and sequential function chart (SFC). In this article, we’ll review the first three. So without further ado, los gehts!
If you’ve programmed microcontrollers with assembly language, IL will feel familiar. One of the simplest PLC programming languages (at least in theory), IL moves step by step and makes the entry of a series of simple mathematical functions easy.
Just like assembly, IL consists of many lines of codes, one line for exactly one operation. These operations can have three modifiers. The “N” modifier negates the result, “C” makes it conditional and “(” delays it. This list of operators and modifiers will give you an idea of what you can do.
As a low-level language, IL will execute much faster and take less space in your storage than a graphical language like ladder and function block. And as a pure text-based language, you won’t have tabs to click or anything. No mouse required, which can make programming even faster. You can display and edit it in handheld programming units without the need for software or laptop.
However, IL has weak semantics and no code structure. If a messy person writes a code, another person may have trouble reading it. The lack of visual structure can also make it hard to tell what the program should do or why it doesn’t do what it should. And complex computations can be hard to set up.
Everybody loves ladders! Well, it looks that way, as many people use it. A visual language, LD resembles a series of control circuits, much like wiring diagrams. A non-programmer with an electrical background will find it easy to program, read, and troubleshoot LD.
This example shows a wiring diagram of a circuit which controls a motor via a switch. If we redraw this circuit using two vertical lines to represent the input power rails, we basically have a ladder diagram. Easy, right?
This simple approach makes it a piece of cake to use LD. You just need a basic outline of input and output signals to start coding. You can also organize a ladder program into folders or subprograms, which allows easy segmentation.
LaD works great for simple applications, like on digital inputs which check for various conditions and set outputs accordingly. You can also work up timers, counters, comparisons, and other basic functions. However, if you need complex functions such as trigonometry and data analysis, then you might get stuck. And the bigger the program gets, the more challenging to read and interpret it gets.
Here you can see a simple ladder diagram program.
If you want to know more about LD, let us know in the comments. We might write another article with a better look at it.
In this video you can see a simple Ladder Logic
Functional block diagram
Just like LD, FBD is visual and intuitive for those with an electrical background. For those used to Boolean expressions and digital systems, FBD will feel more intuitive than ladder. It too resembles a wiring diagram. However, here you “wire” blocks together, while LD has more of a relays logic. In FBD, you have inputs on the left of the function blocks and outputs on the right.
You could say that FBD is a visually simpler version of LD. Take a look at this image to see how they relate and draw your own conclusions about this statement.
While in LD you can segment parts of your codes in a folder, here you can also create your own function blocks. But to start programming in FBD, you need to understand what the function blocks do, which makes it a tad harder than ladder. And when your program gets long or complex, just as in LD, you can have trouble following every step and troubleshooting.
So there you have it! Three of the five main PLC programming languages for PLCs. Questions? Comments? Let us know!