• Home
  • Back to Sonic Robots Main page
  • About
  • Contact

Recital

  • Learning
    • MR 808 Technique – Acoustics
    • MR-808 Technique – IT & Interaction
    • Browse all
    • Electronics
    • 3D-Printing
    • Modding
    • Arduino
    • Technical practice
    • Sensors
  • Music robots list
    • Browse all
    • Autonomous
    • Experimental
    • Glockenspiel & mallet
    • Floppy & retro
    • Piano robots
    • Robot bands
    • Robotic drum
    • String robots
  • Research
    • Lectures

Midi 2

Midi to DMX arduino control shield

Yesterday night I hacked together a quick and dirty Arduino MIDI-to-DMX control . 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 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€)

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 
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.

10 years ago 6 Comments Allgemein, Arduino, Electronicsdmx, midi, midi2dmx

A latency control concept for midi driven mechanic robotic instruments

When combining different robo-mechanic instruments and let them jam together, the most crucial point (beside from making awesome music) is to set the latencies right. The setup is mostly the same: we have a robotic music instrument (e.g. a snare with an solenoid actor), a somewhat electric power unit (Relay, Motordriver / FET-drive and an Arduino) and a unit to generate the information, e.g. keyboard or a midi-program like Ableton.
Each instrument has its own unique latency, given by the time between the “note on” signal (e.g. Ableton triggering a note in the sequencer), and the time when the tone finally leaves the physical instrument. These latencies can be up to several 100 microseconds, a delay that a human ear will definitely recognize. The latency consists of (more…)

10 years ago Leave a reply Allgemein, learning, Media Art Installation - Techniquecontroller, controlling, latency, midi, robotics
Recent Posts
  • Popcorn Drums Piezo Midi Controller
  • Touch Piano with MIDI USB on Arduino Leonardo
  • Volca Korg External Power DC Plug
  • How to Build Techno Music Robots
  • Stephan Eicher und die Automaten
Recent Comments
  • Brynjulf Blix on Midi-in Pitchbend with an Arduino
  • Nick Patel on Spotify and the native windows 7 firewall
  • jhon on Problem with network printer not printing through windows firewall
  • Luqman on M@P Group – Robot Guitar
  • Arne on External power for the Korg Monotron and the Stylophone
Imprint
Impressum
Contact

Love or hate? Get in touch!

Email: contact@sonicrobots.com

2016 © Sonic Robots - Learning