Introduction: Dmx From the Electric Imp
The Electric Imp is a fantastic little wifi-enabled microcontroller. It is basically like having an Arduino, a WiFi-shield and a Cloud-service in one package.
You don't get as much full processor control as on the Arduino, though, because the Cortex M3 are doing all kind of things behind the scenes to keep the WiFi and cloud connection up and happy.
Because of that, it was impossible to use protocols like DMX. But from firmware 30 around October 2014 the issues preventing DMX to be used have been resolved, and now it is possible.
The good guys at Electric Imp have done a nice example of how to send DMX, and I thought it would be nice to pack it up in a full example with some hardware too.
- Electric Imp and Breakout Board (Look here to get started with using the Imp)
- Get it from Sparkfun or Adafruit
- Max-485 or SN75176BP chip - Line driver for the DMX line
- 100 Ω resistor
- Female DMX plug
Step 1: Hardware - DMX Transmitter Circuit
I am using the same basic schematic as the classic DMX-shield for Arduino, that I have been using successfully for years.
Watch out! The Electric Imp runs on 3.3 V
There is no protection on the pins of the Imp at all. If you put as little as 3.7 V on a pin, you are almost certainly going to fry it.
The breakout board, though, takes 5 V and have a regulator for the Imp.
The Max-485 / SN75176 runs on 5 V too, but luckily the input high level threshold is 2 V, so the 3.3 V coming from the pin is fine. This saves us using a 3.3V - 5V level shifter. We are good because we are only sending data from the Electric Imp and are not receiving.
Things to be aware of
- Make sure you get the hot/cold lines for the DMX correct.
- Remember not to put 5 V into the Imp. It will die. (I have my first Imp buried in my back yard..)
Step 2: Code - Agent and Device Code
All code for the Electric Imp is done through an online IDE. No cables or anything needed.
Visit the developer center for the Electric Imp to learn how to code it
Agent Code (github)
The agent now have a http-request handler, to handle incoming commands.
I have implemented two ways in this example:
Raw DMX data in query string.
This means: Channel 1: 0, ch 2: 255, ch 3: 0, ch 4: 2502
Using the Color Picker from the Pitchfork App
The iOS app Pitchfork have (among other clever things) a nice color picker, that sends out the selected color as a JSON.
In the example, one color is received, and multiple fixtures are set to this color.
Device Code (github)
Not much new here. Just a little bit of modification to the Electric Imp DMX512 example
function dmxFromAgent(dmxValues) : Takes a dmxValues-array from the agent and sets each channel accordingly
function OneColor(data) : Takes a single color table and sets several fixtures to that color.
As seen in the video on the first page, the color changes are quite fast. There is very little latency, which is great for the feeling of being well connected to the object controlled.
Step 3: Box It - Small Size Fits Everywhere
Thanks to the small form factor of the imp, it is easy to fit it into a tiny enclosure.
I managed to easily fit the dmx hardware on a piece of proto-pcb no larger than the imp breakout board.
Just remember to keep easy access to the imp for when you need to BlinkUp new WiFi information.
At the art ship illutron in Copenhagen, we have dmx-controlled RGB-spots all around the ship. The colors of the ship can be remote controlled from everywhere by everyone.
The system used to be based on an Arduino + Max/Msp + Google Talk + Google App Engine solution, but the Electric Imp is going to simplify this setup very much.