Jul 10 2009

Rev13 of the Arduino DMX Reception Software Released

New in this version:

  • Tested and working with IDE version 0016.
  • The number of channels to receive is now easily user-configurable.
  • Replaced static variables with #define statements for RAM optimization (+48 bytes, woot!).

You can grab it here or mosey on over to the original post for the instructions.


May 12 2009

Rev12 of the Arduino DMX Reception Software Released

p1000328

New in this Version:

  • In-the-field addressing via two tact switches (works with the previously released I/O Shield, here).
  • Address is stored in non-volatile EEPROM, so it is retained when power is lost to the Arduino.
  • Addressing hardware allows full use of the pins (which is why I didn’t use the more conventional dip switch setup).
  • Some of the variables were localized, since the sketch is now getting pretty complex.

The latest software can be downloaded here, you may also want to check out the release notes here.

How to Set the Address:

I’m going to assume you’ve built yourself a DMX I/O shield, if not, you can take a gander at the schematic and set it up on breadboard.

There are two tact switches on the shield, a ‘1′ switch and a ‘0′ switch.

If you press and hold both switches, then hit the reset button, the starting DMX address will be reset to dimmer 1.  The pin 13 LED (marked as ‘ERR’ on the shield) will flash a few times in confirmation.

For other addresses, you’ll hold down either the 1 or 0 switch (but not both), then hit the reset switch.  The pin 13 LED will light up and stay on.  Then you’ll enter your desired address in binary, least significant digit first, by alternately hitting the 0 and 1 switch.  As you enter each bit, the LED will turn off for a moment to confirm that bit was set.  When all 9 bits are received, the ERR LED will flash a few times.  If you make a mistake, just start over by holding down one of the switches and hitting reset.

An Example: let’s say we want a starting address of 246.  246 in binary is 011110110.  You can get this number in couple of ways.

  • Mathematically,
    246 = 0*256+1*128+1*64+1*32+1*16+0*8+1*4+1*2+0*1
      =  29 + 28+27+26+25+24+23+22+21+20 = 011110110
    (Depending on how well you know your powers of 2, the above will be obvious or complete gibberish)
  • In Windows, by firing up the calculator, going to View>Scientific, entering “246″, and hitting the “BIN” radio button
  • In Google, by entering “246 in binary” in the search box
  • By looking it up in your familiar DMX dip switch chart, like this one here.

So thus far, the same process as addressing any other piece of equipment.  Now, hold down the 1 or the 0 switch, and hit reset.  The ERR LED will come on, signifying that we’re in addressing mode.

Now enter the above binary sequence, starting with the smallest number: hit the 0 switch, then the 1 switch, then 1, 0, 1, 1, 1, 1, 0.  The LED will briefly turn off every time you hit a switch.

After all 9 bits are entered, the LED will flash several times.  The board is now addressed to 246.

Another Example: Channel 131.  Hold down the 0 or 1 switch, hit reset, enter 1, 1, 0, 0, 0, 0, 0, 1, 0.

Note: Once the address is set, the pins 11 and 12 may be re-assigned for any other use.  That’s why I did it this way, rather than using a conventional dip switch, which would have taken up 9 pins on the board (I’d be lying if I said I wasn’t a little impressed by my own cleverness here).  The pins are configured with internal pull-ups in setup() as:

digitalWrite(pin0, HIGH);       //turns on the internal pull-up resistor for pin 11
pinMode(pin0, INPUT);           //sets pin 11 to input
digitalWrite(pin1, HIGH);       //turns on the internal pull-up resistor for pin 12
pinMode(pin1, INPUT);           //sets pin 11 to input

Pressing the switches grounds them, setting the pin to LOW.  So, exercise caution when using the pins for anything that doesn’t like to be grounded, is the only caveat.

Known Bug: for some reason, sometimes when you hit the 0 or 1 switch it doesn’t take.  I’ve programmed the LED to turn off briefly if the bit was successfully entered, so if you don’t see it go off, you’ll have to hit the switch again until it takes.  I don’t know why it’s doing this, if you have some time to wade through the logic let me know why and I’ll update the code.

The Astute Reader Will Wonder: why we don’t enter 000000000 for the first address.  True, DMX addresses actually run from 0 to 511, so dimmer 1 is actually listening to dmx address 0.  I’ve seen gear that takes this into account and automatically adds 1 to your desired address, and gear that you subtract 1 from your desired address.  Since there doesn’t seem to be any standard, I’ve opted to let the software do it for you because it’s easier.


Apr 29 2009

Arduino DMX-512 I/O Shield

p1000325

Breadboard is Great and All, But it’s not going to survive a six week run with actors tripping over it and that kid’s show that runs on Sunday mornings.  So here’s a shield that can fit onto your Arduino and securely hold all your connections in place.  It is tested and working with the dmx reception software I wrote for the Arduino.

Features:

  • Same hardware be used to receive or send DMX, so you only have to build one shield.
  • Onboard termination switch.
  • Reset switch brought to top of shield for easy access.
  • Pin 13 LED brought to shield for status/error messages.
  • Two tact switches allow in-the-field addressing, without permanently disabling any pins.
  • Header sockets for easy prototyping.
  • Solder through-holes for permanent installations.

Note: I changed the pin assignments slightly from early versions of the software to allow easier routing.  Pins 3 and 4 in the software are now pins 2 and 3, respectively.  As of Rev11 this change has been made, get the latest version here.

Continue reading for the parts and instructions…


Apr 1 2009

Rev10 of the Arduino DMX Receiver Code Released

New in this Release:

  • Cleaned up and improved code commenting.
  • Adjusted HardwareSerial.cpp (included) so the code will compile on Arduino software release 0015. If you’re still using 0014 or 0013, you’ll replace wiring_serial.c instead (also included).
  • Replaced manual register configuration of the USART with the Arduino function Serial.Begin(250000), which apparently works just as well and reduces the number of Atmega168-specific register calls considerably.
  • Moved the action() loop (what you want the Arduino to do with the received values) to its own tab, to make the code easier to use.

I’ve updated the instructions, or you can download the updated code directly here.

As always, let me know how works for you, or doesn’t.


Mar 24 2009

A New Floor Lamp, Part III

Or, dispensing with the floor part:

fluorescent-tubes-rev0-cu

fluorescent-tubes-rev0-widefluorescent-tubes-rev0-xcu

The source would be 2′ long T5 fluorescents.  Same perf metal material as before, although I upped the perforation size as I’m not going for a fluid organic effect here.

The lamps could possibly be supported by some kind of tensegrity scheme, which would hopefully reduce the number of wires I need to run to the top.  The screen in this case would be simpler, I could probably get away with just riveting it to close it.

Mainly, it becomes a ballast problem.  It would have to dim, and dimmable T5 fluorescent ballasts are outrageously expensive.  Also, off the top of my head no one makes a 3-lamp ballast for 2′ T5s, so I’d be looking at 2 ballasts, or about $2-300 just on ballasts.

there are some parts that would be difficult to source, such as the 3-way support rod and the lamp sockets, but for the most part this is the simplest to construct.

Hmmm.  I’m going to watch House now and drink some beer, and let this one sit for a few days.


Mar 24 2009

A New Floor Lamp, Part II

Or, I Could Do Something Like This:

perf-screen-cu

perf-screenperf-screen-side-cuwhite-environment-rendering-perf-screen

In this concept, there would be a helical-spiral perf metal screen which would act as a diffuser.  The source would be an MR-16 or similar mounted in the base, pointing up.  The perf screen is generated as a parametric surface governed by the following equations:

X(u,v) = cos(u)+1.5*u*sin(u)

Y(u,v) = sin(u)+1.5*u*cos(u)

Z(u,v) = .5*u*v

u ∈ [4, 15], v ∈ [1.5, 27]

Looks complicated, but the shape is just a trapezoid rolled up into a cylinder.  I like the moire-interference pattern cast by the overlapping layers of perf metal, but in order to get a nice clean finish on the edges I’d have to wrap them in some kind of metal beading, as well as support the whole thing with vertical rods, and I’m not sure I can do that without welding.  So the screen might end up being handmade paper or something like that.




Mar 23 2009

A New Floor Lamp

There’s a Corner of my Apartment that is a Problem. See, my windows face north, so even on sunny days, which are rarer than unicorns here in Portland, I don’t get direct light into my rooms.  During the summer, this means that my apartments stay cool during the day, which is nice.  But in winter particularly, this corner is sort of dim and less than appealing.  Here’s a picture of it:

The offending area of my domicile.

The offending area of my domicile.

Leaving aside the rats nest of cables over by the stereo, which is something else on my list, you can see how this corner just sort of dies, especially at night when there’s no light coming in from the window.  So, I could go to Ikea and pick something out a torchere, which is where everything else I own comes from, or I could design and build something myself.  Here are the preliminary designs I’m working with:

Curved Wood Concept:

curved-wood-rev1-cu


curved-wood-rev1-insidecurved-wood-rev1-side-cuwhite-environment-rendering-rev0white-environment-rendering-rev0-cu


This would be a steam-bent curved plank of wood, with the source being either T2 miniature fluorescents, cold cathode, LED strips, etc.  In the far right thumbnail you can see where that would live.

I think I could steam the curved plank inside a large piece of PVC pipe, as shown:

steam-chamberAnd then bending it in a jig, like so:

steam-jig

I’m going to work with a few other designs and see what I come up with.


Mar 20 2009

Receive DMX-512 with an Arduino

arduino

Shiny and new out of the box!

Prologue: For Christmas, I received an Arduino.  If you’re not familiar with them, they’re like a little computer with a lot of pins to which you can connect outputs like LEDs, servos, relays, triacs, or anything you’d want to control, as well as photosensors, switches, anything you’d want to take an input from.  You write your program in the easy-to-learn Arduino environment, upload it to the Arduino board, and it’ll run your program automagically.  I’m not a programmer, but less than an hour after taking it out of the box I had it blinking an LED for me.  Buy one, they’re perfect for all of us who are trying to create some Theater Magic with no money or hope of getting any.

Well, Almost Perfect.  There’s been a way to send DMX with an Arduino for awhile, but when I started poking around for DMX reception code, I came up with zilch.  If you’re already savvy with microcontrollers and assembly code and avrdude and whatever-the-fuck-else, you probably know about this solution.  Me, I look at assembly code and I just hear a dull screaming in my head, nevermind all that other stuff that I don’t know how to do either.

So I figured that a great first project would be to remedy this situation, and write a program to receive DMX on the Arduino platform.  In the way of all Works in this Vale of Tears, this ended up being much more difficult and taking much longer than I initially anticipated.  But eventually I figured it all out, and so here it is!

Features:

  • In-the-field addressing from 1 to 512 via two tact switches (works with the previously released I/O Shield, here).
  • Address is stored in non-volatile EEPROM, so it is retained when power is lost to the Arduino.
  • Addressing hardware allows full use of the pins.
  • Number of addresses to receive is configurable.
  • Works with controllers that send less than the full 512 address set.
  • Break detection is done correctly by detecting a Low value of >88μS per ANSI E1.11-2008, rather than the frame error hack used by many devices.
  • Uses interrupt-based subroutines to eliminate processor-load related timing problems.
  • 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.

Continue to Page 2 for Download and Instructions…