Hi All, I've written a sketch that allows you to receive DMX-512 with an Arduino. If you're not familiar with it, DMX is the control protocol for theatrical/live event lighting. It's been possible to send DMX with an arduino for quite awhile, but this will allow you to receive DMX values and execute your custom code accordingly.
The code is quite long, and there's some hardware setup and malarkey with the wiring_serial.c file involved, so I'm just going to give you the link:
It's my first project with the Arduino, and I worked really hard on it, so please let me know if it works for you and how you like it.
It has the following features: - Capable of receiving 8 contiguous addresses from 1 to 505. - Works with controllers that send less than the full 512 address DMX frame. - Break detection is done correctly by detecting a Low value of >88[ch956]S per ANSI E1.11-2008, rather than the frame error hack used by many devices. - Uses interrupt-based algorithms to eliminate processor-load related timing problems. It may be of general interest to those in this forum who are trying to get interrup-based sketches off the ground - If the DMX data signal is lost, the Arduino will maintain the current state until new values are received. - The reception and user code run sequentially rather than at the same time, so they won't interfere with each others timing.
And the following limitations, as of now: - Atmega168 based processors only (you will have to rename the registers and interrupt vectors if you want to use it for another processor). - Currently only tested with a USB-DMX Pro controlled via Lightfactory and MagicQ software, since that's what I could get my hands on. But it handles a variety of frame rates, break lengths, etc. just fine. If you're in the Portland area, and you'd like to let me test it with other controllers, drop me a line. Also, if you use it with other controllers, let me know how it turned out. - Because I needed access to exact timing, I had to use the Timer2 functionality, so pins 3 and 11 cannot be used for PWM. - Will not detect bad addressing, such as “dmxaddress=510;” or ”dmxaddress=50;” when only 55 slots are sent by the controller.
I'm still developing and improving the software, so check the link above for the latest version.