How to reduce workload using reusable components for PLCs

Multiple programmable logic controller (PLC) platforms now support pre-packaged code to reduce your programming time.

By Brandon Teachman May 1, 2024
Courtesy: Vision Control & Automation


Learning Objectives

  • Understand what pre-packaged code is and how it is used for programmable logic controllers (PLCs).
  • Learn about the benefits of using pre-packaged code for PLCs.
  • See examples of pre-packaged code implementation for PLCs.

Programmable logic controller (PLC) insights

  • Pre-packaged code accelerates PLC programming, enhancing responsiveness, reliability and reducing errors, which helps save time and improve efficiency.
  • Utilizing pre-packaged code standardizes PLC programming across projects, enhancing code readability, consistency and accessibility while reducing support costs.

Writing programmable logic controller (PLC) programs from scratch is usually time-consuming and tedious. Many know about the long-term costs and frustrations of debugging and maintaining code, but there is a method to increase the code’s dependability and quality while streamlining and simplifying the PLC programming process. Multiple PLC platforms can now use pre-packaged code to reduce your programming time and support.

Three benefits of pre-packaged code

Pre-packaged code is a collection of pre-made libraries and functions that let users quickly construct PLC applications. Pre-packaged code can help users to:

  1. Accelerate your code: Using tested pre-packaged code to perform common tasks reduces the time spent writing code. Due to this, the code may become more responsive, resilient and faster. Users also are minimizing errors by using proven and validated code. This reduces testing and troubleshooting time.

  2. Standardize your code: Pre-packaged code can be used across different hardware platforms and projects. Users can use the same functions and libraries for different projects and follow identical coding conventions and best practices. Using this can make the code more readable, consistent and more accessible for others to support.

  3. Reduce support costs: Using pre-packaged code, users can update or replace these packages when needed. For example, if a machine uses pre-packaged code that interacts with an outside platform, users can update the package without redoing the code if it updates its communication spec.

CODESYS is a programming software that works with multiple PLCs. In the CODESYS, pre-packaged code is available in the form of libraries. Users can download many free libraries, but some have a cost or only work with specific hardware. To use pre-packaged code in CODESYS, users need to follow a few simple steps.

  1. Identify the library that contains the code you need.

  2. Import the library into your project.

  3. Write the code to interact with the library.

Figure 1: The Library Manager in CODESYS that allows users to add and select pre-packaged code for a project.

Figure 1: The Library Manager in CODESYS that allows users to add and select pre-packaged code for a project. Courtesy: Vision Control & Automation

For example, there was a case where message queuing telemetry transport (MQTT) messaging to an existing PLC program. While MQTT is a feature not native to this particular PLC, CODESYS has several different library options, including ones that support Sparkplug B.

For this application creation, WagoAppCloud library and the Native MQTT support it offers were used to send messages to the MQTT broker.

Another example would be adding SQL database connectivity, which is not a feature that comes with the PLC. There are multiple libraries that can connect to a database. In this case, it was the Microsoft SQL database and used the WagoAPPSQL_MsSQL library. This hardware-specific library allows users to connect and send SQL syntax to a database.

Using pre-packaged code can help reduce programming time and support efforts and improve workflow and development time. Users also can benefit from the advantages of pre-packaged code and create better PLC programs faster and easier. Users might be surprised how pre-packaged code can improve their next project.

Brandon Teachman is an application engineer at Vision Control & Automation. Edited by Chris Vavra, web content manager, CFE Media and Technology,


Keywords: PLC, programmable logic controller


What applications could benefit most from pre-packaged code at your facility? 

Author Bio: Brandon Teachman is an application engineer at Vision Control & Automation, where he helps businesses improve their manufacturing processes through automation solutions.