Yesterday night I hacked together a quick and dirty Arduino MIDI-to-DMX control for our robot band Science Fiction Children . It’s really simple! And here’s how I did it.

Goal:

I have two really cheap LED Par56 from Stairville (DMX controlled), a simple DMX-Dimmer pack and use Ableton Live for our sound setup. So all I want is to control the different colors and dimmer channels (DMX channels) with each one Midi-Note. The pitch (note) shall represent the channel, the midi velocity shall represent the actual DMX-value (brightness).

DMX-protocol

Some words about the DMX protocol: This is a really simple serial protocol, the connectors are 3-pole XLR and yep – you can use normal audio XLR-cables. The devices (my LED-Par for example) are connected in a chain. Each device can have one or more channels, there are up to 255 channels per chain possible. Let’s have a look at a standard LED PAR56 channel setup:
DMX-LED-PAR Channels

So all we have to do is to send something from “0 to 63” to “channel 1” to set the device to RGB Mode and then the brightness value (0..255) to channel “1..3“ for the brightness of the different colors. Really easy. When you set another start address for the DMX Device, the 5 channels are shifted, e.g. to 7,8,9,10,11.

Circuit

I combined a MIDI-In Circuit with the “DMX.Simple” library. Here are the resources:
Simple DMX Code
Simple DMX Circuit

One Note: this circuit does not provide isolation. Be sure to connect all devices and the control to the same electrical loop (Phase).

Parts list: (~10€ w/o Arduino)

  • R 100 Ohm
  • R 3,3K Ohm
  • R 220 Ohm
  • Diode 1N4148
  • Opto copler 4N28
  • Serial transmitter 75176AP
  • XLR Jack female
  • 5-Pin DIN Jack female (Midi Jack)
  • Arduino Uno (Nano, Duemilanove and all the others will probably work as well) (~30€)

Midi-to-DMX-Circuit

Download the Eagle schematic for the Midi to DMX Arduino Shield here

You have two sections: opto copler 4N28 for handling the MIDI-In. You can probably use other types like the 4N38 as well. Secondly the DMX output section that consists of a serial converter 75176, here you could also use the standard chip MAX481 (see this tutorial)

Code

Preparation: You have to install the Simple.DMX library (howto install a Arduino library) get the library here
The code is not too nice written, but works as supposed and can be easily adapted.

// welcome to MIDI to DMX by moritz Simon geist.
// Ressources, setup and hardware: http://sonicrobots.com/?p=864
// DmxSimple is available from: http://code.google.com/p/tinkerit/
// Help and support: http://groups.google.com/group/dmxsimple       */

#include <DmxSimple.h>
byte incomingByte;
byte note;
byte velocity;
int statusLed = 13;   // select the pin for the LED
int action=2; //0 =note off ; 1=note on ; 2= nada

void setup() {
    pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  //start serial with midi baudrate 31250 or 38400 for debugging
  Serial.begin(31250);       
  /* The most common pin for DMX output is pin 3, which DmxSimple
  ** uses by default. If you need to change that, do it here. */

  DmxSimple.usePin(3);

  /* DMX devices typically need to receive a complete set of channels
  ** even if you only need to adjust the first channel. You can
  ** easily change the number of channels sent here. If you don't
  ** do this, DmxSimple will set the maximum channel number to the
  ** highest channel you DmxSimple.write() to. */

  DmxSimple.maxChannel(5);

}
void loop () {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // wait for as status-byte, channel 1, note on or off
    if (incomingByte== 144){ // note on message starting starting
      action=1;
    }else if (incomingByte== 128){ // note off message starting
      action=0;
    }else if (incomingByte== 208){ // aftertouch message starting
       //not implemented yet
    }else if (incomingByte== 160){ // polypressure message starting
       //not implemented yet
    }else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
      note=incomingByte;
      playNote(note, 0);
      note=0;
      velocity=0;
      action=2;
    }else if ( (action==1)&&(note==0) ){ // if we received a "note on", we wait for the note (databyte)
      note=incomingByte;
    }else if ( (action==1)&&(note!=0) ){ // ...and then the velocity
      velocity=incomingByte;
      playNote(note, velocity);
      note=0;
      velocity=0;
      action=0;
    }else{
      //nada
    }
  }
}

void playNote(byte note, byte velocity){
  int value=0;
  if (velocity >10){
      value=255;
  }else{
   value=0;
  }
  // =DEVICE 1=
  // DMX CHANEL 1: "2" for seting DMX Mode
  // DMX CHANEL 2: 0 .. 255 Control Red     --> .... MIDI Note "1" (possible C-2)
  // DMX CHANEL 3: 0 .. 255 Control Green   --> .... MIDI Note "2"
  // DMX CHANEL 4: 0 .. 255 Control Blue    --> .... MIDI Note "3"
  // DMX CHANEL 5: NADA
  
  // =DEVICE 2=
  // DMX CHANEL 8: "2" for seting DMX Mode  
  // DMX CHANEL 9: 0 .. 255 Control Red      --> .... MIDI Note 4
  // DMX CHANEL 10: 0 .. 255 Control Green   --> .... MIDI Note 5
  // DMX CHANEL 11: 0 .. 255 Control Blue    --> .... MIDI Note 6
  // DMX CHANEL 12: NADA
  
  

// ADAPT THIS to match your Midi Notes to your DMX Channels
 if(note>=1 && note<10){

    switch (note) {
    case 1:
    DmxSimple.write(2, velocity); 
      break;
    case 2:
    DmxSimple.write(3, velocity); 
      break;
    case 3:
    DmxSimple.write(4, velocity); 
      break;
    case 4:
    DmxSimple.write(9, velocity); 
      break;
    case 5:
    DmxSimple.write(10, velocity); 
      break;
    case 6:
    DmxSimple.write(11, velocity); 
      break;
      //[ ... ] add more channels
  }
   

 }

}



  

MIDI-Programming

So what we have here is, that we control each of the DMX channels with one note and its velocity. We can for example set red from LED PAR1 to 255 (100%) and blue and green from LEDPAR2 to each 128 (50%). The light will cease when the Midi note-off command is sent.

In Ableton I opened up a new Midi track where I can control the lights with notes. What I did to have a hardware master fader: I added a Midi device to control the velocity of all the notes, and midi mapped it to my APC40 midi controller. Like that I additionally have a hardware master fader!

Troubleshooting & FAQ

It doesn’t work!

When you build the circuit be sure to debug one thing after the other.

  • First you can check if the MIDI-In circuit works with this little program I have written. It simply lights the status LED 13 when Midi data is coming in. When it doesn’t, you better check your input circuit or your midi device.
  • Next you can check the DMX output stage with the “Fade” sketch that came with your DMX Library. Play around with the DMX.write() commands until you see something.
  • Did you check the DMX settings of your device? Normally they can be set to “manual”, “DMX” or “Auto” Mode with little switches. The DMX starting address is also set here. Be sure to consult the manual to do it right.

What about Isolation?

This circuit doesn’t provide isolation, so be sure to connect all devices, and the control to ONLY ONE ELECTRIC LOOP (Phase). If you don’t, you can possible blow your equipment.

Share →

2 Responses to Midi to DMX arduino control shield

  1. ManuM sagt:

    Thank you for your MIDI ARDUINO DMX code and circuit !!!
    It work very well with my ATARI ST and my LED Par 56 SX Lighting
    drive with GFA BASIC for MIDI ST part

  2. Dirk sagt:

    Hi Sonicrobots, thank you very much for sharing this project. I made a tiny shield with your schematic. First it didn’t work, but after an intense web search I found out that the DmxSimple library appeared to be out of date. I work with arduino 1.0.5 and in the DmxSimple.cpp file that can be found in the driver folder, I replaced
    #include “wiring.h” with #include “Arduino.h”.
    At this time I don’t understand what this change exactly does, but since the change it works here. So I thought sharing this might be interesting for others too.
    Cheers!

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht.



Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>