Just like talking to a person, when we talk to a machine, we need to know its language. We 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.
If we’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 us an idea of what we can do.
As a low-level language, IL will execute much faster and take less space in the storage than a graphical language like ladder and function block. And as a pure text-based language, we won’t have tabs to click or anything. No mouse required, which can make programming even faster. We 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.
To know about HART, you can read the Visaya Article on HART Communication Basics
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.
This simple approach makes it a piece of cake to use LD. We just need a basic outline of input and output signals to start coding. We 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. We can also work up timers, counters, comparisons, and other basic functions. However, if we need complex functions such as trigonometry and data analysis, then we 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.
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 we “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.
We 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.
To know about Profinet, you can read the Visaya Article here
While in LD you can segment parts of your codes in a folder, here we can also create our own function blocks. But to start programming in FBD, we need to understand what the function blocks do, which makes it a tad harder than ladder. And when our program gets long or complex, just as in LD, we can have trouble following every step and troubleshooting.
To know more about PLC Programming Languages, you can get in touch with our engineers and we will be happy to help.