Working with Hardware: DMX, Part 1


DMX, or more accurately, DMX 512, is a network protocol most commonly used for the control of stage lighting and effects. It is easily programmed in Max, using techniques similar to those used to program MIDI. With your Max skills, you can replace and extend the functionality of dedicated DMX controller/mixer hardware boxes with patches.


Video: Tom Hall and Andrew Pask

This is the first article of three in which we shall explore the world of programming DMX with Max.

Over the course of these articles, we will present some basic DMX concepts and an introduction to some DMX hardware options that are usable with Max. The second article will feature interviews with Max programmers that have experience with DMX in professional environments. Finally, the third article will focus on development of a rather complex DMX control system.

Understanding the DMX Protocol

The name “DMX” is short for “Digital Multiplex”. It is a network protocol for passing packets of control data over device network. The “512” in DMX 512 represents the maximum number of devices (512) that can be controlled with a single packet. This network of 512 devices is called a DMX “universe”.

In a typical DMX 512 network, devices are daisy chained together. The master (or control) device is at the beginning of the chain, with a cable running to one device, and a cable run from that device to the next device, and so on. DMX always travels in one direction – it is unidirectional, and the end of the chain needs to be terminated.

Here’s a picture of the simple DMX network we used to make the video.

In this picture, we have a laptop running our Max patcher connected to a DMX controller, which in turn sends packets down the DMX network cabling to connected lighting devices.

Devices in a DMX universe are specified by channel, with up to 512 channels in a single packet. A packet contains a header followed by the control data expressed as 8-bit values (bytes). Since this is 8-bit data, we use the values 0-255 (in decimal) when programming DMX data in Max.

There is no index in a DMX packet, so if a device thinks it is on channel one, it will look at the first data byte in a DMX packet and choose that value to set its state. If a device thinks it is on channel 53 in the current universe, then it will choose the 53rd byte in the packet for its value.

Each DMX controllable device has built-in channel selectors, allowing you to specify its channel numbers within the universe. Let’s look again at our example DMX network. The first device is a 6-channel LED “spot”. The 2nd device is a 4 channel dimmer starting on channel 8, with 2 light bulbs hooked up on the first two channels.

As an example, if we send a DMX packet with the following data:

255 255 255 0 0 0 0 127 255

The result will be to set the RGB led to white, the first light in the dimmer to half way on, and the 2nd light in the dimmer to all the way on. Notice a few interesting things about this data packet:

  • We don’t need to send all 512 data values; but we do have to send data for all the devices in our DMX universe.
  • The LED spot only uses 3 channels of color data, even though it is a “6-channel” device.
  • There needs to be 7 channels of data allocated before we get to first channel in our dimmer (channel 8). Since we are only using 3 channels to drive the LED, we need to pad out the packet with data for the unused channels.

Many DMX devices are like the 6-channel RGB spot, which has multiple channels to control various parameters of their state; for example, a DMX led array can have hundreds of channels of control. When programming multi-channel DMX devices, you usually need to dig into the documentation for each device in order to find out how each channel is used.

Connecting a DMX Network to Max

The first thing we need is a DMX interface. In my case, I have a LanBox LCX by the Dutch company LanBox.

The LanBox-LCX is an extremely well equipped piece of equipment. It offers connections in a variety of formats, including Ethernet, MIDI, and USB, or can be operated in standalone mode. It can be used on an Art-Net network. It is a kind of “Swiss Army Knife” of DMX network control. The LanBox website contains a page with the freely available Max externals which are required for communication with the device, plus some examples of patching code. This unit, while not the cheapest DMX interface available, has all the bells and whistles, and feels solid and well built.

In addition to a controller, you’ll need devices to control and some cabling to hook it all up. DMX cables are a mix of 3 pin and 5 pin XLR, so expect that you’ll need to buy some adapters. There is an incredible range of DMX controllable dimmers, lights, fog machines, lasers, servos, and amplifiers out there. Two of the most common brands of DMX capable lighting gear are Chauvet and American DJ.

Our “hello universe” Patch

Once we have downloaded and installed the LanBox Max externs and examples from their site, setting up for patching is straightforward. You can follow along with the LanBox documentation concerning setting an IP address for the LanBox on your network, or you may be lucky enough to find out that the default IP address for the LanBox works fine at your location.

For my example, I have an American DJ P36 LED spot connected as the first device on my DMX daisy chain. This light has 6 channels of DMX control. Next comes an Elation DP 415 4 channel dimmer pack, and I have placed standard incandescent light bulbs on channels 1 and 2 of that device.

On the back of the 4 channel dimmer, I’ve set the DMX channel offset dipswitches so that the dimmer’s first channel is channel 8.

Here is the patch I’ve created:

Let’s walk through the patch a bit.

There are many ways you can manage lists of numbers in Max. To make things obvious, I’ve decided to go with message boxes.

The swatch object is set to “Output Old Style 0-255 values” in its inspector. This gives me the exact range I need for my DMX channels. The first 3 channels on my LED spot are for R, G and B, so I’m setting them up as the first three values in my message box labeled “channels 1-7”. I have to pad out the message box with unused channels because the first channel on the dimmer box is set to channel 8, so it will use the 8th value in the DMX packet.

The output from the sliders and toggles intended to drive the light bulbs is made into a similar message, which represents the 4 channels on my dimmer. I then join the two messages together and use them to set the contents of a third message box, which is the whole packet I need to set state in this system.

My LanBox has a hardware clock which runs at 20fps, so I’m using a qmetro to update the state of the DMX network every 50 ms.

Finally the lcudp-pack object, which is provided by LanBox, formats the packet for the network and passes it to the udpsend object via the “FullPacket” message – and off it goes to my light show!

Stay Tuned

At this point, you should have a handle on how DMX 512 works, how you communicate to devices and how you would create a basic DMX control patch. We are going to get deeper into the DMX world in an upcoming article, but the next entry will discuss DMX with some people using it professionally.

Please let us know in the comments if you have any questions or suggestions, and thanks for reading!


July 9, 2012 | 12:59 pm

Thanks for the great overview.
For those that are interested, the Teensy microcontroller comes with a version of the firmware that allows it to talk DMX:

http://www.pjrc.com/teensy/td_libs_DmxSimple.html

And one of my favorite students ever recently made a very nice Teensy shield to make it all super easy;
feel free to contact me if you wanna know more…

a


July 9, 2012 | 1:11 pm

And a link to said Teensy/DMX shield:

https://plus.google.com/109036222621917320968/posts/BiVYJpPJ9YV


July 9, 2012 | 6:36 pm

Thanks for sharing! Very useful.
I also work with DMX by Max,
Here is my project last year: https://vimeo.com/29149258


July 9, 2012 | 7:43 pm

Cheers Ali.

Yeah there are loads of ways to hook up DMX in Max. The more the merrier I say! Thanks for those links.

-A


July 12, 2012 | 1:44 pm

Great article! The hardware looks really solid and flexible.
My issue was always getting the formatting right for sending to various devices and UDP, so it’s great to see dedicated externals for this. Still, I’d love to see a pure-Max solution for the formatting—that is, generate your list of channel values, and *do some magic around it* (in a subpatch) to be able to send it to UDP directly. Understanding that building process would be great.
Regardless, love the post and am looking forward to more!


July 16, 2012 | 2:36 am

The lights which Palmbomen uses during his live-set are all controlled via Max as well, converting MIDI signals from Ableton to DMX data in MaxMSP.
This way he can sequence his lights synced to the music. Video: http://www.youtube.com/watch?v=ijpmNt_Vff0



Ray Kampmeier
July 28, 2012 | 7:42 pm

Thanks for the useful primer Andrew. I designed a simple Teensy/Arduino dmx adapter if anyone is interested. Gerber files for board fabrication are included :) http://www.raykampmeier.net/projects/portfolio/teensyarduino-dmx-adapter/



Torsten
November 22, 2012 | 9:18 am

a very useful LAN to DMX Converter:

http://www.cinetix.de/interface/english/etdmxgen.htm


April 20, 2013 | 4:24 pm

This was an awesome post indeed!
This post was the inspiration for my final year project in the University of Limerick, Ireland.
My project was to create a DMX lighting controller in Max using an iPad with TouchOSC.
The progress can be seen here: http://conorkeane.net/about/final-year-project/

Thanks Andrew for this as it was truly inspirational!



Nat
November 7, 2013 | 6:58 am

Here’s a box I made based on Teensy 3 :

https://github.com/natcl/dmx_midi

It’s basically a midi to dmx bridge. The midi implementation is quite complete so you can use note messages, control changes, sysex (to use the full 8 bit resolution), poly pressure.

Nice thing is that since it’s midi class compliant it’ll work out of the box on an iPad !

The repository contains everything to build the project !


Viewing 10 posts - 1 through 10 (of 10 total)