Honest Abe { HonestAbe }

USB DMX, Part 0. Hardware and Software Setup

Jul 1, 2019

Welcome to the first in a series on a project I spent too many restless nights thinking about. USBDMX is a Go library designed to control real world lighting and special effects. Think of the last time you went to a night club, or the theatre, and the lights would dance to the music or a smoke machine would start up; all of that is likely controlled by DMX, a universal show control protocol.

DMX 512, A Primer

DMX 512 is the defacto standard for controlling “safe” stage lighting and special effects. Everybody running a nightclub, a theme park, a stage show or a halloween attraction has definitely heard of it but may not be using it due to a lack of understanding. Honestly, it’s fairly straight forward: each fixture (strobe light, smoke machine, mirror ball, etc.) has an address between 1 and 512 and occupies a number of channels. Each channel can have a value between 0 and 255 assigned to it. These channels and values combined control the fixture, in some case colour, in others intensity.

Say we had a spotlight that could change its intensity between 0 and 100%, and that it was sat on the first channel in our DMX universe, we would send some data that would look something like: “Channel 1: 100%”. Now imagine it had three, seperate, additional channels to control red, green and blue values respectively, now we would send some data that may look like: “Channel 1: 100%, Channel 2: 100%, Channel 3: 100%, Channel 4: 0%” and before you know it we have a nice, bright, purple light.

The more fixtures we want to control seperately, the more channels we need to assign. Say we had another of our spot lights that we wanted to control completely independently of our first, we’d need to assign a total of 8 channels, 4 for the first and 4 for the second. With fixtures channels are almost always sequential, meaning it wouldn’t be possible to share the intensity channel of the first light with our second light whilst maintaining the ability to control the colours independently.

There’s a number of ways to control these channels, the most popular being with a lighting desk. Just like audio engineers have a desk with lots of shiny knobs, switches, buttons and sliding things, lighting engineers have consoles that can be used to pre-program sequences and control fixtures on the fly. Another method, for those of us unwilling to drop thousands of pounds on a lighting console, is USB to DMX devices. These are often small devices that take your USB data and convert it to something that can be understood by fixtures. Although being significantly cheaper than a console, it was still looking like a considerable investment just to find out if I could make my own library to control lighting rigs, but there was an alternative.

China, The Land of Cheap Hardware

As we all know, China is a great one stop shop for products that have questionable authenticity. Not just discount iPhones, fashion and consumer electronics, but every chip ever made. In fact, it’s not all that difficult to head out and buy all the individual components need to build your own iPhone with the much desired headphone jack.

Well, if you crack open almost any of the consumer DMX to USB devices it’s likely that you’ll see a Future Technologies 232 chip, which (in our case) is used to convert our USB data to serial data that fixtures will be able to understand. These aren’t a cheap component by any means, but thanks to the beauty that is knock off electronics it’s not hard to purchase one that’s: already connected to a board, with a USB B connecter, screw terminals and some sketchy soldering for under £2. Throw a female XLR connector in the cart and a spool of wire and you’ve got yourself a DIY USB to DMX device for less than £4. You’ll probably want an enclosure too, so we’ll round it up to £7 for arguments sake, not a bad saving on buying an almost identical consumer device off Amazon.

Now, I’m not saying I’d trust one of these in a production environment, they have a distinct lack of surge protection, and lighting isn’t cheap; but as a hobbyist, or as part of a cosplay with some addressable RGB LED strips then it really is a budget way of getting access to some great control for your project. With our controller built, and ready to go we’re going to need a light to plug it into. Again, China is great for these and you can pick up an inexpensive DMX light up for around £20, although personally I’d go for a name brand (like Pulse, or Equinox) and sell it on when you’re finished with the project. For some lights, and with some boards, you may need a terminator. Easy enough to build or cheap enough to buy, and if you’re not sure I’d recommend getting one anyway, there’s nothing worse than being full swing on a project only to find you’ve got to wait 7 days for a component to tie it all together.

If you’re interested in building your own controller, here’s a components list.

You’ll also need: soldering equipment, wires, wire cutters and strippers. Really, not a bad little project if you have no real experience with electronics and limited equipment to hand. Remember to keep your wires short where possible, long wires have the potnetial to create noise and interference.

Depending on your connector you’ll need to wire it up slightly differently.

In the case of a 3 Pin XLR connector you will want to wire the pins accordingly.

In the case of a 5 Pin DMX connector you will want to wire the pins accordingly.

QLC+, Open Source Lighting

Now that we’ve got some hardware, we need to check everything is working. For this I’d recommend using QLC+, an open source solution to controlling DMX devices. QLC is a bit of a beast, it can even be used to create lighting shows and programmable lighting desks, something that (for this project) we have no interest in doing. So, let’s just talk quickly about the basics.

Fixtures

Fixtures is where we can add our lighting and special effects fixtures, eg. the light we purchased earlier. If you have bought a well known brand it’s likely that your fixture will already be built into the software and you can add it to your workspace. If not, don’t worry, you can ignore this step, or go ahead and create a new fixture using the “QLC+ Fixture Editor”

Simple Desk

This is what we’re going to be using to control our light, it lets you control all 512 channels quickly and visually, great to determine if our lights are working as intended.

Input / Outputs

This is a list of well known input and output options for sending our DMX commands to and recieving them from. Once you’ve plugged in your custom controller you should see it pop up, if not it’s likely that you’re missing the FT232 driver and you may need to install that.

You may notice that our controller only has output. This is one of the limitations of the device and, as far as I can tell, it can’t be reversed to take serial input and convert that to USB data.

Some more expensive controllers may have 2 or more output/inputs. I own a Enttec USB DMX Pro Mk.2, which has 2 ouputs and 1 input. If you open one of them up you’ll still see an FTDI232 chip in there.

So, if all has gone to plan, you should be able to add a fixture to your workspace and see what each channel relates to in the virtual console. Finally we’ll want to plug in our controller, and light, and see if we can start sending some data down the line. Have a play around in the console, your light may have some fancy features like strobing or other effects.

Wireshark, The Holy Grail of Packet Sniffing

We’re going to be using wireshark to find out what data is being passed down from QLC+ to our controller. We could just look at the source code, you can grab it straight from Github, but this was an adventure in reverse engineering and programming for hardware.

Simply put: Wireshark collects data that is being passed from one place to another. That means it can be, and is most commonly used for, sniffing network traffic. From this you can begin to gain an understanding of what exactly is going on between a client and game server, see what data is being leaked when you are chatting with your friends online, or even discover what content people on your network are looking at. Not all things I recommend you do, and definitely not all are legal, but it shows off the power and versatility of the software.

We’re going to be using this to grab packets going between our machine and ligthing controller, which requires a little bit of configuration and really doesn’t push the limits of what the software can do. Once we’ve captured the data we’ll be able to look through each payload and start to analyse exactly what is going on. If you’re unfamiliar with Wireshark, don’t worry, I’ll be walking you through each step, and it does look quite daunting, but do yourself a favour and learn how to use this magnificent beast. If you work in tech, anything from a QA Tester to Hardware Engineer, it will help you out and some point.

Epilogue

Well, looks like you’re all ready to go. In the next post I’ll be talking more about Wireshark, how we can set it up to intercept packets being sent over our USB bus and how we can analyse and interpret each of those. If you care more about the end product you can take a look at the project over on Github and see exactly what’s being sent. The project is still in active development (although it may not look that way) and any help with documentation or support for new hardware is much appreciated.

A quick shout out to Steven Breuls, without you this would’ve been a much pricier endeavour. The Wireshark team for building such bad ass software. And finally: the guys over at Enttec, who were cool enough to sponsor me with a DMX USB Pro Mk.2 to continue work on this project, they make some awesome hardware and if you’re looking at getting more into this field you can find much worse.

See you next time, Read more from this series

More Posts