Arduino DMX master using RS485 click board

13

In this project, I will show how to implement a DMX master controller using one Arduino Uno, and one MikroElektronika Uno Click shield hosting one RS-485 click board. This project allows up to 32 devices to be connected to the same DMX bus, including the master controller, so up to 31 slave devices can be used. The number of DMX channels is up to 512, but due to memory space restrictions you may wish to use a limited set of channels.

The RS-485 click board features a half-duplex SN75176 IC (which is basically an MAX485 clone). This is a non-isolated DMX transceiver, so there is no galvanic isolation between the master device and the rest of DMX devices. Two unwanted issues here: this allows for ground loops to exist, so a current path can be established from a DMX slave device through the RS485 transceiver and then through Arduino and the USB cable connected to a computer or a laptop. If there’s a defective device and you have such a ground loop, you can damage all the equipment, including the computer. Second, lack of galvanic insulation can allow the live mains voltage to leak from a defective device through the DMX cable and into the Arduino and the connected PC. Another issue is that when used outdoor, especially with a long DMX bus, hazardous voltages can appear on the DMX bus during electric storms. So, it’s best to use this project only indoors.

Arduino DMX master controller

Arduino DMX master controller

While there’s a low statistics for this to happen, the lack of galvanic isolation creates a potentially life-threatening situation, so please take all the appropriate safety measures when working with this project. Don’t touch any of the exposed circuits. Use battery power if possible. Better safe than sorry.

if you plan to do some serious projects starting from this article, then I strongly recommend the use of a DMX isolator, such as this one, or the use of an isolated DMX shield (more about this in a future article).

Close view of the RS485 click board

Close view of the RS485 click board

The main element on the RS-485 click board is the RS-485 transceiver, which is configured to work in half-duplex mode. You can either transmit or receive, the selection between these modes being made through the R/T signal, which corresponds to the PWM pin of the RS-485 click board. When using the Click shield, if the RS-485 click is inserted into slot #1, the PWM pin is connected to Arduino pin D5. If the slot #2 is used, the selection between emitting or receiving is made through Arduino pin D6.

Three jumpers are present on the RS-485 click. If our project is connected to one end of the DMX bus, which is the most frequent situation, all three jumpers must be closed. However, the DMX master can take any position of the DMX bus. If the master is somewhere in the middle of the bus, remove all three jumpers.

Schematic of the DMX master node

Schematic of the DMX master node.

By the RS-485 standard (inherited by DMX), there must be also a proper termination of the other end of the DMX bus. So, a terminator comprising of a 120-ohm resistor mounted inside an XLR connector was plugged in.

DMX terminator

DMX terminator

The light fixture used for testing is a Eurolite T-36 LED DMX Par, which uses five DMX channels, as follows:

CH1: Red (0:100%)
CH2: Blue (0:100%)
CH3: Green (0:100%)
CH4: Brightness (0:100%)
CH5: Flash (0:10 – no flash; 11:255 flash 0:100%)

The switches on the back of the T-36 were configured for DMX operation, channel range 1:5.

Arduino DMX project connected to a PAR36 DMX from Eurolite

Arduino DMX project connected to a T-36 DMX from Eurolite

As for the software, I used the Conceptinetics DMX library. The following is a code example for this light fixture, which turns on each color for about 3 seconds, then turns off all lights, followed by a dimming of the red channel from 0 to 100%:

 

And finally, a picture of the working project:

Working DMX project

Working DMX project

Share.

13 Comments

  1. Thank you for the code. Helped me a lot. I have only the problem that “fade in” is not working:

    // Keep fading channel 2 in from 0 to 100%
    for (int dimmer_val = 1; dimmer_val >= 255; dimmer_val++) {
    dmx_master.setChannelValue ( 2, dimmer_val);
    delay(100); // from 0 to 100% in about 2.5 seconds
    }
    Any idea?

    • Hi!

      Is your slave device dimmable? Maybe you can’t fade it at all. Or maybe it has a separate DMX channel for fading. Could you please tell me which DMX slave device are you using?

  2. Teodor, thanks for your answer.
    “Fate out” is working, but not “fate in ”
    Its a cheep device found on ebay. MXS-019
    The description says:
    CH1: Flash (0 – off, 1-127 – flash slow-fast, 128-255 Light brightness)
    CH2: red 0-255
    CH3: green 0-255
    CH4: blue 0-255

    I put this code in:

    // the loop routine runs over and over again forever:
    void loop()
    {
    static int dimmer_val;
    // Keep fading channel 2 in from 0 to 100%
    for (int dimmer_val = 1; dimmer_val >= 255; dimmer_val++) {
    dmx_master.setChannelValue ( 2, dimmer_val);
    delay(100); // from 0 to 100% in about 2.5 seconds
    }
    // Now dimming channel 2 in from 100% to 0
    for (int dimmer_val = 254; dimmer_val >= 1; dimmer_val–) {
    dmx_master.setChannelValue ( 2, dimmer_val);
    delay(100); // from 0 to 100% in about 2.5 seconds
    }

    • Hi,

      Please change

      // Now dimming channel 2 in from 100% to 0
      for (int dimmer_val = 254; dimmer_val >= 1; dimmer_val–) {

      to

      It also looks that CH1 is used for dimming, by setting values from 128 to 255. The fade code in this case should be be:

  3. now i have an error on this line (exit status 1 stray ‘342’ in program):
    for (int dimmer_val = 254; dimmer_val >= 1; dimmer_val–-) {

    /*
    Example code for using the Conceptinetics DMX library with RS485 click board from Mikroelectronika
    DMX PAR is a MXS-019
    https://electronza.com/arduino-dmx-master-and-slave/
    CH1: Flash (0 – off, 1-127 – flash slow-fast, 128-255 Light brightness)
    CH2: red 0-255
    CH3: green 0-255
    CH4: blue 0-255

    Ver.1.0, 7 July 2015
    http://microcontroller-projects.com

    Based on:
    Conceptinetics DMX library,
    Copyright (c) 2013 W.A. van der Meeren . All right reserved.
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 3 of the License, or (at your option) any later version.
    http://sourceforge.net/projects/dmxlibraryforar/files/
    */

    // Be sure to download and install the library files 🙂
    #include

    // The master will control 4 Channels (1-4)
    //
    // depending on the ammount of memory you have free you can choose
    // to enlarge or schrink the ammount of channels (minimum is 1)
    //
    #define DMX_MASTER_CHANNELS 4

    //
    // Pin number to change read or write mode on the shield
    // Need to be 5 if slot#1 is used, or 6 if using slot #2
    // The switch on Click Shieeld should be set on Prog when programming the code,
    // and on URAT
    //
    #define RXEN_PIN 2

    // Configure a DMX master controller, the master controller
    // will use the RXEN_PIN to control its write operation
    // on the bus
    DMX_Master dmx_master ( DMX_MASTER_CHANNELS, RXEN_PIN );

    // the setup routine runs once when you press reset:
    void setup() {

    }

    // the loop routine runs over and over again forever:
    void loop()
    {

    // Enable DMX master interface and start transmitting
    dmx_master.enable ();

    // I have to set first the dimmer channel to 100%
    dmx_master.setChannelValue (1 , 255);
    //dmx_master.setChannelValue (16 , 255);
    //Scheinwerfer 1

    static int dimmer_val;
    // Keep fading channel 2 in from 0 to 100%
    for (int dimmer_val = 1; dimmer_val >= 255; dimmer_val++) {
    dmx_master.setChannelValue ( 2, dimmer_val);
    delay(100); // from 0 to 100% in about 2.5 seconds
    }
    // Now dimming channel 2 in from 100% to 0
    for (int dimmer_val = 254; dimmer_val >= 1; dimmer_val–-) {
    dmx_master.setChannelValue ( 2, dimmer_val);
    delay(100); // from 0 to 100% in about 2.5 seconds
    }

  4. Thanks Teodor, i typed it manually and the error is gone, like bevor it doesn’t fade in… doesn’t matter…
    Im trying to write an easy Light-sequence for one Song and to make it a bit easyer, do you have an idea where i can look for some information or about what therm i have to search if i want to define for example red light is:
    // red;
    dmx_master.setChannelValue (2 , 255);
    dmx_master.setChannelValue (3 , 0);
    dmx_master.setChannelValue (4 , 0);

    and the n in the loop i write only (the color i want and after how many milliseconds from starting the arduino it should end) for example:
    red(15534);
    blue(23374);
    red(35534);
    blue(43374);

    • Have you tried to use CH1 for dimming, as in the code below?

    • If you wish to synchronize music and light then you need some form of DMX scripting. Unfortunately, you will have to write your own functions to do this.

      I have something like this as a future plan, but I don’t know how soon I will manage to publish the code…

  5. I need only some 20 or 30 Light changes and for this it would be easier to define only once:
    red equals:
    dmx_master.setChannelValue (2 , 255);
    dmx_master.setChannelValue (3 , 0);
    dmx_master.setChannelValue (4 , 0);

    and then I write only.

    red(how many milliseconds)

    But i don´t know what therm (maybe variables) to search for…

    • You can take a look at my DMX master and slave code https://electronza.com/arduino-dmx-master-and-slave/

      If you only need 20 or 30 changes you can do it like

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.