PLC projects, programming best practices, Part 3: Programming best practices

In a September 14, 2023 webcast, "PLC Series: PLC projects, programming best practices" Automation Consulting LLC’s Frank Lamb joined Control Engineering to discuss PLC history and platform differences, as well as the impact of standards.

By Control Engineering February 28, 2024
Image courtesy: Brett Sayles

PLC programming insights

  • In a September 14, 2023 webcast, “PLC Series: PLC projects, programming best practices” Automation Consulting LLC’s Frank Lamb joined Control Engineering to discuss best practices related to PLC-based programming.
  • In Part 1, Lamb discusses PLC history and platform differences, as well as the impact of standards.
  • Part 2 has a case study example on address structures and their unique features and part 3 has more information on PLC-programming platform best practices and considerations.

Programmable logic controllers (PLCs) remain a strong choice for many automation applications, and programming software and practices that use standards have huge advantages over other options. Documentation is important, along with change management, and understanding use of standards to more efficiently program for certain applications. This includes the ability to bridge from operational technology (OT) applications to information technology (IT) connections. By using standards, code will be easier to update and optimize from current to future operations. In a September 14, 2023 webcast, “PLC Series: PLC projects, programming best practices” Automation Consulting LLC’s Frank Lamb joined Control Engineering to discuss these topics and more.

Below, the transcript of his presentation has been provided with minor edits and adaptations.

Program maintenance best practices

A best practice in program maintenance is to keep a master copy of the program in a secure location, such as a server or cloud. This avoids discrepancies between different versions held by various individuals. When taking over a plant, finding no copies of the program except for what’s uploaded in the processors, often lacking comments and documentation, can be challenging. Implementing a naming convention with date tracking for programs is also beneficial, as it helps in identifying the most recent version without relying on properties. In environments like pharmaceutical plants or medical devices, adhering to software validation regulations is critical. Any changes, even minor ones, should be tested, ideally in a simulated environment, before implementation.

Considering cybersecurity and access control

With the increasing reality of PLC viruses and hacking, cybersecurity measures are essential. Restricting access to processors and being cautious with external devices like USB sticks is important to prevent unauthorized access and potential cyber threats.

Final considerations: Programming languages and costs

The final slide of this presentation discusses programming languages and their associated costs on certain platforms. Specifically, platform A, which is prevalent in the United States, charges extra for certain programming languages. This cost factor can influence the choice of language and platform in a project.

Challenges with structured text in plant environments

Despite arguments for using structured text universally, many plants do not have the necessary software to view or interpret this language, as it often requires a more advanced version of the software. This is an important consideration: whether the customer has the appropriate software to access and understand structured text. Such text-based languages can be more challenging for maintenance personnel, particularly in urgent situations. At 2:00 AM, for instance, maintenance staff typically prefer visual cues over text-heavy documentation. They are more accustomed to electrical circuits and visual representations, which is one reason why ladder logic is so prevalent in the U.S.

Complexities of pointers and indirect addressing

Pointers and indirect addressing, while useful for efficiency and reducing code length, can be difficult to understand and troubleshoot. Indirect addressing, especially in brand C as previously mentioned, often requires the use of statement list language, which is less intuitive than ladder logic for many users.

Differences in industry practices and terminology

Different industries employ distinct methods and terminologies. The oil and gas or chemical industries, for example, use techniques vastly different from those in machine control, automotive, or manufacturing. Even the names of routines and elements within these systems can vary significantly. For instance, I’ve worked on projects with components humorously named “piddlers” and “spankers,” which made sense within the context of the process but might be confusing without proper explanation. It’s crucial for the customer to understand these terms, or otherwise, provide a glossary to clarify industry-specific terminology.

The importance of documentation and understanding system controls

Understanding someone else’s code can be challenging, especially if you’re unfamiliar with the controlled processes. Comprehensive documentation is key to bridging this gap. It’s hoped that accompanying electrical drawings, P&ID diagrams, and monitoring tools are up-to-date and comprehensible, enabling effective job performance.