This is part two of my series on the IEC-61131-3 programming standard. Here's a link to Part 1 for those of you that missed it.
The IEC61131-3 standard contains 5 different programming languages. This article will give a brief introduction to each one and some tips on choosing which language is best.
The five languages:
Ladder Diagram is most popular in the USA. It is based on the graphical presentation of Relay Ladder Logic. Most non-IEC61131-3 compliant PLCs only support ladder logic.
Instruction List is the European counterpart to Ladder. As a textual language, it resembles assembly code.
Function Block Diagram expresses the behavior of functions, function blocks and programs as a set of interconnected graphical blocks, like in electronic circuit diagrams.
Structured Text is a very powerful high-level language with its roots in Ada, Pascal and “C”. It can be used for the definition of complex function blocks, which can be used within any of the other languages.
Sequential Function Chart (SFC) is a powerful graphical technique for describing the sequential behavior of a control program
So which one should you choose? The choice of programming language is dependent upon the following:
- The programmers’ background
- Are they better/faster at programming and debugging a particular language
- The end user’s preference
- As consultants, we often select a language based upon our customer's skill set. If they prefer one language over another, we will use it even if it would not have been our first choice.
- Code that is easy to maintain may be much better than code that was easy to write in the first place
- The task at hand
- Ladder, Instruction List, and Function Block Diagram are work well for bit logic.
- SFC is great for sequential operations.
- Structured Text is perfect for complex math functions, array operations, and string operations.
- Instruction List is well suited for low level processor commands and PLC memory/register access.
- The way in which the logic is defined
- If your pseudo code is written as a graphical flow chart, SFC is a good choice.
- If your logic is defined as a stateless system where the outputs and inputs are linked with interlock logic, then Ladder is a good choice
If you are still unsure of which language to choose, here's a secret: YOU DON’T HAVE TO CHOOSE! That’s right, the great thing about the IEC61131-3 standard is that you can structure your project and mix and match programming languages.
If you structure your code properly and leverage the power and flexibility of function blocks (you do use function blocks, don't you?), you can modularize your code into manageable blocks. Each block can be written in a different language. You can choose which one is most suitable for each section of the project. For example: Basic I/O logic could be written in Ladder, main control and sequential operations in SFC, and data processing in ST. This way you can maximize the benefits of each language without having to choose one over another.
In the next segment, I'll be writing about what I believe to be the most important and powerful feature of the IEC61131-3 standard: Function Blocks!
Learn more about DMC's PLC programming services.