Kickstage Logo
Default post hero

Prototyping machine dashboards using Node RED

IoT
Nikola Jerković
Nikola Jerković
,

If you run a manufacturing shop or a factory floor, chances are you already have some sort of monitoring system set up or you are looking into getting one. Deciding which would be best for your use case can be difficult as they tend to vary depending on complexity, pricing and feature support. This post is meant to help you set up your own dashboard prototype so that you can gauge which features are useful for you, and which may be redundant.

When machines have been acquired over longer periods of time, as is the case with many factories, they can be of varying manufacturers, generations, interfaces and protocols. This can present issues if you want all of your machines connected to the same system. In this example we'll assume the machines are equipped with an Ethernet interface or can be upgraded to support it. One machine will only support Modbus, while the other will be Profinet, though a wide range of supported protocols is available in the Node RED library. Non-Ethernet protocols such as RS-485 and IO-Link are also supported as long as the host computer has the adequate adapters.

The reason we chose Node RED for this post is that its block-based interface and large library allow for fast creation of prototypes, easy modifications and good readability of projects. All nodes (blocks) are organized in flows which show the flow of data very explicitly so that it's easy for someone upgrading or maintaining the dashboard to understand at a glance where a certain chunk of data is being read from, how it is processed and in which dashboard, gauge or chart is it shown. Reading an extra value from a machine is a matter of changing one field in one configuration, and showing it means just adding another node. Using Node RED also makes it easy to store the data for future reference, process it into more complex values such as efficiency and overall equipment effectiveness, or pass it into more complex systems like Prometheus and Grafana with even more analytics tools.

Getting Started

To set up a Node RED dashboard prototype, you first need to install Node (version 18 or higher) and Node RED. This is platform specific and not the topic of this post so it would be best you follow the instructions in the provided links: Node , Node RED.

Once you have them installed, run the local Node RED instance and use the upper-right menu to open Manage pallete and install the modules you require for the dashboard creation and machine interfacing. In this case, that means:

  • node-red-contrib-s7
  • @flowfuse/node-red-dashboard
  • node-red-contrib-modbus

With the modules installed, we can start setting up the dashboard. The building blocks of Node RED are nodes, configurable blocks which perform perform different functions and communicate with each other via messages. These nodes can be grouped in flows, sub-flows and groups, depending on what the task requires.

For the purposes of this prototype, we will require two machines, or to be more precise, two simulators. The simulated Profinet machine will be run outside of Node RED and emulate having a fluid tank who's level and temperature are being monitored as well as a motor for which we'll be tracking the speed. The Modbus machine can be mocked with a few simple nodes in Node RED and will in this case only have a valve and a flow meter.

First we set up a blank Modbus server

modbus_server

and then we set up a few Modbus Write nodes to write data into the memory space of the server.

Reading the Machine Data

In order to show the data in the dashboard, we first have to read it from the machines. In case the data being sent by the machine interfacing nodes isn't what the dashboard nodes are expecting, the data will also have to be modified.

Reading From a Profinet Machine

Data from a Profinet machine can be fetched by using the s7 in node. We'll be using the All variables mode so that we don't have to use multiple nodes to fetch multiple values.

We also need to configure its connection settings by setting the correct IP/port of the machine, and changing the cycle time if we need the data to be updated more often. The mock machine has the following properties set so the variables list needs to be set accordingly. Data types not listed in this table can be found in the module documentation

NameData BlockData TypeOffset
Machine nameDB1String (10 char.)0
SpeedDB2Unsigned Integer0
TemperatureDB2Integer2
Fill percentageDB2Unsigned Integer4

If you wish to check the data incoming or what form it's coming in, you can simply attach a debug node to the S7 node and view the output by hitting CTRL+G and then D.


Preparing the Profinet Data

One important aspect of the communication between nodes is that all messages are in the JSON format. Each msg object will have a payload property which contains the data important to us. In case of the s7 in node we configured, the msg object will look something like this

1{
2 "payload": {
3 "article_name": "Article 1",
4 "speed": 0,
5 "temp": 20,
6 "percentage": 0
7 }
8}

Since gauges for individual values will only expect that value in the payload, we need to strip the payload. This can be done by routing the message through a change node first.

By doing this (in this example, for speed), we tell the change node to replace the payload value in the new message with just the speed value of the incoming message. We then get a msg object that looks like this:

1{
2 "payload": 0
3}


Reading From a Modbus Machine

Data from a Modbus machine can be read in Node RED in multiple ways. You have the option to read a large batch of data, a single point of data or to read based on an input message. Since we used batched reading in the Profinet example, here we'll use individual data point fetching with the Modubs - Read node.

The flow value is an integer so we're reading one memory location from the holding registers and checking it every second. We also need to set the IP/port like we set in the modbus server. The valve value can only be open or closed so we can read the coil status as a boolean. Since the Modbus - Read node can read multiple values at once, it sends the payload as an array, of which we only require the first entry. Like in the Profinet example, this can be achieved with the change node.

payload message

Creating the Dashboard

In order to have a functional dashboard, it's important to set up a proper layout for it. This is done in the Dashboard - Layout menu where we can add or edit pages of our dashboard and do the same to groups within each page. In this example we'll just have one page (named Sample Dashboard) with two groups, one for each machine.

dashboard menu


In dashboard groups, we can reorder the elements within it or we can edit the grid size of the group.


grid size


We can now start adding dashboard elements. For this example, five gauge nodes and one text node is enough to display all of the read values. The text node needs to be connected to the change node meant for the article name and the gauges can be connected to the rest of the change nodes. Once we assign each gauge a name, the dashboard should look something like this



Each individual gauge needs to be configured according to the data it will be showing. In case of the Motor Speed gauge, this means setting its grid size to 2x2, its type to 3/4 of a circle with a needle style, the range from 0 to 1000 and segments within the range, the label and unit.

Since the Valve gauge only has two states, we can use a Tile type for it and use color codings of red and green for its states.

With everything set up, we can click Deploy do run the changes and then click Open Dashboard in the Dashboard screen to get redirected to our new dashboard.

Now, let's say we want to track the temperature changes in the last 30 minutes. We simply need to add a chart node, increase the grid size of the Profinet group to accommodate the larger chart, connect the chart to the Filter temperature node and then configure the chart's size and X-axis limit.

chart setup

With a little fidgeting around the group grid sizes, you should end up with a dashboard not unlike the one bellow

sample dashboard

The data doensn't need to be just incoming. If we assume the Modbus machine's valve is controllable, we can use a copy of the Set Valve node from the machine mock and connect its input to a dashboard switch node which will allow us to toggle its state.

With the new changes deployed, the Modbus machine group should now have a new toggle as seen bellow.

The inputs towards the machine don't have to be just a button. You can add text inputs to your dashboard that can then be sent to the machine in order to change articles or a dropdown menu for selecting states. There's even a file upload node that lets you send configuration files to your machine. In case you wish to store any of the data read from the machine, all you need to do is connect a formatting node such as csv or xml and a write file node to the output of the value you wish to store. The more you play around with different nodes, the possibilities you'll discover.

Final Word

That's it. You now have a dashboard to monitor your machines that you can set up and modify on your own within minutes. Adding another machine or an extra value to monitor is easier than adding an image in a Word document. If you want to connect a machine who's protocol isn't covered in this post, chances are that you'll find a node that supports it in the vast Node RED library. Hopefully this post helps you figure out if Node RED is enough for you, if you need a more advanced monitoring tool or if dashboards don't really make your job any easier and the machine's HMI is doing its job just fine.

READ NEXT ARTICLES

Let’s Collaborate

Need to plan, create, or redefine a digital project so you can concentrate on your core business? We can help! Pop in for coffee at our office or simply reach us using the details below.

Office

Radnička cesta 47, 10000, Zagreb, Croatia

Contact

Valentin Topolovec

Social

Valentin Topolovec

Valentin Topolovec

Project Manager