Node-RED Nodes for the sysWORXX CTR-700
Use of I/Os directly from Node-RED with the IoT edge controller sysWORXX CTR-700.
The sysWORXX CTR-700 edge controller supports graphical programming in Node-RED in addition to classical programming languages such as C/C++, C#, Java and OpenPCS (according to IEC 61131-3). Using the nodes created by SYS TEC electronic, the inputs and outputs of the sysWORXX CTR-700 can be addressed directly from Node-RED. In addition, data exchange with OpenPCS, i.e. the IEC 61131-3 runtime, is supported on variable level. This allows, for example, to use a dashboard created in Node-RED as a GUI for the PLC program.
In addition, all other Node-RED functionalities are available to the PLC program. For example, data of a PLC program can easily be transferred to a Rest-based web interface via HTTP nodes, OPC-UA services can be used or weather data can easily be retrieved from the Internet.
What is Node-RED?
Node-RED is a graphical programming environment that uses nodes as program blocks. The program flow is exclusively done by processing and passing on messages and is therefore also called flow. The program flow results from the connection of the nodes by linking the output of a predecessor node with the input of a successor node.
The beginning of such a chain is always a node that generates a message based on a certain event. Such events can be, for example, the change of a digital input, the expiration of a timer, but also the receipt of a message from an external server - such as the arrival of an MQTT message. At the end of such a chain, there is always a node that triggers a specific action based on the received message. This includes setting a digital output or writing a value to a database. Between the start and end nodes of a flow there can be any number of other nodes that process the message received at the input and forward the result to the output.
Using the I/O nodes of the sysWORXX CTR-700
The I/O nodes allow direct access to the interfaces of the sysWORXX CTR-700. The following nodes and functions are available:
The following example describes in detail the principle way of using the I/O nodes. The configuration procedure is indicated by the numbering in text and picture.
Configuration of the I/O nodes
- One of the available channels must be selected. Besides the digital inputs 0 to 15, the relays 0 and 15 are available.
- It must be set on which edge a signal is triggered.
- The activation behavior can be adjusted as desired. By default, the node is set to High-Active.
- Finally, the topic to which the node reacts can be adjusted.
The configuration of the node for the digital output is similar:
- A channel must be selected. All 16 digital outputs are available.
- The initial state used after program start can be adjusted. By default it is set to inactive.
- The activation behavior, again High-Active by default, can be adjusted.
- The topic, on which the node reacts, can be adapted.
Program flow:
The following figure shows the example program. There you can see how a digital input is connected to an output.
If there is a "true" value at input DI0, output DO0 will also be set to "true" and the corresponding LED of the digital output will light up accordingly.
All I/O nodes are configured in a corresponding way and are individually adaptable. Likewise, any extension of the program is conceivable, such as inverting the input, interposing a logic, etc.
Access to OpenPCS variables with the IPC nodes
By the IPC nodes the access to the variables is possible, which are used by the OpenPCS:
- openpcs_read
- openpcs_write
The following example will explain how to use the nodes. Precondition: on the sysWORXX CTR-700 the program"Runlight" is executed. The corresponding project for this is included by default in the installation scope of OpenPCS (SYS TEC electronic Extension), which can be downloaded from the SYS TEC electronic website.
The Runlight program writes a variable group to the digital outputs of the sysWORXX CTR-700. Three of the variables in it are always "high", depending on the state of the program. In regular intervals the variable group is "shifted" by one position. This is how the running light is created.
Via the Node-RED of the sysWORXX CTR-700 a variable, which is used in the OpenPCS program, can now be retrieved via the IPC nodes. For this the"openpcs read" nodeis used and the variable path is entered there accordingly. This is composed of the program name and the function block in which the variable is used. In the following example the name is"RUNLIGHT.BLEDGROUP0". The variable indicates the constantly changing status of the running light LEDs.
The variable is read after each cycle. The topic can be defined arbitrarily. In the picture below a simple flow is shown, which fulfills the described function. The debug node is only used to visualize the data flow.
At a remote station an application is needed to evaluate this data. Here, Node-RED on a local PC is used again - in principle, any software that supports MQTT can be used.
For the next step a MQTT node is used, which subscribes to the corresponding topic, which was set on the sysWORXX CTR-700. A simple converter translates the chaser position into a numerical value, here 0 to 7, and transfers it to a slider node.
The slider node is part of the Node-RED package"node-red-dashboard"and can be installed as described above.
This node behaves within defined limits like the chaser on the sysWORXX CTR-700. In the dashboard the slider button moves one position further with every move of the chaser and starts again from the beginning when the end is reached.
Unlimited application possibilities
Our simple example applications are intended to illustrate what the nodes for the sysWORXX CTR-700 can do in principle. In a real application, instead of a running light, the level of a liquid container or the status of a machine traffic light can be integrated, for example. The visualization can be realized by a graph (available in the dashboard). The control of inputs and outputs can also be extended as desired. With Node-RED, visualization - even of the PLC - can thus be generated without much effort and without having to rely on additional licenses or cloud connections. Essentially, there are hardly any limits to the possibilities and freedom of implementation.
In addition, many other freely available standard nodes can be integrated. The following nodes were tested in particular together with the sysWORXX CTR-700:
Installation and update of the nodes
The libraries of the nodes are hosted on GitHub and can, in case of an update or subsequent installation, be conveniently installed directly via the palette manager integrated in Node-RED:
- Open the menu at the top right of the user interface (three horizontal stripes).
- Select the menu item "Manage Palette" and its sub-item"Install".
- In the search field you can search for the node packages.
The following libraries are available especially for the sysWORXX CTR-700:
- "node-red-contrib-ctr700-io".
Provides access to the inputs and outputs of the sysWORXX CTR-700.
- "node-red-contrib-ctr700-ipc"
Allows data exchange between OpenPCS and Node-RED.