Arduino Dmx Fade

Portland CORE effigy at Burning Man will be using DMX controlled lighting this year. At least that's the plan, but a low-cost and low-power way to automatically play the lighting sequence (without a PC) is needed. Here's a little board I made for the purpose.

Click 'Read more' for source code and other technical details.

First, the lighting sequence is created using Vixen version 2. Creating the sequence is pretty simple, just click ranges of time slots and use the toolbar buttons to turn the light on, off, fade up, fade down, etc. Vixen has lots of little features to create patterns, but so far I've only used the simplest ones.

One nice feature of Vixen, which I knew existed but never tried back on the Hand-Eye Supply float (Tobias did most of the Vixen stuff) is the Sequence Preview. It takes a photo of your project and then you can define pixels that will overlay the image for each lighting channel. Here's a screenshot:

Vixen version 3 greatly expands the preview feature and adds lots of new features, but it doesn't use the simple time slots that we need from version 2. Maybe someday I'll revist this project and make a way to use version 3, but for now it's limited to Vixen 2.

Permanent Redirect. I have a project where I have an Arduino with DMX shield. In the program I have an array of DMX values that I want to set after a button press. The code is working, but I need the values to fade from one to the next over a period of ten seconds. Any ideas how I might make that work? Here is the code below.

  • Control DMX lights with your Arduino. Using RS485 shields, like the MKR 485 Shield. This library depends on the ArduinoRS485 library.
  • Works exactly as it should, has a good library for arduino that makes it very easy to write DMX output code for. I actually used this unit to replace a lighting amplifier that used the arduino's PWM outputs through a mosfet amplifier, to modify the code all i had to change was my analogWrite to DmxSimple.write.
  • This shield for Arduino allows you to control several DMX light fixtures or DMX receivers by using only a simple Arduino board and a free software library. DMX is the industry standard for controlling stage lighting, and is now increasingly used also in smaller sets like interactive installations, DJ Sets, Shops, and even private living rooms.

Vixen saves files to its Sequences folder as a '.vix' file. It's XML format, with a big binary dump of the raw sequence data encoded as base64. I started reading about Vixen's file format, determined to write a program to play it. Pretty soon, I found Bill Porter had already done it, and written a very nice tutorial.

I just modified Bill's awesome script. I've done very little with Python before, but it's a pretty easy language to pick up. There are lots of tutorials and great documentation online. But being a Python novice, I probably didn't do everything the best way. At least it works. Actually, it apparently only works with Python 2.7, but not Python version 3. Again, I'm a Python novice....

It turned out Bill's script could not read a .vix file with the image preview. It finds too many channels, because the channels within the preview get double counted. Bill used Phython's minidom XML parser with getElementsByTagName() to find all the channels. I found much better documentation for Python's ElementTree, so I rewrote the script using that to carefully find only the channels in the main section of the file.

I also changed the script's output. Instead of creating a .cpp file to be compiled directly into Arduino, I had the script output a text file with the data in a format that could easily be read from a SD card. This way, there's no practical limit to the sequence length. The script stores the data in a simple format, so Arduino code can just read each line of the file as it plays the sequence. Here's what the text format looks like:

Arduino dmx faded glory

100
000000000000000000000000000000000000FF000000000000000000000000000000000000000000
331700000000000000000000000000000000F9000300000000000000000000000000000000000000
662E00000000000000000000000000000000F4000600000000000000000000000000000000000000
994500000000000000000000000000000000EF000900000000000000000000000000000000000000
CC5C0E000000000000000000000000000000EA000C00000000000000000000000000000000000000
FF731C000000000000000000000000000000E5001000000000000000000000000000000000000000
FF8B2A000000000000000000000000000000E0001300000000000000000000000000000000000000
BFA238000000000000000000000000000000DB001600000000000000000000000000000000000000
7FB946000000000000000000000000000000D6001900000000000000000000000000000000000000
3FD055000000000000000000000000000000D1001C00000000000000000000000000000000000000
00E76300000080FF00000000000000000000CB002000000000000000000000000000000000000000
00FF710A00007BF605000000000000000000C6002300000000000000000000000000000000000000
00FF7F15000077EE0A000000000000000000C1002600000000000000000000000000000000000000

The first line is the number of milliseconds for each update period. Then each line has channel 1 in the first 2 characters, channel 2 in the next 2 characters, and so on.

With the data in a simple format, it was pretty easy to write code with Arduino to read it. The DmxSimple library did all the heavy lifting for transmitting DMX, so only a RS-485 chip needs to be connected to get DMX output.

The SD library and Arduino 1.0's new readBytesUntil() function makes reading the text file pretty easy. Just a little code was needed to turn the hex digits back to binary. I suppose I could have made the Python script output binary, but I felt the text file would be much nicer, so anyone using this project could 'see' the data by just double clicking the file.

With 5 PWM output available (DmxSimple uses Timer2, so 2 of the 7 PWM on Teensy2 aren't usable), I added a tiny bit of code to display the first 5 channels on LEDs. The script can parse up to 256 channels, half of DMX's maximum. I'm pretty sure that will be plenty of this project.

Here's the Arduino sketch:

I'm not actually going to Burning Man this year. So far, my success rate for building stuff for burners to take and use on the Playa (in my absence) has been pretty low. Burning Man is a really harsh environment and it's also filled will all sorts of distractions when solving any sort of technical problems. This year the team has someone who's very good with electronics and he seems comfortable with Python. Hopefully this little device will be usable and they'll be able to create sequences, convert the file and get it onto the SD card.

EDIT: Here's an image from Jesse doing a test with all the DMX lights.


EDIT: I built a spare board. They wanted it to be able to play multiple files and randomly choose them, so I added a LCD to show which file is playing. Hopefully will make troubleshooting easier.

Here's the Python script and revised Arduino code (with randomized multi-file playing and display), in case anyone ever wants to use this controller for their own DMX controlled lighting.

A stream of consciousness write up on building a DMX- audio trigger device.

So it’s been 5 years or so since I was last playing around with DMX receiving (to control WS2801 led strip, and RGB 12v strips), and the MP3 Trigger from robertsonics (as part of a game show buzzer sound effect player).

Simple enough project this time, when a dmx value is received, play an mp3.

Ideally DMX Address 512 to keep it away from any other lighting addressing, but this could cause problems if there’s any timing/variable storing issues.

DMX Values =

0-127 = stop playing

128-255 = start playing ?

And all it does it make a digital output pin go low/high. which triggers 1 track to play, nothing fancy at all.

Originally I thought 0 could be stop, and 1-255 could be volume levels, to allow for fade ins and outs, but if i’m using the serial port for DMX, I can’t use the same serial port to talk to the robertsonics mp3 trigger. This could be a reason to use a Teensy instead of an ATMega device. Then could also use serial to pick different tracks too.

Anyway, keeping it simple for now (mostly because I don’t have a MAX485 wired into a teensy, but I do have a ATMega 328P with a MAX485 prototype already made.

DMX Library, I had been using the Max Pierson DMX receive code, and so pulled out Arduino v 0018, which was my last known working compiler, but it threw errors straight away, so started looking for a newer option, compatible with the current v1.6.x Arduino IDE.

DMX Serial – http://www.mathertel.de/Arduino/DMXSerial.aspx seems to be a good option, code here: https://github.com/mathertel/DMXSerial/blob/master/examples/DmxSerialRecv/DmxSerialRecv.ino

So using Arduino 1.6.4 on my mac, with a 5v FTDI cable, was able to upload the DMX Receive example, (the switch/jumper on the pcb has to be up to switch the FTDI in program mode. Down to receive DMX via the Max485.

Schematics and board design for my prototype at https://github.com/dargs

Arduino Dmx Fade Code

Finding info on the mp3 trigger board I have, as I have the original design is hard.

Arduino Dmx Fade

Trigger pins are active Low, pulled high internally, so to trigger, external uC needs to make the pin low (to ground) to trigger. I think it’ll play the whole track, then look to see if any trigger pins are low, otherwise stop. This is going to make programming annoying, as you’d have to wait until the 30min track finishes before triggering again. Hmm.

SD card fat16 or fat32

Arduino Dmx Fade

Arduino Dmx Code

001xxxxx.MP3

Waiting on a new WAV Trigger board to arrive, then the plan is to use teensy v3 to make a fancier system.

DMX Ch = Track #

DMX Value = 0-5 = Stop

DMX Value = 6-10 = Pause

DMX Value = 11-15 = Resume

DMX Value = 16-20 = Start (from beginning)

DMX Value = 21-255 = Volume (0-100%)

Update- Part 2

I’ve realised I probably could use software serial between the atmega and wave trigger, keeping the hardware serial for the DMX connection.

I’d also planned to design a opto and DC isolated interface, but came across the same author of the DMX Serial arduino library,Matthias Hertel, has designed a board already: http://www.mathertel.de/Arduino/DMXShield.aspx So will probably get some pcbs made and order some parts.

I now have a robertsonics wave trigger board, and reading this tutorial: http://robertsonics.com/2015/04/25/arduino-serial-control-tutorial/

Arduino Dmx Decoder

That worked almost first go, I had to download an older version of the code- Apr 26, 2015 commit – due to comms issues in Sept 2016 version

Arduino Dmx Faded

Serial protocol for wavTrigger:

test code. havent tested with dmx input .. yet!