What is a PLC?

A PLC, or Programmable Logic Controller, is a specialized computer intended to control machinery or electro-mechanical equipment. As such, they are built to operate in real-time and survive conditions that would damage a normal computer such as high / low temperatures, dust, impacts, etc. They also tend to have a large number of ports for interacting with analog systems, sensors, switches, motors, and various other systems needed to operate, monitor, and maintain a control system used in industrial automation applications. Thanks to Web 2.0 software development and a demand for improving productivity by managing equipment utilization, a software developer has the unique opportunity to bridge the field of industrial automation with web application development. To understand the role a software developer plays, let’s consider a remote monitoring software application involving an Omron PLC control system.

The Situation – Remote Monitoring for Managed Services

A customer leases industrial machines (i.e. a control system) to their customers that requires remote monitoring for a managed services business model. Workers interact with the industrial equipment to perform their tasks while managers kept a watchful eye for misuse, alarms, or other problem situations. To aid in the prevention of problems and to keep track of the operations that workers were performing with the equipment, the customer who leased the industrial equipment needed a web based application to serve their customers throughout the U.S.

The Solution – Web based Remote Monitoring of PLC’s

To perform remote monitoring of this industrial machinery, the software developer needs to communicate with the Programmable Logic Controller (PLC) used in the control systems. As the software development company, Ayoka was contracted to perform the PLC software development and PLC integration necessary for remote monitoring. Ayoka developed a C# solution that communicated with the PLC based control systems, stored it in a SQL Server database, then and displayed the information on an ajax web application with dashboards that automatically refreshed in near real-time.

How does a Software Developer Perform PLC Programming?

A number of PLCs, including the PLC used by the customer’s control system, use what is called Ladder Logic programming languages for software development. Ladder Logic programming languages are named due to the program having the appearance of a ladder with each rung being an execution step. Each rung will be one of two things:

  • A switch that activates based on an internal variable or the status of an I/O port (input / output)
  • An action to take such as changing an internal variable or switching a motor on via an I/O port

In the case of this project, the customer’s operations manager worked with the web application developers and the PLC programmer to define the business logic for the remote monitoring operations.

How to Communicate with a PLC

In the case of this control system project, communications was made much easier due to an Ethernet port being built into the PLC itself. The Omron PLC used by the control system can be communicated with via the Omron FINS command, which is an Omron protocol which can be used by a PLC program to transfer data with a remote PLC on an Ethernet network. The Omron FINS command contains specially crafted packets that contain destination and source IP address, two command numbers, and up to two thousand bytes of data. These packets are sent to the PLC with via UDP (User Datagram Protocol), meaning that the arrival of the packet is not guaranteed. This means that the remote monitoring software must be able to repeat a command request in the case that the PLC control system never receives the packet. The response packet from the control system will contain two response code numbers as well as up to two thousand bytes of response data. For this particular remote monitoring project, there were only a few commands that were commonly used. The most critical of these commands allows for the remote monitoring software to retrieve the values for a range of memory addresses. The values returned by the PLC can be parsed and reveal the current status of the control system at the customer’s facility. An example of this would be the current electrical usage of a motor being stored in memory range 0xf489 – 0xf48c. To get the information from this memory range, the remote monitoring software would send a command packet to request this memory range from the PLC, listen for a valid response, and interpret/store the returned information as necessary. Remote Monitoring of a PLC Control System flow chart showing how remote monitoring software reads from PLC Another often used command allowed for the remote monitoring software to write values to memory addresses on the PLC. This is useful if, for example, the PLC is designed to wait for a value at address 0xf22 before it performs some action. An application of this would be an alarm collector. If the control system were to have a number of errors, it would queue them up for the remote monitoring software to retrieve and set a flag that the remote monitor application watches. When the remote monitoring software detects the tripped flag in the control system, it would first pull down the first alarm record followed by writing a certain value to a confirmation flag on the PLC. When the PLC sees this flag, it would proceed to write the next alarm on the queue for the remote monitoring software to pull. This process would continue until the alarm queue is empty. Remote Monitoring of a PLC Control System flow chart showing how remote monitoring software writes to PLC

Interpreting Data from the PLC Control System

All data retrieved from a PLC is in byte format. These bytes need to be converted and/or interpreted so that the remote monitoring software can display human-readable information. Some of the values retrieved from the PLC can be directly converted into characters, which can then be assembled into strings. Other values are stored in hexadecimal or Binary Coded Decimal (BCD) format and need to be converted into base 10 integers. Certain bytes use each bit as Boolean status flags, so each bit must be read.

Remote Monitoring the PLC

After the data has been retrieved from the PLC and converted into human-readable values, it must be stored in intermediary storage so that remote monitoring software can access it. There are many possible methods for this, each having pros and cons. In this instance, a SQL database acted as the storage. Using a database allows for easy adjustment of data, and can be connected to almost any web application programming language. Web based remote monitoring enables simultaneous (concurrent) access to up-to-date control system information through a web browser. Multiple users of the remote monitoring software can view the same dashboard for equipment status at once without performance issues. In the event of network downtime or problems with access to the database, the software development team implemented a lightweight database for offline browsing. The lightweight database, SQLLite, used for this remote monitoring software project has the ability to generate a table in memory for improved performance. From there, any type of web application can hook into the database and display dashboards based on the PLC control system data. For our customer, the software developers wrote an Ajax Enabled web application that updates as quickly as possible to display up to date data. PLC data flow to remote monitoring software with SQL database as intermediary storage

Frequently Asked Questions

  • What is a PLC control system?

A PLC (Programmable Logic Controller) is a computer that is specialized to control machinery or electro-mechanical equipment. A PLC operates in real-time, and is made to withstand conditions that might damage a normal computer.

  • What is Remote Monitoring Of A PLC Control System?

When workers use mechanical and industrial equipment, managers need a way to monitor to assure things run smoothly, avoiding mistakes and misuse, as do the owners of the equipment who lease it out. Remote monitoring allows both managers and equipment owners to monitor such usage to avoid any issues.

  • How does a Software Developer Perform PLC Programming?

Many PLC’s use Ladder Logic programming languages for software development. Their name stems from the resemblance of the program to a ladder, where each step is a new rung. The rungs can either be a) a switch that activates based on an internal variable or the status of an I/O port or b) an action to take such as changing the internal variable or switching a motor or via an I/O port.