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.

    Working with Hardware: DMX, Part 1

    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.
    All the tutorials in this series: Part 1, Part 2, Part 3.
    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!

    by Andrew Pask on
    Jul 9, 2012 7:01 PM

    • owmtxy
      Aug 25 2018 | 4:57 pm
      So (as of 2018) is there anyway to get a LanBox working in Max? It seems they've stopped supporting their externals, and the tutorial patches here don't seem to run with LanBox anymore? Any ideas?
    • Luke Woodbury's icon
      Luke Woodbury's icon
      Luke Woodbury
      Oct 18 2018 | 8:03 pm
      @OWMTXY I have just posted a solution if you still want one:
    • n2048's icon
      n2048's icon
      Oct 20 2019 | 11:25 am
      Hi.. I'm adapting a Patch to work with an ENTEC DMX USB PRO and 3 RGBW light fixtures Each fixture takes 6 channels. For some reason, the 3rd fixture (set to channel 13) is not responding.. channels 1 and 7 work just fine. Any Ideas about what's wrong here?
      maxpat 144.07 KB
      DMX control (3 RGBW spots)
    • felipe vaz's icon
      felipe vaz's icon
      felipe vaz
      Oct 29 2019 | 5:31 pm
      It is easy overflow the serial port with pak. Maybe that's what is happening (it happened to me with the same interface). Just send send the list with a metro in a decent tempo instead of updating every time each parameter changes.
    • Conall   O Maolain's icon
      Conall   O Maolain's icon
      Conall O Maolain
      Jan 24 2020 | 3:04 pm
      Hi, have the external in my file path but the object won't open in MAX 8. Is it compatible?
    • Luke Woodbury's icon
      Luke Woodbury's icon
      Luke Woodbury
      Jan 27 2020 | 12:13 pm
      @CONALL O MAOLAIN are you talking the Lanbox external? If so, then no, the old external won't work with Max 8 as it is 64 bit. I posted a hack here: