66842ad8cdcf282665f86800 2402cd Podcastcover

Object-oriented programming or ladder logic?

Oct. 14, 2024
A Control Intelligence podcast with editor in chief Mike Bacidore, written by contributing editor Tobey Strauch

In this episode of Control Intelligence, written by contributing editor Tobey Strauch, editor in chief Mike Bacidore discusses object-oriented programming in PLCs.

Transcript

One manager recently said all his people used ladder logic and didn’t know object-oriented programming. He went on to explain that the company wants to be able to reuse code.

In essence, even ladder programmers are using object-oriented programming because they are utilizing premade functions that are in the default libraries and putting that in their ladders. For example, timers are premade functions already in many libraries, and those are used throughout ladder logic.

Object-oriented programming is simply software that is divided into objects. An object can be thought of as a block, a unit or a cannister—the list goes on. But most describe this piece of software as an object so that, when you have a discussion, others may follow.

Within that object, the descriptions, associated data, procedures, interfaces or methods are included and combined to make an element. An element is typically a function. For instance, a motor starter is something that can be found in almost any system. To create an object that is repeatable in a PLC program, or library, the first step is to understand what is being interfaced-with physically. Then describe the inputs and outputs in software, determine data types and then create the functionality in the function block that is wanted to be repeatable. Physically, a motor starter is described electrically. Taking the physical functionality and describing it in code may equate to a function block.

Then the structure is set up to allow the object to be reused. The function block code could be in ladder logic or structured text. Both blocks would act the same way.  Once the block is made, then it is usable for being called in a routine.

Let’s review the steps to creating a reusable object. First, understand the physical functionality. Next, list out the inputs and outputs that interface with the PLC. At this time, decide if these inputs and outputs are integers or Boolean and assign a type. Then write pseudo code for the logic required to run the function. Put that pseudo code into executable code in the function-block logic. Remember that it needs to cover the generic function so that it can be repeatable. After that, program, compile and test. Once the bugs are worked out, then it is sharable with the rest of the controls group. The advantage of these reusable code blocks is that code starts looking the same, and it saves time.

About the Author

Control Intelligence | A Control Design Podcast

Control Intelligence is a Control Design podcast that goes deep inside the automation and technology that machine builders, system integrators and end users rely on to keep production humming efficiently. New episodes come out every Monday, and download all episodes by Apple Podcasts or Podbean.

Sponsored Recommendations

Learn how Beijer’s X2 extreme HMI thrives in extreme oil & gas environments—this webinar breaks down specs, certifications, and integration strategies for industrial engineers...
NSK integrates advanced automation and drive technologies to deliver high capacity, high speed, ultra-precise indexing and positioning in a compact, flexible linear actuator: ...
Unlock comprehensive insights into today's thermal processing landscape with Honeywell's whitepaper, detailing advanced technologies and solutions designed to enhance thermal ...
Sensing devices and vision components are a large part of safety systems. They protect employees, equipment and processes. But they do so much more. The applications are continue...