Makers Blog

Getting the most out of PLCnext Engineer Simulation: Connecting to Node-RED via REST

sreyes 19 July 2022 min. read
875 views 0 comments

Hello Community!

When we meet with PLCnext Technology, as developers we can’t wait to try its functionalities 😊 So, with the great milestone of New PLCnext Engineer Simulation and inspired by this article Node-RED communication with an AXC using the PLCnext Connector now we can interact from our simulation environment with Node-RED, and in this way, test IoT functionalities before we have the hardware on the table.

Installing Node-RED on Windows 10

Node-RED can run on multiple platforms, it's a very lightweight visual programming tool that we can install in our PLCnext controllers (on a Docker container for example) and also in a PC. For this demo, follow the installation steps for Windows 10 in this guide. After that, you can run the application using the cmd tool or PowerShell with the command node-red.

Once it's running, just type in your favorite web browser the the URL http://localhost:1880.

Downloading Node-RED connector for PLCnext

The following article show us how to download and use a node to connect our PLC variables in PLCnext Engineer with Node-RED via REST, you can found more information in the npm repo. So, in this step you only have to search the node in the Manage Palette and install it:

Imagen1.png

Configuring PLCnext Engineer Project

You need to install the Firmware image for AXC F 1152 from the Phoenix Contact website and the software PLCnext Engineer >= 2022 version to use the Simulation environment.

  1. Create a project for that controller, go to the Cockpit area and then change the connection to “Simulation”.
Imagen2.png
  1. Choose the program variables that you want to share with Node-RED checking the “HMI” box.
Imagen3.png
  1. Go to the Plant area and double click on HMI Web Server. Enable REST interface checkbox.
Imagen4.png

That’s all! Connect and download the project to your simulation environment. Remember that the credentials are “admin” as user and “plcnext” as password.

Check connection in Node-RED

You can try a “plc-browse-items” node to add the PLCnext connection. You have to use the same credentials and enter in Host IP the URL “localhost:5050”.

Imagen5.png

Deploy your code and voilà! Your connection is ready to read and write your PLCnext program variables in your favorite 61131-3 language 😉

Imagen6.png

If you want to know more about REST data interface, you can visit the Info Center.

Happy code!

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users