Some time ago I wrote about implementing a DMX master controller using Arduino Uno and MikroElektronika RS-485 click board. Today I will show how to implement a slave DMX node, also based on Arduino and MikroElektronika click boards.
The required hardware is:
3 pcs. Arduino Uno (or any other 5V-based Arduino clone).
3 pcs. Arduino Uno Click Shield
3 pcs. RS-485 click boards
2 pcs. 4×4 RGB click boards
As in many other cases, the hardware is extremely simple to implement: just stick the Arduino Uno click shield on top of the Arduino Uno. Install the RS-485 click boards into slot#1 of the Click Shield. Install the 4×4 RGB clicks into slot #2 of the slave DMX boards.
The only thing that requires some care is setting the correct jumper position of the RS-485 click boards: on the master DMX node all jumpers are connected. This setting activates DMX bus terminator and also applies some bias on the RS-485 lines. Biasing has the role in providing a differential voltage to the DMX in idle state so the receivers are held in a known logic state. You can read more about the role of RS-485 / DMX biasing here.
— on the slave node(s) located on in the middle of the DMX bus all jumpers are disconnected.
— on the slave node on the opposite end of the DMX bus only the terminator jumper is connected.
The pictures below show the jumper configuration for all DMX nodes:
To connect the DMX nodes I used Cat5 UTP cable. The wire colors are those recommended by the Electronic Theatre Controls on their DMX-over-Cat5 page: white/orange is for Data+, orange is for Data- and both brown and white/brown wired are connected to the ground terminal. All other data pairs on the UTP cable remain unused.
The code for the DMX master node is largely based on the Conceptinetics DMX library, which I found to be the code library the that works the best with the RS-485 click boards. So, please install this code library first. The same code library is used by the slave nodes. Also, the slave nodes require the Adafruit Neopixel library to be installed. So, as a prerequisite download and install these two code libraries.
Arduino code for DMX master node
Implementation of the code for the master node is explained in detail on my previous post. Here I post only the code for the current project:
Arduino code for DMX slave node
In this project, I decided to keep the DMX nodes as simple as possible, and I designed the two nodes to run the same program. Also I have designed the code so all the LED’s on the same node show the same color — just like an architectural light or a PAR projector — as this makes the code easier to understand.
The above code requires both Neopixel and Conceptinetics libraries to be installed. As recommended by MikroElektronika, this project is designed to drive the LED’s at a fraction of their maximum possible output in order to avoid overheating. The maximum LED level is controlled by the variable MAXLEVEL, which was set at a value of 150 (of the maximum 255).
In the initialization part of the code, some pin attributions are made to match the hardware. The pin that controls if the RS-485 click is set to transmit or receive setting is pin 6. RX and TX pins are pins 1 and 2 of Arduino Uno. As you may already know from other projects, these are pins used also by the FTDI chip responsible for programming. Thus, both master and slave nodes the switch on the Arduino Uno Click shield MUST be placed in PROG position when programming, and on UART position when running on DMX mode. There is no serial monitor available.
Also on the initialization phase we define pin A2 (imposed by hardware) as data pin for the NeoPixels, and we define the number of NeoPixels as 16.
After all the pins are defined we initialize the DMX and the Neopixel libraries.
The most interesting part of the code happens within the OnFrameReceiveComplete function. This function enables us to execute time-sensitive code, as is the case with the Neopixels. So, as a DMS frame is received, the values received are first mapped to match the maximum intensity we previously set, then the new data is sent to the NeoPixels.
That’s all for this code example.
- Each slave node can be set to its own channels, so the slaves will display different color combinations
— Each NeoPixel can be driven independently, a number of three DMX channels being necessary (RGB). Increasing the number of channels will increase the CPU load. At some point, there might even arise the need to switch to a more capable board.
— The code for the master node becomes huge when implementing a larger number of DMX effects, especially when using transitions and fades. I’m working towards an advanced code for the master, using a DMX script stored on SD card.
Originally published at https://electronza.com on November 2, 2015. Moved to Medium on May 5, 2020.