During a visit to IBMs Client Center in Hursley, UK I first familiarised myself with Node-RED, and I became quickly attracted to this practical platform so helpful in experimenting with new ideas and implementing them as fast working prototypes.
Later on, when preparing for the Euroshop 2017, where we really wanted to put up a show, I went for an excursion to Fellesverket Dragen where I came up with the idea about using DMX lights and moving heads connected to Node-RED and the Gunnebo Business Solution.
In today’s post, I would like to talk about a Node-RED node that lets us take control over stage lighting equipment, such as LED lighting units, (LED) Par Cans, moving heads and so on, in general – any fixture with DMX512 protocol support. I have chosen Art-Net (simple DMX512-A implementation) for transmitting lighting data over Ethernet.
Node-RED is a NodeJS based visual tool that allows you quickly build your own applications by composing data flows via a series of connected nodes. It is a flow-based programming environment, so any data processing or connecting to services or devices requires access to a “node” that provides the functionality you need.
To get started, you’ll need an installation of Node-RED. If you already have NodeJS on your machine, you can easily install Node-RED via Node Package Manager from a terminal:
$ sudo npm install –g nodered
If you don’t have NodeJS yet, you can download the installer directly from the NodeJS website.
In order to launch Node-RED web interface just run:
and launch http://localhost:1880 in your browser.
Figure 1. Node-RED Web UI is served by default at port 1880
There are a few simple steps to compose and run application flow:
- Select some nodes from the left palette and drag them onto the workspace canvas.
- Connect the nodes together by dragging between the output port of the one to the input port of the other. This is allows them to pass data and interact with each other.
- Click the Deploy button at the top.
Node-RED comes with a basic set of nodes, however there are more out there and you can write your own! Since there is no Art-Net package out of the box in Node-RED, I decided to create some and contribute to a community.
Note: To be honest, when we started working on the node, there had already been two similar nodes in the library (node-red-node-artnet and node-red-contrib-ola), but, unfortunately, they both don’t meet all my requirements.
So, the initial requirements to node-red-contrib-artnet node were:
- Convenient API to set single/multiple DMX channel values (already implemented in node-red-node-artnet)
- Set linear transition for single/multiple channel (already implemented in node-red-contrib-ola)
- Set arc transition for multiple channel (to support moving heads movements by arc) (implemented only in node-red-contrib-artnet)
And tet’s take a quick look at the node itself. It uses single dependency on artnet-node module in order to compose and send data as ArtDMX packets – the developers made a few small fixes to original version so that one can run it on Node v.5+.
Our node-red-contrib-artnet node uses global context to store channel’s state. It was implemented in such a way because of a requirement to control DMX state from different flows. In other words, we can use multiple nodes in separate flows to share one endpoint and control single stage from separate flows.
The other possible solution is to use “link in/out” built-in Node-RED nodes to connect flows together and share single node-red-contrib-artnet node globally across the canvas.
Quite complex and interesting constituent is arc transition implementation. The most obvious application of this feature is by getting control on tilt/pan channel for moving head fixture and making it move in an arc. You can find a detailed description here.
Another significant feature, implemented in node-red-contrib-artnet, is protecting from concurrent switching to the same channels when performing transitions: when we start a new transition on channels already involved in another transition, the old one is immediately canceled.
node-red-contrib-artnet provides simple API for a different kind of DMX channel manipulation including batch handling and simultaneous linear/arc transitions.
Figure 2 illustrates a simple flow aimed at controlling consistent fading of 3 DMX lamps with node-red-contrib-artnet and node-red-contrib-prolights.
Figure 2. Art-Net simple flow
On this video you can find an example of an arc movement, performed by Prolights PIXIEWASH and controlled via Node-RED:
node-red-contrib-artnet is published under MIT license. Please use links for source code and npm package below.
Node-RED is a rapidly growing tool helpful in bringing your ideas to life, for example, when building a prototype or event-processing engine. It’s also easy to extend it with your custom nodes as shown above. Feel free to experiment, create useful nodes and flows to contribute to Node-RED community!