00:03
How would you go about exchanging serial Modbus data with Allen-Bradley PLC data?
00:08
Well one way might be to use the groov Edge Appliance and embedded software
00:12
like Ignition Edge and Node-RED. As an example we have this Wattnode energy
00:17
metering device accumulating energy data from this workshop. From this groov Edge
00:21
Appliance here where you're going to read the accumulated energy from a
00:25
Modbus register on the Wattnode over the serial connection using Node-RED
00:29
and then write to a different register to reset the accumulated value with this
00:33
push button which is wired to the Allen Bradley PLC. We'll do the PLC portion with
00:38
Ignition Edge and its built-in OPC UA server. These devices are typical
00:43
examples of what you might find on the edge of an industrial automation system.
00:47
Where normally the A-B PLC and serial devices cannot easily communicate. But
00:52
the industrially hardened groov box bridges the gap between devices without
00:56
requiring a PC on site. To learn more about setting up Node-RED or Ignition
01:01
Edge on the groov Edge Appliance check out our other videos on workshops.opto22.com
01:04
In this video we will focus on gathering Modbus data and reading an
01:10
input from the Allen-Bradley PLC and we'll cover a lot of things like how to
01:15
get serial Modbus data in and out of the groov box with nNode-RED, how to get a
01:19
push button state from an Allen Bradley PLC into the groov box with Ignition
01:23
Edge, how to set up Ignition Edge for Node-RED integration, how to create and
01:28
view Ignition tags using the Designer App, and finally how to configure the
01:32
Ignition Node-RED read and write nodes to exchange data. Let's get started
01:41
first we'll take a look at the net energy usage being measured by the
01:45
serial Wattnode device. The best place to do this is to see where it's brought
01:49
in to Node-RED. I'll navigate there now by opening a
01:52
browser and heading to HTTPS:// the hostname or IP address of your
01:58
groov box colon 1880. Acknowledge the security warnings and proceed to your
02:07
Node-RED instance where you can log in with your groov Admin credentials. Here I
02:16
already have a flow set up. This node simply reads the workshop's accumulated
02:20
energy from the Modbus register.In this case reading from register 1000 every 2
02:26
seconds.Then the value is extracted, formatted and printed to the debug pane
02:31
on the right. If I go to the debug pane and enable this node I can see the
02:38
accumulated energy showing up on the right-hand side. Here we are going to
02:43
write this net energy measurement value to an Ignition tag for future reference
02:46
as well as read a button value from the Allen Bradley PLC through the Ignition
02:50
OPC UA server. This will use the Ignition read and write nodes. Once the button
02:55
value is in Node-RED it will trigger a reset of the measurement inside the
02:59
Wattnode device so it starts accumulating again from zero. This is
03:03
done by writing to the reset register using this node here set for register
03:07
1-6 1-9. Resetting the total could be useful for finding out how much energy
03:12
is being used in a given day, during a shift, or over certain production cycle.
03:17
There are two things we need to do to link Node-RED and Ignition Edge. That is
03:22
to install the Ignition Node package and the Node-RED module. To install the nodes
03:26
open the menu and select manage palette. From here go to the install tab and
03:32
search Ignition. Go ahead and install the top result.
03:40
Now before we can move on to Ignition Edge we will need to make sure that it's
03:44
running, that we have access, and also find and download the module file to
03:49
manage Ignition Edge we need to open groov Admin in a new tab by going to
03:53
HTTPS:// the same hostname or IP address and this time at port
03:59
10,000
04:04
Again you'll need to login with your groov Admin credentials
04:09
and then select the Ignition Edge tab on the left hand side. If you don't see this
04:15
you'll need to update your groov box to the latest admin update. From here ensure
04:20
that the boxes to enable and run Ignition Edge at startup and the check
04:24
box to enable access to Ignition Edge Designer and Edge Panel are both ticked
04:28
and hit save.
04:32
Next we will need to download the Node-RED module file which can be found
04:36
by visiting a great Node-RED resource flows.node-red.org
04:43
From here we can search for the Ignition Node package
04:50
and see its requirements specifically the Ignition module.
04:55
Follow this github link and go ahead and download the file. Now we're ready to
05:01
head over to Ignition Edge. This will be at port 8043. If this is your first time
05:12
using this instance of Ignition Edge there are some initial setup items
05:15
you'll want to do including changing the default admin password login credentials.
05:19
If you are unsure how to do this please check out our previous workshop video
05:23
that goes over this process. Once you're signed in go to the main configure tab
05:29
and under the first system category select modules. This will take you to the
05:34
main module configuration page. At the bottom there's an option to install or
05:39
upgrade a module. Select that and provide the file you just downloaded.
05:46
Click install and approve the self-signed certificate
05:51
to give Node-RED permission to access the Ignition tag database.
05:55
Once that process is successfully completed there will be a new category
05:59
Node-RED with the single sub item API tokens. Select that and create a new
06:06
Node-RED API token and secret. This pair is the key password set that authorizes
06:12
Node-RED to access the tag database. The name can be anything so I'll call this
06:16
set workshop and the API token opto22opto22opto since it must be exactly 16
06:25
characters no more and no less. Set a password make sure that the key stays
06:32
enabled and create the token.
06:37
Before we go back to Node-RED let's check out the Ignition tag database to
06:41
see what we can read from and write to. Since we already enabled Edge Designer
06:46
in groov Admin we are free to launch it using this button in the top right and
06:50
open the file.
06:53
Note that once you have this file you can feel free to go back and uncheck
06:57
that box in groov Admin to close the insecure TCP port. Also, note that you
07:02
will need Java to run this app so if you don't already have it follow the prompts
07:06
to the free download before you continue. Once the designer is open we can log-in
07:12
with Ignition Edge credentials and see the entire tag structure in the tag
07:16
browser window. By default there will be two main folders under tags; data types
07:23
and edge nodes. You will have to make this sub folder structure for your
07:27
devices under Edge Nodes but I have some here already. At the top we can see the
07:32
group ID folder, usually named for the device or vendor that the tags originate
07:36
from, so I've used the vendor name Opto 22. Under that we can see the Edge Node
07:42
ID folder, usually named for the location, so for me that's Optoworkshop. Under
07:48
that is the specific device ID, which I've named groov Edge Box.
07:56
I already have one subfolder associated with this device for the Allen-Bradley
08:00
PLC. If I expand that I can see some of the tags that are available. If I hit the
08:06
toggle button now we can see it changes to true and back to false when I release.
08:12
This happens through the Ignition Edge OPC UA server that connects the Allen
08:17
Bradley PLC with the groov Box. The names of these tags and folders don't matter
08:22
too much but the folder structure of group ID, edge node ID, and device ID is
08:27
important so be sure to follow this convention when creating a new folder
08:31
structure. To easily find this value again right-click it and copy the tag
08:36
path to your clipboard. To give us an end point in the tag
08:40
database to write to I will create a new subfolder called a groov Edge. To create
08:46
this folder I right-click on the device ID and select new folder. Here I can give
08:52
it the name groov Edge.
08:56
To create a new tag under this device ID folder right click on the folder and
09:01
hover over new tag. Right now don't worry about the other tag types just select a
09:07
memory tag. For this example I'll call it net energy and set the data type to be
09:15
float. Here we can see it's shown up in the tag structure so now we have all the
09:28
tags we need for Node-RED. Go back to that first tab and since the Ignition
09:34
nodes are already installed we can scroll to the bottom
09:38
drag in an Ignition tag read node and double-click it to edited settings.
09:45
Here you want to select the pencil icon to add a new Ignition server and give it
09:50
all the required details. Here I provide the API token and key set that I made in
09:55
Ignition Edge for me that's opto22opto22opto and the password. Make sure to
10:03
enter these exactly because they're both case sensitive. You can leave the default
10:07
tag provider, and since this configuration will work for both reading
10:10
and writing you can just go ahead and save it and then paste the tag path from
10:15
your clipboard that you copied a moment ago. Next let's test the connection
10:21
between the A-B PLC and the groov box. This is as simple as dragging in an
10:26
inject
10:29
and debug node. Wire these two together deploy the flow. And when I
10:40
inject
10:43
I can see that the energy reset button is in the payload under Ignition result
10:48
held in value. Right now the value is false but if I hit the reset button
10:54
connected to the Allen-Bradley PLC and inject again I'll see a new value of
11:02
true. So we know the connection is working. Before I do anything more with
11:11
this data I need to see the format that is required by the Modbus node.If I
11:17
select the Modbus node and look at the info tab I can see that it's required to
11:21
be on message.payload whereas the ignition tag was in message.payload.ignitionResult.value
11:27
To make this change I can simply use a change node. I
11:35
will use this to move message.payload.ignitionResult.value
11:44
into just message.payload
11:51
Also since this value is being put into a register it must be changed from a
11:56
true/false boolean to the number 1 or 0. Again the change node is perfect for
12:00
this. I'll drag in another one. I will use it to change the message.payload
12:07
property and search for the value true and replace it with the value 1. And add
12:14
another rule to search message.payload for the boolean value false
12:23
and replaced that with a zero.
12:30
Lastly I'll change the input node to regularly inject every two seconds
12:36
as well as adding a rate by exception node to make sure it doesn't update the
12:41
value every second that it is checked. The default to block and less value
12:47
changes is perfect for this. Now I can wire these nodes together.
12:52
I can deploy and enable the debug output of the current net energy. That value is
12:58
now appearing in the debug pane every two seconds. Once I've wired the flow
13:05
together I can deploy, enable the debug output of
13:08
the current net energy so that when I hit the button to toggle that energy
13:11
reset variable on the Allen Bradley PLC I can see that Node-RED has taken the
13:15
change in the Ignition tag and put 1 into Modbus register 1619 so
13:21
we have a flow of data from the Allen Bradley PLC to the serial Wattnode
13:24
device. And now we're counting back up from zero.
13:32
Finally as well as using the Ignition read node I'll also use an Ignition write node to put the accumulated energy
13:38
value into the net energy tag that we created an Ignition Edge Designer
13:42
earlier. Before we can feed this data into the
13:47
Ignition write node it needs to be carefully repackaged just like the
13:51
serial node required. To see what the write node needs again
13:56
check out the info tab. In this case the value to write must be
14:02
on message.payload.tagValue. Another thing to keep in mind is that as well as
14:07
being on the correct path the input must be of the same data type as the tag in
14:11
the Ignition tag database. Here they're both decimal so we're good to go there.
14:16
To get the message.payload to a message.payload.tagValue I could use another
14:21
change node to move like I did above but instead I'll use a function node to show
14:26
you how to make this change with JavaScript. First I'm going to create a
14:37
new object to return. It is going to have the single property tag value which I
14:44
will assign the value of the current message.payload. Then I simply return a
14:50
new message object where the payload is the new object I just built. Simple as
14:55
that. Now the value is ready to write. To make finding this tag path easier I can
15:07
once again go to Edge Designer, right click on net energy, and copy the tag
15:13
path to my clipboard so that it's easy to paste into Node-RED.
15:19
Once I provide the node with the server that I set up earlier I can hit done,
15:25
deploy, and now every two seconds this Modbus node will fetch the energy data.
15:30
This function node handles the buffer to float conversion takes that number and
15:36
moves it to the correct message path and finally writes it to the float net
15:40
energy in the Ignition tag database. If we head back over to the Ignition
15:44
Designer we can see that the tag is updating live already. And right now
15:48
we've used just a few kilowatt hours. How cool is that! So there you have it we
15:53
have shown you how to install, configure and use the Ignition node read module to
15:57
read and write Ignition OPC UA tags without using a PC just this
16:02
industrially hardened IOT appliance. Combining the power of Node-RED and
16:06
Ignition edge on the groov box gives you a whole range of ways to move different
16:11
types of data to suit your needs. With this energy data now in Node-RED I am
16:15
free to write it to a database like SQL, display it in groov, even send it
16:19
to be analyzed by artificial intelligence software like IBM's Watson,
16:22
or anything else you can imagine. To learn more check out our other videos
16:27
on workshops.opto22.com Thanks for watching.