OptoBlog

Coming soon: IEC 61131-3 on groov EPIC

Posted by Garrick Reichert on Oct 18, 2018 9:08:13 AM

As the "P" in EPIC implies, we are adding more Programming options to groov EPIC in the near future.  Our goal is for this Controller to be truly EPIC, and give developers and engineers multiple programming options on an Edge device, in addition to PAC Control, C/C++, Python, and more that's already available.  So, it's time to get excited about the future of EPIC, and discuss how developers will soon be able to get creative by using an IEC-61131-3 tool set for their applications.

Many automation engineers are familiar with the IEC 61131-3 standard, though you might not know it by that name. If you use ladder logic, you may be using one of the languages the standard defines.

Garrick_old_eqptDeveloped by the International Electrotechnical Commission (IEC), the standard defines the five accepted basic software architecture and programming languages of PLC control programming.

Of these five, one (Instruction List) has already been deprecated in the 3rd edition (61131-3). That leaves us with four languages, three graphical and one textual:

  • Function Block Diagram (FBD)
  • Structured Text (ST)
  • Sequential Function Charts (SFC)
  • Ladder Diagram (LD)

Each language has its basic functions, its strengths and weaknesses, and its detractors and evangelists.

Let’s run down a short history of each language and its intended use, and then I’ll attempt to compare their strengths and weaknesses. I say attempt, as these strengths and weaknesses are based not only on obvious characteristics to anyone using them, but also on my opinions after using them for last 13 years.

And I’ll give you some example code for each language, based on the great programmer William Shakespeare and his most famous line of code, “To be or not to be: that is the question.” I’ve modified the line to fit the context of our discussion, which is implementing the IEC61131-3 languages using the Codesys platform on Opto 22’s new groov EPIC (edge programmable industrial controller).

Ready?

Function Block Diagram

Function Block Diagram (FBD) is the graphical connection of Boolean and function elements.  This language feels a little like Ladder, but looks and feels more like something you would make using computer hardware gates (AND, NAND, OR, NOR, XOR...).  

FBD is meant to simplify what would normally be a long sequence of code and commands, and block them so that it is easy to see the program flow and understand its functionality. This can be a powerful tool for creating large control structures. On the other hand, it can be complicated to troubleshoot, as the blocks can hide code, or there may be numerous custom blocks that complicate matters.

Here's how our famous line of code looks in FBD:

Garrick_FBD

Structured Text

Structured Text (ST) is a high-level language typically formatted to resemble Pascal. It is different from all the other languages because it isn’t graphical; it’s text-based.

ST can be more difficult to write and more difficult to troubleshoot, unless you’re familiar with software programming. Documentation (//code comments) are key in understanding it, whereas the graphical languages tend to be more obvious in use.

That said, ST is one of the more powerful languages, as it performs complex mathematics, iteration loops, and conditional statements with ease.  

The question in ST:

Garrick_ST

Sequential Function Charts

Sequential function charts (SFC) are like the Opto 22 flowcharting language, PAC Control. SFC is a language that’s easy to read from a high level and performs very well while doing continuous batch processing tasks.

SFC can be deceiving in its use, as it usually relies on some form of structured text buried within script blocks to handle the actual legwork of the program. As with the other graphical languages, it is relatively easy to troubleshoot, as long as the syntax is documented and correct.

Here's how SFC looks:

Garrick_SFC

Ladder Diagramming

Last, but not least in the eyes of most controls engineers, is Ladder Diagramming (LD). The most basic of all the languages, it was designed to perform Boolean logic in a format that is easily readable to anyone who has seen a typical electrical diagram.

LD mimics the original relay logic control panels that were the physical precursor to the modern PLC. It has significant popularity in the US, but it is often overused, and people will try to perform complex loops, mathematics, and batching using various tricks, which negate all the simplistic advantage of using it.

And finally, our question in LD:

Garrick_LD

IEC 61131-3 on groov EPIC

Of course these are just my opinions, and I don’t want the high disciples of Ladder beating down my doors extolling their virtues, and waving their normally closed contacts.

groov EPIC systemOpto 22 will be utilizing the Codesys package for its 61131-3 implementation on the groov EPIC to give programmers all the tools they need to complete projects. As you can see from the above diagrams, you can accomplish the same goal using any one of the tools available in the controls environment.

But as the proverb goes, use the right tool for the job. Or as the American psychologist Abraham Maslow said, “If all you have is a hammer, everything looks like a nail.”  Of course you can use any tool, but it may lead to an inelegant solution. It’s better to weigh the pros and cons of each tool prior to using them.

So think before you program, and use the appropriate tool for each application, or the appropriate set of tools if you have many different functions to perform. Using each language in concert for the appropriate function shows that a project is efficient and optimized.

And programmers will have access to a Swiss Army knife of languages for use with EPIC in the near future.

Topics: Codesys, IEC 61131-3, EPIC, groov

Written by Garrick Reichert

Garrick is a Senior Applications Engineer with 13 years experience in industrial manufacturing. He has worked previously as both a systems integration engineer, and a senior engineer for a top ranked craft brewery.

Subscribe to Email Updates

Recent Posts

Posts by Topic

see all