+Tech TopicsLearning ResourcesProductProgrammable ControlUncategorized

Comparing Ladder Logic and Object Oriented Programming

Jerry Reaves, PLC silo product manager at AutomationDirect, wrote an article for the July 2018 issue of Control Engineering titled Comparing ladder logic and object oriented programming

In the article, he discussed how many young automation professionals are comfortable with object oriented programming (OOP), but Reaves says ladder logic remains the standard for industrial automation applications:

arduino object oriented programming

Arduino microcontroller hardware (above) is usually programmed with an object oriented language, typically a basic form of C language.

Industrial automation has relied on ladder logic for nearly 50 years. Programmers with decades of industrial programming experience like it. But they won’t be here forever, and the industry is getting this influx of younger workers who are already familiar with OOP. How can we introduce these new workforce entrants to ladder logic?

Understanding Object Oriented Programming

OOP has a history longer than ladder logic, appearing in the early 1960s or before. Current hardware and software are adding to its popularity. Leading microcontrollers, such as Arduino and Raspberry Pi, are examples.

Arduino microcontroller hardware typically uses a basic form of C programming. Raspberry Pi is a Linux-based system, with many OOP programming platforms, such as Python and Java. These low-cost microcontrollers and Microsoft’s .NET platform have made OOP easily available to those who want to learn it.

Reaves explains that OOP uses objects, and it’s necessary to understand the concepts of objects and their use to grasp OOP:

Once an object or modular class has been written, it is easy to reuse and call it multiple times. For example, when an object is created to control a motor, it takes care of all inputs, outputs and faults. This single object can be used multiple times as instances when several motors are need to be controlled. It’s called when needed and creates an instance when used.

This Do-more BRX PLC from AutomationDirect provides an industrial strength hardware platform for executing ladder logic.

OOP can have higher overhead than ladder logic because it tends to need more memory and processor power. The learning curve for an OOP programming language can be longer. Significant time, practice, testing and application, likely in a classroom, may be needed to grasp concepts.

Learning Ladder Logic

Ladder logic is a very simplistic and self-documenting method of coding, and some even debate whether it is even a programming language. It follows the format of ladder-type electrical diagrams used in relay-based control systems, and most people can learn it quickly. It was the only industrial-strength programming language for decades in the machine automation arena, and it’s still the main programming language used in the automation industry.

Ladder logic is well suited for both machine and process control, particularly for automating systems with lots of discrete I/O. Ladder logic has been modified over the years to also handle analog I/O, making it a good fit for many process control applications, which tend to have a higher proportion of analog I/O as compared to machine control applications. And, Reaves says, it’s easy to learn:

A wide range of skilled, technical, and engineering personnel can learn ladder logic quickly because it’s easier to use than OOP. The logic is very systematic and orderly, making it simple to follow and understand due to its self-documenting nature. Each line of code must be true before it turns something on. If there are five motors, there are typically at least five lines of code, providing a high degree of simplification.

Easier to Learn

Ladder logic is intuitive for electrical engineers and maintenance personnel. While ladder logic requires a different mindset than OOP, it can be learned quickly, and it takes less time to understand code written by others. It is very clear when the logic is true. Contacts on or off, energized coils, comparing variables and common math functions are easy to follow—even by someone with limited programming experience.

Ladder Logic Pro

This AutomationDirect Productivity Suite Software main screen highlights the visually intuitive nature of ladder logic programming, even for those with limited experience.

Its ease-of-use simplifies troubleshooting and debugging as well. When monitoring the logic, it is straightforward and easy to see what is happening. No software degree or advanced programming skills are necessary. With ladder logic, it’s easy for maintenance and engineering personnel to follow the flow and understand what is going on. But, Reaves notes, it’s a little unusual:

Ladder logic is a symbolic language, unfamiliar to computer programmers and IT personnel because it’s not something they typically learn in school. Handling math, text strings, and data in ladder logic can be difficult because ladder logic was not originally conceived to deal with these functions.

Reaves says users should compare pros and cons of ladder logic and OOP and the existing use of these languages within the environment where they will be deployed:

If the plant or facility has standardized on ladder logic, the use of OOP will be discouraged, even if it’s a better fit for the application. But OOP use is growing, and it’s expected to co-exist with ladder logic for decades to come, so it would behoove an aspiring automation professional to learn both languages.

To read more articles about ladder logic, click here.

Originally Published: July 2018