Tutorials

    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

    • batchku
      Jul 09 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
      Share
    • batchku's icon
      batchku's icon
      batchku
      Jul 09 2012 | 1:11 pm
    • Dat1981's icon
      Dat1981's icon
      Dat1981
      Jul 09 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
    • Andrew Pask's icon
      Andrew Pask's icon
      Andrew Pask
      Jul 09 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
    • seejayjames's icon
      seejayjames's icon
      seejayjames
      Jul 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!
    • maaark's icon
      maaark's icon
      maaark
      Jul 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's icon
      Ray Kampmeier's icon
      Ray Kampmeier
      Jul 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's icon
      Torsten's icon
      Torsten
      Nov 22 2012 | 9:18 am
      a very useful LAN to DMX Converter: http://www.cinetix.de/interface/english/etdmxgen.htm
    • waitingfortheencore's icon
      waitingfortheencore's icon
      waitingfortheencore
      Apr 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's icon
      Nat's icon
      Nat
      Nov 07 2013 | 2:58 pm
      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 !
    • Jesse Baldridge's icon
      Jesse Baldridge's icon
      Jesse Baldridge
      Apr 23 2015 | 9:26 pm
      Hello all,
      I am in dire need of some help. Ok, so I have Windows 8.1, Max 7, a Lanbox-LCE, and a patch that I downloaded from Lanbox the "Max 5 example TCP/IP Communication" found in the 3rd party support section.. I tried using the patch from this page but the lcudp-pack object that came with it doesn't work for me (my guess is because it's a MAC object not a Windows since it ends in ".mxo" and I think that it needs to be ".mxe" for Windows).
      Anyway, with the Lanbox connected I open the patch "TCP Communication", tap the connect button in the upper left corner, but it doesn't work and I get an error 10060 message. I tried re-addressing to 'demo.lanbox.com' like it mentions in the comment box below. For a split second it actually connects, but quickly says that I need a password and then access denied, then it loops that for about thirty seconds.
      I think this must be a Windows thing because I saw someone else use the same patch on his Mac (Max 7) and it connected fine.
      Has anyone using a PC been able to successfully use the nsock object that comes with that patch or know why I keep getting the 10060 error? Or is there a lcudp-pack object that exists for Windows so I can use the original patch from this page?
      Any help would be greatly appreciated! Thank you very much for your time.
      (Here's the link to the download I've been using if it helps any). http://www.lanbox.com/download.php?view.19
    • Jean-François MOUNET's icon
      Jean-François MOUNET's icon
      Jean-François MOUNET
      Nov 20 2016 | 1:50 am
      Hi, Could you show me how to use this patch with a FTDI USB Serial Converter like this one I have : http://www.boutique-electroconcept.com/boutique/interface-isolee-usb-vers-dmx-512-xlr-3-points.html
      Thanks a lot for your help indeed ! Jef
    • owmtxy's icon
      owmtxy's icon
      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: https://cycling74.com/forums/sharing-is-lanbox-in-max-8-lcudp-pack-hack
    • n2048's icon
      n2048's icon
      n2048
      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?
      Untitled5.maxpat
      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?
      Thanks
    • 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: https://cycling74.com/forums/sharing-is-lanbox-in-max-8-lcudp-pack-hack