Blog Search Results for

Remote Monitoring and Control of Allen-Bradley PLC Control Systems with the Losant IoT Platform

Kevin Niemiller
Kevin Niemiller 9 minute read

In the manufacturing world there is a lot of valuable data that exists in the PLC. However, because it can be difficult to access, the information is rarely used to improve operations. When PLC data is moved to the cloud, it can be visualized to gain insights, make real-time business decisions, diagnose problem machines, and trigger alerts to critical team members.

We are able to solve this problem and bring the data that exists within the PLC to the next layer by using the Losant Enterprise IoT Platform along with the Losant Allen-Bradley Read and Write nodes. In this blog, we are going to walk through how to connect to an Allen-Bradley CompactLogix or ControlLogix PLC from the Losant platform. By doing this, we will have the ability to read tag values from the PLC to Losant and also write values from Losant to the PLC tags.

Losant water pump demo dashboard

Let’s walk through each component of the Losant platform that we will be using.

  • Losant Edge Agent - The Losant Edge Agent is deployed on a customer device that has access to the local network to communicate with the PLC.
  • Losant Workflows - The two types of workflows that will be used are Edge and Application workflows.
  • Losant Dashboard - The Losant dashboard provides a flexible and powerful way to display your data from the PLC and control your equipment.

Walkthrough

In order to demonstrate how this works together, we are going to walk through a remote monitoring pump demo we’ve designed. All of the controls and feedback for this demo exist in Losant which reads data from the PLC and writes data to the PLC. Together, we’ll take two parts of this demo and walk through how to turn the pump output on from Losant and how to read the flow switch input data back to the Losant platform.

Getting Started with Losant

If you do not have a Losant account, you can sign up here. This gives you a free, fully functional developer license that will allow you connect to your PLC.

Create a new application or add to an existing application. Steps to create an application are here. The name I gave this application is ‘PLC Monitoring’.

Create an Edge Compute Device by following the instructions listed here. I named this ‘Edge Device’.

Install the Losant Edge Agent on a device that also has Ethernet access to the PLC and to the internet. Follow the instructions here for getting the Losant Edge Agent on a device. For testing purposes, you can use your personal laptop but it is not recommended for a long-term solution.

Create an Edge Workflow

This Edge Workflow will be deployed to a local device running the Losant Edge Agent and will be responsible for communicating with the PLC using the Allen-Bradley Read and Write nodes.

Within the ‘PLC Monitoring’ application, we want to click on Workflows and then Create Workflow.

  • Workflow Name: Allen-Bradley PLC (any name here will work)
  • Workflow Type: Edge
  • Description: Remotely Monitor and Control Demo PLC (any description here will work)
  • Minimum Agent Version: Edge Agent v1.4.0 (to use the Allen-Bradley Read and Write nodes, the Edge Agent must be at least v1.4.0)

Losant platform screenshot of create workflow screen.

Click create and your Edge Workflow will be created.

Now that we have our Edge Workflow created, let’s add two different flows. The first flow will be responsible for turning the pump on when a command from the Application Workflow is sent. The second flow is responsible for reading the flow switch every second to see if flow is present. Go ahead and drag and drop each node and connect these nodes as shown below and then we will walk through each node.

Losant platform switch node screen shot

The Device:Command Node will trigger this workflow when a device command from the Application Workflow is made to our ‘Edge Device’. Do not worry about how this command is made from the Application Workflow yet, we will cover that below. There is no configuration needed for this Device:Command Node.

Losant Allen-Bradley Write Node screen

Losant Allen-Bradley Write Node screen

The Losant Allen-Bradley Write Node will write all tag values configured within this node for the PLC of the IP Address provided.

  • Address Config
    • Host Template: 192.168.5.10 (this is the IP address of the PLC or EtherNet/IP Module that we are connecting to)
    • Slot Template: 0 (this is the slot that your PLC is in)
    • Keep-Alive Interval Template (Seconds): 30 (this value allows you to set a time to keep the connection open to the PLC. This value should be set to less than the connection timeout of the device you are connecting to. If you do not read or write a tag within the device’s connection time, then the device will close the connection. Each time a connection closes we have to open a new connection the next time we write to the PLC or read from the PLC which adds some latency. We have it set to 30 seconds which means we are pinging the PLC to keep its connection open every 30 seconds)
  • Write Instructions
    • Controller or Program Tag Template: Pump (here we enter the name of a tag in the PLC that we want to write to)
    • Program Template - MainProgram (if this is a program tag, then the program name must be specified here. If it is a controller tag, then leave this field blank)
    • Data Type: Atomic (the Pump tag is a BOOL)
      • Atomic - data type is SINT, INT, DINT, REAL, BOOL
      • STRING - data type is STRING or a custom STRING type
    • Value Template: true (this is where the value goes that you are writing to your tag. In this case, we are writing a boolean tag so writing true or 1 works)
  • Result
    • Destination Path: working.plc_write.result (this is optional, and provides feedback (‘success’ or ‘fail’) from the write onto the payload).

In our PLC program, we have a program named ‘MainProgram’ which has a program tag named ‘Pump’ which drives the output to turn the pump on. We are writing a value of ‘true’ (1 works as well) to this program tag. If this tag were a controller tag then the Program Template field would be left blank. We are also configuring the optional Destination Path so that we get feedback of the PLC write on the payload.

When the write node is executed, it will return a ‘plcProperties’ object on the Destination Path payload. These properties give information about the PLC and the current state of the PLC such as minor or major faults, PLC serial number, the PLC model, PLC firmware version, etc. These properties are also returned when the read node is executed.

This completes the edge workflow for writing to the PLC. Now let’s read a PLC tag which is connected to a flow sensor input. The timer node in this example is set to one second. Every second, it will trigger this workflow.

Losant Allen-Bradley Read Node screen

 

Losant Allen-Bradley Read Node screen

The Losant Allen-Bradley Read Node will read all tag values configured within this node for the PLC of the IP Address provided.

  • Address Config
    • Host Template: 192.168.5.10 (this is the IP address of the PLC or EtherNet/IP Module that we are connecting to)
    • Slot Template: 0 (this is the slot that your PLC is in)
    • Keep-Alive Interval Template (Seconds): 30 (this value allows you to set a time to keep the connection open to the PLC. This value should be set to less than the connection timeout of the device you are connecting to. If you do not read or write a tag within the device’s connection time, then the device will close the connection. Each time a connection closes we have to open a new connection the next time we write to the PLC or read from the PLC which adds some latency. We have it set to 30 seconds which means we are pinging the PLC to keep its connection open every 30 seconds)
  • Read Instructions
    • Controller or Program Tag Template: Flow_Switch (here we enter the name of a tag in the PLC that we want to read from)
    • Program Template - MainProgram (if this is a program tag, then the program name must be specified here. If it is a controller tag, then leave this field blank)
    • Data Type: Atomic (the Flow_Switch tag is a BOOL)
      • Atomic - data type is SINT, INT, DINT, REAL, BOOL
      • STRING - data type is STRING or a custom STRING type
    • Result key: Flow_Switch (any name here works - when the PLC reads the Flow_Switch tag from the PLC that we specified in the ‘Controller or Program Tag Template’ field, it will store the value of this read to this key on the Destination Path - we will set the Destination Path next)
  • Result
    • Destination Path: working.plc_read.result (this is the payload path that the Result Keys for each tag that we are reading will go to)

This node shows that we will be reading a program tag named ‘Flow_Switch’ from a program named ‘MainProgram’. The result of this read will be put on the payload as the Result Key, which in this case is also named ‘Flow_Switch’. The Result Key (‘Flow_Switch’) will be put onto the payload at the Destination Path that was configured (working.plc_read.result).

The next node updates the Device State. I created a device named Flow_Switch as Device Type Peripheral and I am updating a number attribute I created named ‘flow’ with the response from the previous Allen-Bradley Read Node.

Losant Device State screen

The next node, Device State, allows us to update the Flow_Switch device each time we trigger a read on this PLC input. Configure the node so that the attribute ‘flow’ for the Flow_Switch reflects what is being read from the PLC which is accessible from the payload at working.plc_read.result.Flow_Switch.

Deploy the Edge Workflow

To deploy the workflow, click Save in the top right corner and then click Deploy which will bring up a pop-up box like the one shown below.

Losant Deploy New Version Screen

Any version name can be given but it must be unique each time you deploy so using a timestamp works well. Select the device(s) that this should be deployed to which in our case is the ‘Edge Device’ that we created earlier. Then we can click Deploy Version to have this workflow deployed to our Edge Agent.

Create an Application Workflow

This application workflow will command the pump on from the cloud. Follow the same steps that we used to create an Edge Workflow except select Application for Workflow Type. Once this workflow is created, then create the flow as shown below.

Device Command Screen

The virtual button named Pump On will trigger this workflow when this button is clicked - no configuration is needed for this node. The Device Command Node will send a command named ‘pump_on’ to the ‘Edge Device’. This ‘pump_on’ command was used earlier to trigger the edge workflow and allow the Allen-Bradley Write Node to execute. Once this workflow is created and configured, then we can press the Save and Deploy button at the top right corner. Now, if the Pump On virtual button is clicked, the command ‘pump_on’ will be sent to the edge agent on ‘Edge Device’ through the payload path ‘data.name’ and trigger the edge workflow that will write to the PLC to turn the pump on.

Now that we have all of this setup, a dashboard can be created to display the information we are reading from the PLC. The dashboard shown below is from our Pump demo and built by using easy drag and drop visualization blocks. To find out more on how to build a dashboard, look here.

Losant water pump demo dashboard

What's Next?

Now that you know how to use the new Losant Allen-Bradley Read and Write nodes, use them to connect to the machines on your factory floor. You can start by pulling machine state data and alarms and warnings for each of your machines. Using the Losant Dashboard, you can start tracking downtime on each machine to find your problem machines and also find which alarms are causing the most problems. If you have any questions, check out the Losant Forums. If you want to take your project further, we would love to learn more about your use case.

Kevin Niemiller

Kevin is a Senior Integration Engineer at Losant. Kevin uses his factory floor background in automation and systems integration to develop the Losant platform by connecting new software, hardware, and cloud products. When he’s not working, Kevin enjoys time with his wife and kids; making his own home more intelligent with IoT; and maintaining his blog: bloggingwithdad.com