PLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

 

 How to create a Blog Entry

In the previous months I prepared the PLCnext Technology exhibition wall for the showroom in our Polish Phoenix Contact subsidiary and I would like to show it to the community. 
I made the applications with as many technologies as I was able to, that's why I used MQTT, OPC UA, Node-RED, Google Home etc.

These four example tasks can be demonstrated:

  1. LEDs lighting up after activating the PLC's input 0
  2. Voice message about changing the state of the switches connected to the PLC's inputs
  3. Command "Hey Google, blink" causes the LEDs on the panel to change for a moment to the opposite state and return to their original state
  4. Command "Hey Google, check the state" causes that you can hear a summary of the current state of the PLC's inputs

Python is a powerful language with plenty of applications for Industrie 4.0, including Machine Learning and Cloud connectivity, so it’s a natural fit for applications that use PLCnext Technology.

In this episode of Automation Maker, we look at how to install Python and PIP on a PLCnext Control.

Helpful links:

just click the "Read more..." link below the video. 

More information on the IIoT OPC UA node package:

Command to install the IIoT OPC UA node package:

npm install -g node-red-contrib-iiot-opcua

Thank you to PLCnext Community members David Petter and Stefan Brinkmann, and to Klaus Landsdorf from Bianco Royal, for their valuable contributions.

Note: We show the engineering part in this video using a beta version of the upcoming PLCnext Engineer software by Phoenix Contact that will be available soon and for free. Until then, the procedure should work using the current PC Worx Engineer version as well. If you encounter any problems, please let us know.

The flow used in this example is represented by the following JSON (press "Read more" to see it). It can be imported straight into the editor by pasting the JSON into the Import dialog (Ctrl-I or via the dropdown menu).

=== UPDATE ====

The recommended way to install node.js and npm on a PLCnext Control is now through the PLCnext Store.

It appears that the procedure described below may not work after installing node from the PLCnext Store. In this case, an alternative to pm2 may be needed to automatically start node-red. You can raise general issues related to pm2 on their Github page.

The original article remains below.


Procedure

Log in to the PLC as admin and issue the following commands:

npm install -g pm2
pm2 start node-red
pm2 save
pm2 startup

Restart the PLC and check that Node-RED has started automatically.

Thank you to PLCnext Community member David Petter for these instructions.

More information on starting Node-RED using pm2 can be found here: https://nodered.org/docs/getting-started/running

=== UPDATE ====

The recommended way to install node.js and npm on a PLCnext Control is now through the PLCnext Store.

The original article remains below.


If you want to run the popular Node.js framework on your PLCnext Control, you can download the binary for ARMv7 from the node website and install it manually on the PLC.

A previous blog entry described an easier way to install Node on an AXC F 2152 PLC using the ipkg package manager. However this installs a relatively old version of node, which might not be suitable for all applications.

Another way to install the latest version of node - or even multiple versions - is to use Node Version Manager. NVM can be installed and used by the PLC's admin user, without root privileges. Here's how:

=== UPDATE ====

The recommended way to install node.js and npm is now through the PLCnext Store.

After installing node.js from the Store, log in to the PLC as "admin" and proceed with node-red installation using npm.

Useful links:

Sample flow on the Node-RED website

Commands to install Node-RED:

ipkg install node (install node.js from the PLCnext Store)
npm install -g node-red

Note: The errors seen during Node-RED installation relate to the optional bcrypt package.
To avoid these errors, install gcc, make, and python 2, before installing Node-RED:

ipkg install gcc
ipkg install make
ipkg install python27
npm install -g node-red --python=python2 --unsafe-perm

Page 6 of 8