Uploaded by velos22

OPC-UA, Node-RED and Cloud functionalities for PLCnext technology

advertisement
OPC-UA, Node-RED and
Cloud functionalities for
PLCnext technology
Authors: Gabriel Quintana Siñeriz
Felipe Mateos Martín
11th October 2022
University of Oviedo
Automatic and System Engineering Area
TABLE OF CONTENTS:
1
2
3
4
INTRODUCTION ........................................................................................................................ 1
1.1
Context of Industry 4.0 .................................................................................................... 1
1.2
PLCnext ............................................................................................................................ 1
1.3
Objectives and content .................................................................................................... 4
1.4
About intellectual property ............................................................................................. 5
OPC UA WITH UAEXPERT AS VERIFICATION CLIENT OF THE OPC UA SERVER ......................... 7
2.1
Creation of a OPC UA Server in PLCnext Engineer ........................................................... 7
2.2
OPC UA data verification via UaExpert .......................................................................... 11
NODE-RED IN PLCNEXT .......................................................................................................... 18
3.1
Installation of Node-Red in PLCnext AXC F 2152 ........................................................... 18
3.2
Installation of Node-Red on the PC using Docker Desktop ............................................ 26
3.3
Access to the Docker container of Node-Red on the computer .................................... 29
3.4
Access and using of Node-Red in PLCnext ..................................................................... 31
3.4.1
Flow for PLCnext OPC UA Root server visualization .............................................. 32
3.4.2
OPC UA Reading and writing client nodes configuration....................................... 34
3.4.3
Node-Red Dashboard creation .............................................................................. 36
IMPLEMENTATION OF FUNCTIONS ON THE CLOUD FOR DATA ANALYSIS AND CONTROL ... 40
4.1
Introduction to the implemented Cloud System ........................................................... 40
4.2
General configuration of the IBM Cloud system............................................................ 41
4.3
Node-Red programming on PLCnext for sending data to the cloud .............................. 43
4.4
Node-Red programming on IBM Cloud for data reception ........................................... 45
4.5
Node-Red programming on IBM Cloud for sending data to the cloud .......................... 50
4.6
Node-Red programming on PLCnext for data reception from the cloud ...................... 51
5
CONCLUSIONS ........................................................................................................................ 54
6
REFERENCES ........................................................................................................................... 56
INDEX OF FIGURES:
Figure 1. PLCnext Technology diagram ............................................................................................ 2
Figure 2. Functionalities provided by PLCnext Technology .............................................................. 3
Figure 3. Logo of the Proficloud platform by Phoenix Contact ........................................................ 3
Figure 4. PLCnext trainer EDU AXC F 2152 ....................................................................................... 3
Figure 5. AXC F 2152 control module ............................................................................................... 4
Figure 6. PLCnext Engineer environment version ............................................................................ 7
Figure 7. OPC UA tab on PLCnext Engineer ...................................................................................... 8
Figure 8. OPC UA basis configuration on PLCnext Engineer 192.168.1.10 ....................................... 8
Figure 9. OPC UA basis configuration on PLCnext Engineer 192.168.0.16 ....................................... 9
Figure 10. OPC UA configuration PLCnext Engineer Security tab..................................................... 9
Figure 11. Declaration of local variables for the OPC UA server .................................................... 10
Figure 12.Declaration of global variables for the OPC UA server .................................................. 10
Figure 13. Declaration of variables for the OPC UA server alternate way ..................................... 11
Figure 14. UaExpert install window ................................................................................................ 12
Figure 15. Opening window of UaExpert once installed ................................................................ 13
Figure 16. Adding a OPC UA server in UaExpert............................................................................. 13
Figure 17. OPC UA server data being introduced in UaExpert I ..................................................... 14
Figure 18. OPC UA server data being introduced in UaExpert II .................................................... 15
Figure 19. OPC UA server data already introduced on UaExpert and connecting to it ................. 15
Figure 20. Connection with the OPC UA server already established ............................................. 16
Figure 21. Connection with the OPC UA server already established with all the necessary
variables ......................................................................................................................................... 16
Figure 22. Example of a Nodeld reference ..................................................................................... 17
Figure 23. WinSCP install window .................................................................................................. 18
Figure 24. PuTTY version used ........................................................................................................ 19
Figure 25. WinSCP connection to the PLCnext ............................................................................... 19
Figure 26. WinSCP connection to the PLCnext already made ........................................................ 20
Figure 27. Icon indication for accessing PuTTY once the connection to the PLCnext is made on
WinSCP ........................................................................................................................................... 21
Figure 28. Opening window in PuTTY ............................................................................................. 21
Figure 29. PuTTY once the identification has been done ............................................................... 22
Figure 30. PuTTY window once the root user login has been done ............................................... 23
Figure 31. PLCnext internet access configuration .......................................................................... 23
Figure 32. General PuTTY window once the root user login has been done ................................. 24
Figure 33. Version information of the balena engine installed on PLCnext ................................... 25
Figure 34. Docker desktop installer icon ........................................................................................ 26
Figure 35. Docker desktop application ........................................................................................... 27
Figure 36. Docker desktop opening window .................................................................................. 27
Figure 37. Command window of the user PC ................................................................................. 28
Figure 38. Docker version verification ............................................................................................ 28
Figure 39. Command window of the user PC ................................................................................. 28
Figure 40. Docker container creation ............................................................................................. 29
Figure 41. Node-Red opening flow ................................................................................................. 30
Figure 42. PLCnext Docker container access .................................................................................. 31
Figure 43. General view of the implemented code in PLCnext Node-Red ..................................... 32
Figure 44. OPC UA server root visualizer code .............................................................................. 32
Figure 45. OPC UA server root visualizer I ..................................................................................... 33
Figure 46. OPC UA server root visualizer II .................................................................................... 33
Figure 47. Nodeld data introduction on Node-Red ....................................................................... 34
Figure 48. Reading node on Node-Red .......................................................................................... 35
Figure 49. Writing node on Node-Red ........................................................................................... 35
Figure 50. Visualization nodes ....................................................................................................... 36
Figure 51. Data inject visualization nodes ..................................................................................... 36
Figure 52. General information Dashboard ................................................................................... 37
Figure 53. Extended data of the order in the Dashboard I ............................................................ 37
Figure 54. Extended data of the order in the Dashboard II ........................................................... 37
Figure 55. Remote order ................................................................................................................ 38
Figure 56. General PLCnext/Cloud interaction schematic ............................................................. 40
Figure 57. General PLCnext/Cloud interaction schematic, cloud part ........................................... 41
Figure 58. IBM cloud resources list I .............................................................................................. 41
Figure 59. IBM cloud resources list II ............................................................................................. 42
Figure 60. IBM IoT Platform ........................................................................................................... 42
Figure 61. General PLCnext/Cloud interaction schematic, sending data from PLCnext to the cloud
....................................................................................................................................................... 43
Figure 62. Code visualization for injecting data to the cloud ........................................................ 43
Figure 63. Data reception on the IoT Watson Platform................................................................. 44
Figure 64. Board created on the IoT Watson Platform I ................................................................ 44
Figure 65. Board created on the IoT Watson Platform II ............................................................... 45
Figure 66. General PLCnext/Cloud interaction schematic, cloud Node-Red ................................. 45
Figure 67. Cloudant App ................................................................................................................ 46
Figure 68. IP associated to the user cluster ................................................................................... 46
Figure 69. General PLCnext/Cloud interaction schematic, sending data from the cloud to the
cloud Node-Red ............................................................................................................................. 47
Figure 70. Node-Red coding for receiving data from the cloud I................................................... 47
Figure 71. Node-Red coding for receiving data from the cloud II.................................................. 48
Figure 72. General data information on the cloud Node-Red Dashboard I ................................... 49
Figure 73. General data information on the cloud Node-Red Dashboard II .................................. 49
Figure 74. General PLCnext/Cloud interaction schematic, sending data from the cloud Node-Red
to the cloud .................................................................................................................................... 50
Figure 75. Remote order on the cloud Node-Red dashboard ....................................................... 50
Figure 76. Data inject visualization nodes ..................................................................................... 50
Figure 77. General PLCnext/Cloud interaction schematic, receiving data from the cloud onto the
PLCnext .......................................................................................................................................... 51
Figure 78. Data receiving node from the IoT Watson Platform ..................................................... 51
Page 1 of 57
1 INTRODUCTION
1.1 Context of Industry 4.0
Due to the actual requested requisites by the industry 4.0, the different production plants
and industrial processes are adopting changes in such a way that they can approach to the
demanded features.
For keeping in mind what changes should be made it would be recommended to make a
brief list of the different industry 4.0 requisites:
-
Internet of Things (IoT)
Cybersecurity
Cloud based systems
Machine to machine Communication (M2M)
Big Data
Advanced robotics
3D printing
…
Basically, these are features given by the digitalization and globalization that are being
requested by the industry and the market.
This is the reason why the implementation of this document has been considered
interesting, and, above all, the narration of the content that is being represented inside it.
It will be discussed how a few simple steps can be taken to resolve many of these points
and adapt an obsolete industrial process to the features requested by the industry 4.0 from
PLCnext technologies and a series of external software that will be commented throughout
this text.
1.2 PLCnext
Before starting to describe the objectives and content of this document, it would be
convenient to give a brief explanation of what PLCnext Technology is and the reason why
it has been used for this set of applications.
PLCnext technology is an integrated system for the industrial automation consisting of
open hardware, modular engineering software, a global community and free access to apps
based on this technology. In addition to the standard programming of PLC systems
according to the IEC 61131-3 standard, with PLCnext also enables a combination of other
programming languages such as C/C++, C#, MATLAB, Simulink, Node-Red, Python…
Page 2 of 57
Figure 1. PLCnext Technology diagram
That is why, thanks to the easy integration in the cloud due to the free access to Proficloud,
the possibility of using Open-Source Software and the constant evolution in the specialized
knowledge, it becomes an essential and extremely suitable tool for the implementation of
the features requested by the industry 4.0, making PLCnext the optimal environment for a
modern automation system.
In short, Phoenix Contact's PLCnext technology involves 5 essential things that make it
possible to cover and be prepared for all those requirements that Industry 4.0 implies.
1) PLCnext Control: Basically it includes all the different hardware parts involved in use
of a PLC: the controller (AXC 2152…), digital modules, analog modules… [this
doesn´t differ much from a typical PLC with the exception that it presents a more
open customization and direct interaction between the operator and the PLC,
because many of the PLC properties can be added, stored and modified, obviously
with certain security limitations.]
2) PLCnext Engineer: Free access software developing tool that would allow the user
to program and configure the PLC to achieve the desired operation.
3) PLCnext Store: This is the first common point between users and developers to
extend PLCnext functionalities.
4) PLCnext Community: Where users, developers and official Phoenix contact staff are
constantly in contact to help each other to develop the product and get to the point
where it is needed.
5) ProfiCloud: Easy access for users and companies to a cloud environment for Phoenix
Contact products.
Page 3 of 57
Figure 2. Functionalities provided by PLCnext Technology
Figure 3. Logo of the Proficloud platform by Phoenix Contact
A Phoenix Contact trainer equipped with an AXC F 2152 control system has been used for
the implementations carried out. To begin the implementations described in this
document, only the AXC F 2152 control module and access to the Internet connection are
required.
Figure 4. PLCnext trainer EDU AXC F 2152
Page 4 of 57
Figure 5. AXC F 2152 control module
1.3 Objectives and content
Once the actual characteristics required by modern industry and the power of PLCnext
technology to meet them have been introduced, the objectives to be achieved with this
technology in an industrial process can be listed and are set out in detail in this work:
1) Creation of an OPC UA server, integration and management of industrial process
variables from that server.
2) Node-Red installation on the controller, code creation and structure in order to
handle and analyse the process variables.
3) Introduction to the services that the cloud systems make available to the users.
4) Implementation of basic analysis process of an industrial process from the cloud.
Each chapter of this document develops the objectives outlined above. The chapters begin
with a description of the software and hardware tools used in each case. Based on these
descriptions, the step-by-step procedure to install and use them is detailed with
explanatory text and images.
The aim is to provide the user with enough information to test and verify the presented
functionalities. From this, each user can apply them to their own examples to meet the
required needs.
Finally, the references provided at the end of this document will offer complementary
information to help the user learn the concepts and technologies involved.
Page 5 of 57
1.4 About intellectual property
“OPC-UA, Node-RED and Cloud functionalities for PLCnext technology” © 2022 by Gabriel
Quintana Siñeriz and Felipe Mateos Martín (Automatic and System Engineering Area University of Oviedo) is licensed under CC BY-NC-SA 4.0. This work is a collaboration to
Erasmus+ Project “ETAT - Education & Training for Automation 4.0 in Thailand”.
Page 6 of 57
Page 7 of 57
2 OPC UA WITH UAEXPERT AS VERIFICATION CLIENT OF THE OPC
UA SERVER
2.1 Creation of a OPC UA Server in PLCnext Engineer
The verifications that have been carried out are:
Figure 6. PLCnext Engineer environment version
The creation of an OPC UA server in PLCnext is very simple. To achieve it, the following step
has to be followed:
1) Access to the OPC UA tab. An example of what the tab would look like can be seen in
Figure 7.
Page 8 of 57
Figure 7. OPC UA tab on PLCnext Engineer
2) The basic configuration of the OPC UA must be carried out, which consists of entering
the IP associated with the PLC, indicating the display of the variables as "Marked" and
the type of subscription as "Direct read" as shown in Figure 8.
Figure 8. OPC UA basis configuration on PLCnext Engineer 192.168.1.10
NOTE:
In this case the IP is 192.168.1.10 due to the fact that this is the IP obtained after the restart
of the PLC to its factory conditions. In the unit that is currently being used in the laboratory
of the EPI, the IP has been changed to 192.168.0.16 in order to have internet connection,
as shown in Figure 9.
Page 9 of 57
Figure 9. OPC UA basis configuration on PLCnext Engineer 192.168.0.16
3) In the rest of the tabs (Security, Discovery Server and File System) it is not necessary to
modify anything for the moment. In order to speed up the testing and configuration of
the whole system, in the tab referring to Security Policies, the only access requirement
to the server will be the user and password of the PLC. An example of the configuration
of the Security tab is shown in Figure 10.
Figure 10. OPC UA configuration PLCnext Engineer Security tab
4) Indication of the elements that have to be used on the server.
The introduction of local variables on the server has to be indicated in the PLCnext
environment tab, as shown in Figure 11.
Page 10 of 57
Figure 11. Declaration of local variables for the OPC UA server
For global variables, the tab configuration of the AXC F 2152 module has to be accessed
and proceed with the Data List as shown in Figure 12.
Figure 12.Declaration of global variables for the OPC UA server
Option
of the project tree in the Data List tab can also be used, with the advantage
that it maintains the view with the folder structuration of variables that has been done. A
graphical example of how to do this is shown in Figure 13.
Page 11 of 57
Figure 13. Declaration of variables for the OPC UA server alternate way
2.2 OPC UA data verification via UaExpert
The UaExpert of Unified Automation tool allows the quick verification, control and
visualization of the correct operation of the OPC UA server created in PLCnext.
The UaExpert tool can be downloaded from the following link:
https://www.unified-automation.com/downloads/opc-ua-clients.html
and subsequently installed on the PC.
Page 12 of 57
Figure 14. UaExpert install window
Once UaExpert is installed in the computer, the following steps have to be followed:
1) Open a window like the one shown in Figure 15.
Page 13 of 57
Figure 15. Opening window of UaExpert once installed
+
2) The icon “ ” has to be clicked in order to add a new server, as shown in Figure 16.
Figure 16. Adding a OPC UA server in UaExpert
Page 14 of 57
3) Double click on Custom Discovery in order to add a new server. A dialogue will indicate
to introduce the IP direction of the OPC UA server, as shown in Figure 17.
Figure 17. OPC UA server data being introduced in UaExpert I
4) After introducing the direction of the OPC UA server and click on OK, the following
sequence of clicks must be made:
opc.tcp://192.168.0.16:4840
 eUAServer@192.168.0.16
Aes256_Sha256_RsaPss – Sign (uatcp-uasc-uabinary)
(opc.tcp)
Then, on the bottom part it is possible to identify a user and the password of the PLC:
Username: admin
Click on store
Password: 7ab54609 (The password of the PLC).
Finally, the configuration is activated by clicking on OK as shown in Figure 18.

Page 15 of 57
Figure 18. OPC UA server data being introduced in UaExpert II
5) After following the above steps, the established server will appear in the Servers folders
of the project tree and it is possible to connect to it by clicking on the ( ) icon like is
shown in Figure 19.
Figure 19. OPC UA server data already introduced on UaExpert and connecting to it
Page 16 of 57
NOTE:
After connecting to the server, a window may appear asking if the server is trusted. You
must accept.
6) A window similar as the one shown in Figure 20 will appear, allowing access to all the
elements (variables) that previously were indicated to be used on the server.
Figure 20. Connection with the OPC UA server already established
Figure 21 shows an example of how the client would look like in UaExpert visualizing and
actuating on all the variables of interest.
Figure 21. Connection with the OPC UA server already established with all the necessary variables
To implement the coding in Node-Red it is interesting to have in mind the UaExpert tool to
identify the Nodeld of the attributes in a simple way, in order to use them in the assignment
of the correct variable in Node-Red. An example of a reference Nodeld can be seen in Figure
22 which is focused on the variable “Last_Finished_Order_A.Order.ID”
Page 17 of 57
Figure 22. Example of a Nodeld reference
To use this variable on Node-Red take the Nodeld referencing the variable type in the
following way:
ns=5;s=Arp.Plc.Eclr/Last_Finished_Order_A.Order.ID;datatype=Int32
This will be reflected in the following section of Node-Red in PLCnext in which the code will
be visualised.
Page 18 of 57
3 NODE-RED IN PLCNEXT
3.1 Installation of Node-Red in PLCnext AXC F 2152
There are different options to install Node-Red in PLCnext:
a) Manual installation using the access to the root folder of the PLCnext
b) Installation via commands with access to an internet connection
In this case the second option was chosen.
Before proceeding, it will be necessary to guarantee the access to two tools that are
essential to the realization of this process.
The first one is WinSCP, which allows the access to the PLCnext controller storage.
It can be downloaded from the following link:
https://winscp.net/eng/download.php
Figure 23 shows the used version.
Figure 23. WinSCP install window
The second tool is called Putty. In combination WinSCP it allows to introduce commands
to the PLCnext and proceed with the installation of Node-Red.
The Putty tool can be downloaded from the following link:
Page 19 of 57
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
The used version is shown in Figure 24.
Figure 24. PuTTY version used
Once the above-mentioned applications have been installed, proceed as follows:
1) Open WinSCP. The same IP address associated with the PLCnext and the credentials to
connect must be entered, as shown in Figure 25.
Figure 25. WinSCP connection to the PLCnext
Page 20 of 57
NOTE:
After clicking on “Connect”, two notifications that are security verifications will appear.
Simply accept.
2) On the right side of the WinSCP environment, the root folder of the PLCnext equipment
will appear, as shown in Figure 26.
Figure 26. WinSCP connection to the PLCnext already made
3) Execute Putty, in order to enter the necessary installation command in PLCnext. This
execution can be activated with the indicated icon ( ).
Page 21 of 57
Figure 27. Icon indication for accessing PuTTY once the connection to the PLCnext is made on WinSCP
Now the Putty session has to be open, appearing the window shown in Figure 28 for
identifying the user and the password of the PLCnext.
Figure 28. Opening window in PuTTY
4) After the identification, the command window will appear as in Figure 29.
Page 22 of 57
Figure 29. PuTTY once the identification has been done
Before proceeding, a user has to be created in the root of the PLCnext. To do that, the
following command has to be introduced:
sudo passwd root
It will ask to introduce a password. In this case the chosen password was the PLC password
followed by 2021: 7ab546092021
NOTE:
The cursor and the characters may not be seen due to security reasons.
Once the user is created in the root folder, proceed to the identification as shown:
su
7ab546092021
At this moment the command window will appear as shown in Figure 30, indicating that
now the access to the root directory of the PLCnext is granted and it is possible to continue
the installation.
Page 23 of 57
Figure 30. PuTTY window once the root user login has been done
Before doing anything else, it is necessary to check that the PLC has the correct
configuration to be able to connect to the internet. To do this, enter the following
command:
nano /etc/network/interfaces
It has to be verified that the window appears as in Figure 31, where the Gateway direction
192.168.0.99 corresponds to the Router that gives access to internet.
Figure 31. PLCnext internet access configuration
Page 24 of 57
After that, the following key combination has to pressed:
Ctrl + x
to go back to the previous command window with access to the root.
Figure 32. General PuTTY window once the root user login has been done
The following commands can be introduced to verify if there is internet connection:
ping 8.8.8.8
Ctrl + c
ping google.com
Ctrl + c
Ctrl+C is necessary for stopping the ping command.
Once the internet connection is verified, introduce the following commands to make the
Docker installation and initiate the container where the Node-Red will be placed.
git clone https://github.com/PLCnext/Docker_GettingStarted.git
cd Docker_GettingStarted
chmod -c 777 setup.sh
./setup.sh
Page 25 of 57
Following these steps, the permission will be requested in order to install Balena-engine or
Docker. First the Balena-Engine has to be installed and then the commands have to be
introduced again to install Docker.
It is possible to verify that it is correctly installed via command:
balena-engine version
Obtaining the screen information shown in Figure 33.
Figure 33. Version information of the balena engine installed on PLCnext
Finally, enter the following command to generate a container where Node-Red will be
placed and generate the OPC UA nodes.
docker run -it --restart unless-stopped -e GOOGLE_CLOUD_PROJECT = TFGplcnext
-p 1880:1880 --network=host --privileged -name =nodered nodered/node-red
If the previous command is not allowed, enter first the following command:
balena-engine run -it --restart unless-stopped -e GOOGLE_CLOUD_PROJECT =
TFGplcnext
-p 1880:1880 --network=host --privileged -name =nodered
nodered/node-red
If with the above command still fails to create the container with Node-Red, type:
balena-engine run -it -p 1880:1880 --name nodered --restart always pxcbe/nodered:opcua
Page 26 of 57
(View: https://www.plcnext-community.net/en/discussions-2-offcanvas/how-do-i-install-opcua-on-node-red-with-balena-engine.html)
3.2 Installation of Node-Red on the PC using Docker Desktop
It is very convenient to try any type of programming code in Node-Red without the use of
PLCnext.
In order to download the Docker Desktop, access the following link:
https://www.docker.com/products/docker-desktop
1) After downloading Docker Desktop from the above link, run the downloaded .exe
as any other Windows program and install it.
Figure 34. Docker desktop installer icon
2) During the installation process, a message of Close and Log out that will close the
session will appear.
3) When the session is open again, access to the Docker Desktop application installed
on the PC.
Page 27 of 57
Figure 35. Docker desktop application
4) Accessing Docker Desktop will install the last components necessary to complete
the Docker installation process on the PC. During this process the PC will reboot.
5) Finally, once the PC has rebooted, the Docker Desktop will be accessible and will
look as shown in Figure 36.
Figure 36. Docker desktop opening window
To verify that Docker is correctly installed on the PC:
1) Open the command window as shown in Figure 37:
Page 28 of 57
Win + R
cmd
Figure 37. Command window of the user PC
2) Write the following command on the command window (see Figure 38):
Docker version
Figure 38. Docker version verification
For the creation of a Docker container that contains Node-Red:
1) Open the command window shown in Figure 39.
Figure 39. Command window of the user PC
Page 29 of 57
2) Type the following command (see Figure 40):
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/nodered
Figure 40. Docker container creation
3) The container could be handled by the following method:

Attach the container to the command terminal of Windows:
docker attach mynodered

Restart the container:
docker start mynodered

Stop the container when required:
docker stop mynodered
See reference [1] at the end of this document.
3.3 Access to the Docker container of Node-Red on the computer
1) Open the browser and introduce the following direction:
127.0.0.1:1880
Page 30 of 57
Figure 41. Node-Red opening flow
IMPORTANT NOTE:
If, after completing the installation of Docker Desktop, it is not possible to start the
container or access the settings, this may be due to a missing update of the Windows
subsystem for Linux. This can be solved by doing a quick search on the network and
proceeding as indicated.
Page 31 of 57
3.4 Access and using of Node-Red in PLCnext
Once Node-Red has been installed on PLCnext, the access Node-Red will be as simple as
introducing on the browser the IP followed by :1880, due to the fact that this was the
chosen port for the Node-Red installation, as shown in Figure 42.
Figure 42. PLCnext Docker container access
Figure 43 shows a general view of the implemented program on PLCnext Node-Red.
Page 32 of 57
Figure 43. General view of the implemented code in PLCnext Node-Red
3.4.1 Flow for PLCnext OPC UA Root server visualization
The following program Flow is in charge of generating 4 reading clients and 1 writing client.
At the same time, a visualizer (Browser) of the OPC UA server Root has been implemented
with the goal that if there is no access to UaExpert all the data of the necessary attributes
for the Node-Red program implementation could be checked.
The visualizer is a very simple Flow (see Figure 44) that can be easily found with a quick
search on the browser.
Figure 44. OPC UA server root visualizer code
Once the visualizer is accessed, the content shown in Figure 45 and Figure 46 will be
displayed:
Page 33 of 57
Figure 45. OPC UA server root visualizer I
Figure 46. OPC UA server root visualizer II
The same Nodeld of the attribute obtained in UaExpert can be seen, so it is verified that
the visualizer works correctly and all the necessary information for the coding part can be
obtained without using external software like UaExpert. Nevertheless, it is highly
recommended using UaExpert due to the comfort and ease that contribute to handling and
visualizing the information in comparison with the visualizer implemented on Node-Red.
The variable configuration on Node-Red with the appropriate Nodeld will be obtained by
simply adding inject nodes. Those nodes allow to do events and assign the nodeld (like it
was previously indicated) on the topic of the inject node, as shown in Figure 47.
Page 34 of 57
Figure 47. Nodeld data introduction on Node-Red
IMPORTANT:
It has to be kept in mind that the OPA UA server of PLCnext only allows 5 clients connecting
simultaneously. In the case that more connections are required it would be interesting to
generate a coding program in which the client accesses to the server are intercalated. It
would be also possible to generate another OPC UA server inside the PLCnext or another
peripheral hardware (Raspberry Pi, Cloud, PC…). This can be a very interesting approach
because of the server configuration possibilities. This option will allow a much more
customised server configuration to suit the user, because the predefined PLCnext OPC UA
server has certain limitations that cannot be eluded.
Finally, the configuration of the read/write node is done as shown in the following
paragraph.
3.4.2 OPC UA Reading and writing client nodes configuration
For the reading nodes case, see Figure 48.
Page 35 of 57
Figure 48. Reading node on Node-Red
For writing nodes, see Figure 49.
Figure 49. Writing node on Node-Red
Page 36 of 57
3.4.3 Node-Red Dashboard creation
With the coding developed in Node-Red, a Dashboard was generated. It is accessible up to
local level of the PLCnext net with the introduction of the IP address of the PLC followed by
the port where the Node-Red is located and finishing with /ui like this:
192.168.0.16:1880/ui
To generate a visualization of this type, all that is necessary is to select any of the function
or inject nodes that return a variable and connect them to any visualization node (chart,
text, gauge…) as shown in Figure 50.
Figure 50. Visualization nodes
In this figure it can be appreciated that from a function node the temperature value is
injected to two visualization nodes. The node called Temperature is a chart type
visualization node, which will generate a chart with the temperature values and will add a
value will each timestamp. The node with the abc indicative is a visualization node that is
going to project the last temperature value received from PLCnext.
At the same time, data can also be sent from the Dashboard. It will only be necessary to
use the dashboard inject nodes. For example, the following case illustrates how a remote
order can be done. It will be as simple as taking a button visualization node and annex it to
a function node that generates a variable that can take a true or false value in function of
that an order was made or not. The general schematics of the code implemented in NodeRed can be observed in Figure 51.
Figure 51. Data inject visualization nodes
On the Dashboard generated on the Node-Red installed in the PLCnext at local level, the
following content is visualised:
1) General information of the process (Figure 52).
Page 37 of 57
Figure 52. General information Dashboard
2) Order information and indication if there is an order in progress (Figure 53, Figure
54).
Figure 53. Extended data of the order in the Dashboard I
Figure 54. Extended data of the order in the Dashboard II
3) Remote control of the plant (Figure 55).
Page 38 of 57
Figure 55. Remote order
Page 39 of 57
Page 40 of 57
4 IMPLEMENTATION OF FUNCTIONS ON THE CLOUD FOR DATA
ANALYSIS AND CONTROL
4.1 Introduction to the implemented Cloud System
After reviewing all the information directly related to PLCnext, it is convenient to comment
on the possibilities that are presented with all the OPC UA variables and the programming
implemented in Node-Red to process, analyse and manage the data for the control and
external drive of the plant.
To this end, it is interesting to briefly introduce the possibilities involved in the
incorporation of sending and storing data in the cloud, since with programming very similar
to that which will be discussed in this part of the document, it will be possible to use the
necessary data for different types of applications such as storing them in a database,
launching remote services, accessing monitoring in real time from anywhere in the world...
The general visualization of the schematics implemented for this application is displayed in
Figure 56.
Figure 56. General PLCnext/Cloud interaction schematic
PLCnext has its own Cloud service known as Proficloud.io, which allows the monitoring of
time series data free of charge. It is straightforward to use, as simple as marking in PLCnext
Engineer the variables to be monitored in the cloud. It is the same procedure that is
followed to add variables to the OPC UA server.
In this case it is more interesting to briefly illustrate how to implement a simple coding that
allows uploading data from the Node-Red to the cloud because in all cloud platforms
(Google Cloud, IBM, Azure, AWS...) it is implemented in a similar way. IBM Cloud was the
platform chosen for this coding because it allows a very fast and easy connection between
Page 41 of 57
the cloud and the device using the IBM Watson IoT Platform. In addition, it is a completely
free service provided by IBM.
4.2 General configuration of the IBM Cloud system
Figure 57. General PLCnext/Cloud interaction schematic, cloud part
Before any action can be taken, it will be necessary to create an IBM user account (this will
be the same for any cloud platform used). After creating that account and logging in it, a
list of resources that are available to use on the necessary elements (Watson IoT,
Kubernetes (cluster for Node-Red in the cloud)...) will appear. The list of resources used for
this application can be seen in Figure 58, Figure 59.
Figure 58. IBM cloud resources list I
Page 42 of 57
Figure 59. IBM cloud resources list II
Special attention should be paid to:
1) Internet of Things Platform-21q (Access to IBM Watson IoT Platform)
2) Node_Red_PLCnext (Cluster that contains Node-Red). This will allow us to create
the dashboard that will be accessible at any time will allow users to launch services
or different actions.
Once the account has been created, two steps will be necessary to incorporate the PLC data
into the cloud:
1) Node incorporation: node-red-contrib-ibm-watson-iot on the Node-Red installed
on PLCnext.
2) Creation of an organization associated with the user and the user’s device identifier
on the Watson platform as shown in Figure 60.
Figure 60. IBM IoT Platform
Page 43 of 57
In order to illustrate more easily how to follow these last two steps, this document can be
complemented with the video shown in reference [2] at the end of the document, in which
these steps are explained in detail.
4.3 Node-Red programming on PLCnext for sending data to the cloud
Figure 61. General PLCnext/Cloud interaction schematic, sending data from PLCnext to the cloud
After creating the above, the following programming must be carried out in order to
transmit the data from PLCnext to the device created on the Watson platform. The way to
collect the information in Node-Red to enter it in the cloud is shown in Figure 62.
Figure 62. Code visualization for injecting data to the cloud
Page 44 of 57
It should be noted that in order to send the data correctly to the cloud they must be in
JSON format. An example of how this step should be done can be seen in the already
mentioned video shown in reference [2].
Once the user is correctly connected to the cloud, it can be easily seen on the previous
Figure, on the exit node to the Watson IoT platform can be observed an indicative that the
user is connected. At the same time, it can also be verified on the same Watson platform,
due to the fact that when the device is connected it will also appear a connected indicative
next to the corresponding device.
The data transmitted to the platform has to be received as shown in Figure 63.
Figure 63. Data reception on the IoT Watson Platform
It is really easy visualizing this data on the platform, as a “Board” can be directly created on
the IBM Cloud platform (like the dashboard created in Node-Red) which will allow to
monitor all the information that the cloud is receiving, as shown in Figure 64, Figure 65.
Figure 64. Board created on the IoT Watson Platform I
Page 45 of 57
Figure 65. Board created on the IoT Watson Platform II
At this moment, the data is being monitored on the cloud.
4.4 Node-Red programming on IBM Cloud for data reception
Figure 66. General PLCnext/Cloud interaction schematic, cloud Node-Red
The next step is the already discussed of creating/installing Node-Red on the “cloud”
providing free access and allowing the implementation of coding to access services,
monitoring and acting on the data at any time and from anywhere without the need of
being in the local area where the PLC is located or under the same network.
This is as simple as following the steps outlined in reference [3] at the end of this document.
It is necessary to make a small note here and that is that the Cloudant service for setting
up the Node-Red is no longer a free service. In order to continue enjoying this service in a
Page 46 of 57
free war, when the app is created, Kubernetes must be selected, a service that will allow
the user to create a free cluster where Node-Red is going to be located and only by
introducing the IP associated with the Node_Red_PLCnext application that will allow access
to Node-Red in the same way as the Node-Red located in PLCnext. Access to this application
and the associated IP is shown in Figure 67, Figure 68.
Figure 67. Cloudant App
Figure 68. IP associated to the user cluster
After accessing the IP, the user will see the Node-Red, where the user can implement the
necessary code for monitoring and acting on the different services. In this case, a small
code has been developed to generate the visualisation of the data injected to the cloud
and the action on the remote launching of orders. The general scheme is shown in Figure
69.
Page 47 of 57
Figure 69. General PLCnext/Cloud interaction schematic, sending data from the cloud to the cloud Node-Red
The written code can be seen in Figure 70.
Figure 70. Node-Red coding for receiving data from the cloud I
As it can be seen, data must be taken from the cloud (remember that before data were
only sent). For this, a new node set must be installed (In the cloud Node-Red and in the
PLCnext Node-Red) called: node-red-contrib-scx-ibmiotapp which, by the generation of an
Page 48 of 57
API in IBM, will allow to take the inserted data in the cloud by the PLC part and visualizing
in the cloud Node-Red and vice versa (send data from the cloud Node-Red to the Watson
platform and use them on PLCnext Node-Red). The node is highlighted in Figure 71.
Figure 71. Node-Red coding for receiving data from the cloud II
This node will only take the data received in the cloud and allow to operate with them in
the “generated” Node-Red cloud, so that it will allow the user to generate a global-access
Dashboard. It has been the case implemented in this example in order to take the values
from the cloud and act on the functions that perform any type of operation on other device.
The implemented dashboard on the cloud Node-Red that can be seen in Figure 72, Figure
73.
Page 49 of 57
Figure 72. General data information on the cloud Node-Red Dashboard I
Figure 73. General data information on the cloud Node-Red Dashboard II
As can be seen, it is the same information that is being displayed in the Board generated in
the Watson platform and for its creation it is as simple as following all the same steps that
were previously explained for the Node-Red PLCnext Dashboard, with the only particularity
that any user can access this dashboard without the need to be under the same network in
which PLCnext is located. This Dashboard is directly accessible by entering the IP of the
application in the browser of choice (Address of the “container” generated in the cloud).
Page 50 of 57
4.5 Node-Red programming on IBM Cloud for sending data to the cloud
Figure 74. General PLCnext/Cloud interaction schematic, sending data from the cloud Node-Red to the cloud
In this case it has also been implemented the launching of a remote level order, not only
launching an order within PLCnext network, but also at the cloud level, meaning this having
access to place an order from anywhere without the need to be within the PLCnext
network. The code is the same that has been previously implemented and explained in this
document, and the Node-Red dashboard will be like the one shown in Figure 75.
Figure 75. Remote order on the cloud Node-Red dashboard
In this case, the only thing that has been resorted is the using of the visualization nodes
already introduced in this document like the ones shown in Figure 76.
Figure 76. Data inject visualization nodes
Page 51 of 57
4.6 Node-Red programming on PLCnext for data reception from the cloud
Figure 77. General PLCnext/Cloud interaction schematic, receiving data from the cloud onto the PLCnext
The procedure for reception of the data from the cloud in the locally installed Node-Red of
PLCnext is exactly the same as the one followed for the reception of data in the cloud NodeRed, but in this case, for the PLCnext Node-Red the distribution of nodes can be seen in
Figure 78.
Figure 78. Data receiving node from the IoT Watson Platform
Page 52 of 57
The node highlighted in the Figure is the reception node of IBM IoT Watson data, as
previously implemented in the cloud Node-Red for data reception. For this, as it was
generated for the cloud Node-Red and as already mentioned, it is necessary to install the
node set called: node-red-contrib-scx-ibmiotapp that will allow the user to have access to
the node signaled in red.
Page 53 of 57
Page 54 of 57
5 CONCLUSIONS
This document presents key aspects for the implementation of some functionalities proposed by
the new Industry 4.0 paradigm, allowing the creation and updating of machines, plants and
industrial processes.
Among the most important requirements are the internet of things, the cybersecurity, machine to
machine communication, cloud integration, big data… In order to adapt to these requirements,
various resources such as OPC UA, Node-Red, Cloud… have been used together with the innovative
PLCnext system from Phoenix Contact.
Step-by-step functionalities have been developed, ranging from the creation of an OPC UA server
and the installation of Node-Red on the Phoenix Contact AXC F 2152 module to the subsequent
integration in the cloud (IBM).
Information and a set of suitable examples have been presented in detail to enable the user to gain
a deeper understanding and application of Industry 4.0 functionalities, hoping that it will be of great
help.
Page 55 of 57
Page 56 of 57
6 REFERENCES
1) https://www.youtube.com/watch?v=6Rh2cuceK6g&t=78s&ab_channel=TheTechC
atalyst “How To Install Node Red in Docker”, channel: The Tech Catalyst
2) https://www.youtube.com/watch?v=U8sWT5CV2L4&ab_channel=RajvirSingh
“PLCnext Lesson 15 – Sending PLC values to IBM Cloud (2)”, channel: Rajvir Singh
3) https://www.youtube.com/watch?v=mGlEB-IExtI&ab_channel=RajvirSingh
“PLCnext Lesson 16 – Reading values from IBM Cloud into PLC (1)”, channel: Rajvir
Singh
Page 57 of 57
Download