Ladder Logic vs. Everything Else: 9 Considerations For Selecting a Programming Language
Author’s note: I’m proud to share my latest Control Engineering article on the topic of ladder logic’s future role in automation. Check out the excerpt below, then read the full article published in the July 2018 issue of Control Engineering.
Ladder logic is favored by manufacturers in discrete industries, but as technology and automation evolve, its usefulness compared to other IEC 61131-3 programming languages and PC programming depends on application complexity and other factors.
Ladder logic, the primary programmable logic controller (PLC) programming language, is simple and represented graphically as relay contacts and coils. The question is, though: How well can ladder logic serve the complex automation needs of the present and future compared to other programming languages? The answer is more complicated than just contacts and coils.
Ladder logic origins
Automation existed before PLCs, frequently using a network of relays for the brain of an application. There wasn’t a programming role; there was an engineer to design the circuit and an electrician to assemble it. The circuit would be documented in a standard structure that resembled a ladder when drawn on paper, hence the name “ladder diagram” (see Figure 1).
When PLCs arrived, they promised a lot of benefits to automation, but nobody knew how to program them. Then someone got the idea to program the PLCs with the ladder diagram, which allowed the industry to repurpose existing skill sets for programming. Engineers and electricians could read and understand the programming, and automation design could largely follow the same patterns it had with relays.
Before PLCs, relays took up physical space in a cabinet, cost money to buy, and required time to wire.They were also limited to on/off functionality-without capabilities for analog, math, or data collection in relay logic (aside from some sparse timing and counting functions in special relays). Even the largest, most complex automation systems were limited by the realities of physical relays, so the language of ladder logic didn’t have to do very much.
Today, the processor chip inside a PLC can do more than relays at a much lower cost of space, money, and implementation time. In turn, the programming languages used in PLCs have grown to reflect the increased capabilities. Ladder logic does a lot more today than it used to. PLCs commonly are used for analog control, tracking part data (barcodes, test results, calibration), controlling motion, and a plethora of other tasks-and ladder logic is still the dominant language. As the language has evolved and automation has become more complex, programming PLCs has become a more specialized occupation. Ladder logic is no longer such a convenient language for electricians to read and maintain, nor is it a broadly existing skill in the incoming workforce.
Other PLC programming languages
Industrial programming is influenced by two communities: the standard IEC 61131-3, the industrial control programming standard from the International Electrotechnical Commission; and PC programming. These languages usually are seen as complementary to ladder logic, rather than directly opposed.
IEC 61131-3
As PLCs became popular, the industrial community found the need for standards to guide programming. The IEC’s committee addressed this need with standard IEC 61131, and languages specifically in part three (61131-3). This defined four programming languages that generally were interchangeable-ladder diagram, function block diagram, structured text, and instruction list-and also a program organization language called sequential function charts.
Each language has its own strengths and weaknesses, and they can be used together within one program to best support different program functions. There’s certainly room for debate on which language is best suited to which task (see Figure 2). Generally, a process will operate as discrete or continuous. Automation also tends to lean towards mostly digital input/output (I/O) or analog I/O.
PC languages
The languages drawn into automation from the PC world tend to be used for specialty/peripheral applications. That may include interfacing with databases or programming automation peripherals like cameras and robots. Structured text (defined in IEC 61131) is a very similar to Pascal, a common PC programming language at the time IEC 61131 was introduced. Pascal has since fallen out of favor, but it’s a great example of how the automation industry has borrowed from the PC industry in the past. Current examples of PC languages in automation include C++, Java, and C#. These languages are powerful, but haven’t found a strong foothold in automation.
Three programming questions
Before comparing ladder logic to other potential options, it’s important to understand what a program really needs to do. A program has to make the automation work, which virtually any language can do, but the real world puts other demands on it as well. This largely boils down to readability. Ask these three critical questions about your programming languages.
A. Can a programmer or maintenance technician look at the code and understand what it does?
B. Can problems be found quickly to minimize machine downtime?
C. When new functionality is desired, how easy is it to extend the program?
There are features of different languages that affect a programmer’s ability to make a readable program. Nine areas in particular can influence programming language selection. Read More
About the Author
Jon is an engineer, entrepreneur, and teacher. His passion is creating and improving the systems that enhance human life, from automating repetitive tasks to empowering people in their careers. In his spare time, Jon enjoys engineering biological systems in his yard (gardening).