00:03
Good day. In this video we're going to go
over the steps required to communicate
00:08
with a Modbus TCP device using Node-RED.
I'm going to be using this groov EPIC
00:14
Learning Center and it's perfect for
learning more about groov EPIC or doing
00:18
a proof-of-concept project. I'm also
going to be using this Satec P-130
00:23
power meter as my Modbus TCP device. It's
measuring the voltage and frequency of
00:28
the mains power here in the studio. And,
our goal is to display that data in the
00:33
debug panel of Node-RED. To get started
you'll need the IP address of your
00:38
Modbus device and the hostname
of your EPIC processor you'll also need
00:43
the Modbus device address registers. And,
This is usually found in the manual or a
00:48
supplementary manual for the device.
You'll also need both devices on the
00:53
same network that has access to the
Internet. You can see both devices are
00:58
connected to the same switch here on my
desk. And, also connected to the switch is
01:02
my laptop computer. The switch is in
connected to our company network, which
01:06
has internet access. Go ahead and open a
browser on your computer and go to https
01:12
colon slash slash your EPIC processor
hostname.
01:16
Login,
and, from the homepage select Node-RED.
01:23
Then Node-RED editor. The first thing we
need to do is install the Modbus TCP node.
01:30
This is why you need to have access to
the Internet to be able to search for
01:34
and then install the Modbus node. To do
this click on the menu and then Manage
01:39
Palette. Select the install tab,
then search for Modbus. Install the
01:46
Node-RED contrib Modbus node from the
search results. Wait for the node to
01:53
install before proceeding.
Once the note is installed you will find
01:58
it in your node palette on the left.
Let's start with the voltage measurement.
02:03
We can see in the manual that the phase
1 voltage register is 256, it is a
02:09
read-only register so we need the Modbus
read node. Click drag drop one on to your
02:15
workspace canvas, double-click on it to
open the settings panel.
02:20
Give it a name, in our case read voltage.
Leave the topic blank.
02:28
The device ID is usually 1, but it is
set up in your Modbus device along
02:32
with its IP address. So, in your case it
might be something different. We're going
02:37
to be reading a holding register with an
address of 256. It's a single 16-bit
02:44
integer. Let's set a poll rate of once
per second. We next need to configure the
02:51
device. The name can be anything. I'm
going to call it simply Satec. Type is
02:57
TCP. And, now we put the IP address, and in
my case, the default Modbus TCP port
03:04
number of 502. Both of these settings are
configured on the Modbus device you have
03:10
so they should match your configuration
exactly. That's all the settings we need
03:15
to adjust here for the device. To see the
register value we're going to use a
03:20
debug node. So, drag one over and connect
the two nodes together. We can deploy and
03:27
see our data. Here in the debug tab we
can see our unsigned 16-bit register
03:33
value in raw counts. It's not all that
meaningful. So, how do we turn it into
03:38
engineering units? Well, looking at our
Modbus device manual we can see that the
03:43
conversion is linear 3. Scrolling back up
the manual a few pages shows that
03:48
conversion formula.
To do this in Node-RED we're going to
03:53
use a function block to do the required
math. Let's drag one over the top of the
03:58
wire and once it turns - we can drop it
and have it automatically connect.
04:03
Double-click to open it up. Or we can
start by giving it a name: voltage calc.
04:08
We can now enter the equation, message
payload equals message payload divided
04:15
by 9999 times 144 - 0 + 0 - fixed 1. So
we've simply entered the exact formula
04:26
from the Modbus device manual and then
fixed the result to one decimal place.
04:32
Now let's deploy and see the new result
in the debug tab. There we go,
04:38
much better. Engineering units are a lot
more meaningful. Now let's do the same
04:43
thing for frequency. We drag a read node
over, double-click to open its settings,
04:49
give it a name, unit ID, select holding
register. The address from the manual is
04:57
2 7 9. We want a single 16-bit number, and,
again I'm going to poll the device at
05:03
once per second. Notice that our Satec
device is already configured and is
05:08
ready to go.
Drag a function node over. Give it a name,
05:14
frequency calc. Now let's look in the
manual to see what the upper and lower
05:18
limits are for the frequency. Into the
formula message dot payload equals
05:24
message payload divided by 9999 times 65
minus 45 plus 45 to fixed 2.
05:39
Add a debug node and connect the wires.
Now deploy, and there's both our voltage
05:48
and frequency and engineering units being
updated once a second in our debug tab.
05:52
Where you go from here will depend on
your application requirements. For more
05:57
information on using Node-RED be sure
and check out our other videos at
06:01
training.opto22 com
Till next time cheers mate