8/9/2021 4:57 PM | |||||||||||
Posts: 3 Rating: (6) |
This project realizes an interface between Node-RED and PROFINET. It consists of an interface between PROFINET and Node.js and an interface for Node-RED. Using this interface, response times below 50 ms can be achieved. The project is published in source code only and must therefore be compiled before it can be used. After the compiling and installation process, PROFINET IO devices can easily be used in Node-RED. Installation of the RT-Image and PN Driver Before the addon can be used on an IOT2040, the realtime image must be set up. It can be obtained on the same page as the PN Driver (SIOS). The image must be flashed and the IOT needs to be set up. The next step is to copy the driver kernel object/module on the IOT. The file PNDevDrv_32.ko must be copied from PN_Driver_IOT2000_V2.4.0\PN_Driver_IOT2000\ko\ to the folder /usr/src/ on the IOT. A symlink to this file must be created from the modules folder. Also the modprobe-files need to be updated using depmod. On the RT-Image V2.4 this can be done with the following command:
As this module should be loaded on every startup, an udev-rules file must be copied to the IOT. The file pndev.rules can be found in PN_Driver_IOT2000_V2.4.0\PN_Driver_IOT2000\ko\ and must be copied to /etc/udev/rules.d/. After a reboot, the network interface X2 P1 (/dev/eth1) can only be used by the PN Driver, so no ssh connection is possible anymore using this interface. Prerequirements for Compiling GNU MakeMake sure you have GNU Make installed. This can be tested with the command make in a terminal. GNU Make for Windows can be obtained on multiple sources. MSYS2 is an project, which ports Linux tools to Windows. Follow the steps on the msys2 Homepage for installing and updating the base environment. Make can then be installed in the MSYS2 console with the following commands:
The last step is adding the directory containing make to the
If the installation was successful, running make in a normal console (cmd) should now work. Downloading IOT2040 SDKThe SDK can be downloaded in SIOS. Only the SDK is needed, the Eclipse plugin is optional. The extracted folder containing sysroots will be called SDKROOT. Downloading the PN DriverThe driver (and headers, shared objects, ...) can be downloaded in SIOS. For the compiling of this project only the driver zip is needed. Two folders need to be prepared:
This folder should contain the static library libpndriver.a of the zip file. This file can be found in ...\PN_Driver_IOT2000\test_app_bin. The file PnDev_DriverU32.so is not needed for compilation, but will later be needed to run the program. Download NAN (Native Abstractions for Node.js)As the name suggests, this library is needed for creating an addon to Node.js. It can be downloaded on GitHub or installed using npm. The folder containing the headers will be needed for compilation and will be called NAN_H. Compiling the addon Setup environment vars for compilingThis project can be compiled in a console or an IDE like eclipse. In both the environment vars need to be set. In the cmd, vars can be set using SET <varname>=<value>. Linux users can set these using
or if you want to immediately start a program like make:
Environment vars can also be set in the eclipse preferences (Window > Preferences > C/C++ > Build > Environment). The following vars need to be set:
Compiling The last step is to extract the contents of the file ProfinetNodeAddon.zip and run make inside the extracted folder. This should compile the program without errors. At the end of the compilation process, the file build\default\addon.node should exist. Building and installing the npm module The contents of the npm-package.zip must be extracted to a folder on the IOT. Also copy the file addon.node and PnDev_DriverU32.so in this directory. The folder should now contain the following files:
If the folder ~/.node-red/ does not already exist, create it using:
Change the directory and install the package using:
Add and modify autostart of Node-RED In the iot200setup tool the autostart can be activated in Software > Manage Autostart Options > Auto Start node-red. This creates the file /etc/init.d/launch_node-red.sh. The content of this file must be changed in order to enable the use of the addon. This can be done using nano:
Change the content to:
The path after cd must match the installation path of the npm module. The PROFINET Driver needs this in order to find PnDev_DriverU32.so. After a reboot the interface can be used. Usage Creating a TIA Project The PN Driver needs a configuration file, which can easily be created in TIA. Create a new project and add the "device" "PROFINET Driver V2.1". In this device, add the Interface submodule "IOT20x0" (V2.1). After this step, other devices can be added and the configuration can be changed like any normal PLC project. The configuration can then be exported using the compile button. Adding nodes in Node-RED Open the Node-RED UI in a browser (http://<IP-Address>:1880). The new category profinet should be in the palette. In order to use inputs and outputs, the interface must first be configured. Add an "PN connection configuration" node to the flow and edit its configuration. The file upload button must be used to upload the configuration created within TIA. This xml-file can be found in the subdirectory AdditionalFiles\PNDriver\ of the TIA project folder. In order to connect (equals RUN-Mode), true must be sent to the "PN connection configuration" node. To disconnect (equals STOP-Mode), false must be sent. In- and outputs can be used with the configured addresses. The datatype Boolean uses a Boolean and datatypes up to DWord use Number. As a LWord exceeds the storage of a Number, a string of digits is used instead. AttachmentSourceCode.zip (785 Downloads) |
||||||||||
Last edited by: root@IOT at: 08/09/2021 16:58:28Last edited by: root@IOT at: 08/10/2021 08:59:01Last edited by: root@IOT at: 08/16/2021 10:48:02More detailed description; added missing depmod -a part. |
|||||||||||
This contribution was helpful to5 thankful Users |
Follow us on