Coding to make lights move

posted by Jeff | Saturday, June 17, 2023, 12:16 AM | comments: 0

I'm not sure why exactly, but I got the urge to see if I could write a little code that would move my lights around. I guess I was thinking about it because the software that does this sort of thing is so expensive, especially (and understandably) if you want matching hardware with faders and encoder wheels.

DMX makes stuff do stuff. It's a super simple protocol. It sends a serial burst of packets, each with 512 bytes that correspond to "channels." A channel is just some parameter for the thing you want to make do stuff. On lights it could be the dimmer value, the pan or tilt position, color, etc., but it can also control things like smoke machines. You send these 512 bytes down the wire 40 times a second, and off you go. Best of all, these DMX cables are typically plain old XLR cables, like those you'd use for a microphone.

The days of lights that don't move or change color are long gone, so you aren't going to control 512 dimmers anymore. My moving lights have 14 channels each, so with two of them, I've already used 28 of the 512. There are some single fixtures that have several hundred channels even. Smart people have figured out how to get around this with protocols on top of the the protocols, with different wires. Every 512 channels is a "universe." Someone came up with Art-Net, a thing that can transmit about 32,000 universes over ethernet. Then another standard called sACN came along and can do about twice that. Some fixtures can just listen to the network directly, but for everything else, you just need a little box to listen and output the regular DMX signal over an XLR cable.

Knowing all of that, writing code to manipulate those values is straight forward. You just need an array of 512 bytes per universe you want to talk to, and set each byte to the level you want. That makes a packet of DMX levels. The less obvious part is how to send those packets over the network. I found a library that does it, but it hasn't been updated in awhile and there's a serious bug (I submitted a pull request!). Overall though, it's well-written, and I'm not interested in duplicating it. Once I had this, it was easy enough to bang out a few lines of code, and there it is, I could make the light dance. Cool!

What do I do with this? I don't know. I don't imagine that I would write my own lighting control software. Although I am super intrigued by the idea of making something like this browser based. I am all about less apps, more web. I'm going to study sACN a little more. The thing that's appealing in messing with this is the physical manifestation of actual real life devices doing things. Making stuff happen on a screen is all I've ever done, but this, it has real-life consequences!


Comments

No comments yet.


Post your comment: