Meow Wolf’s Due Return starfield: EXPOSED!
One of the things I’ve been working on during my protracted absence from my blog is a computer-controlled field of stars for Meow Wolf, a Santa Fe-based artist collective known for their anarcho-utopian-egalitarian mass installations in various places throughout Santa Fe. The typical Meow Wolf show has more stuff by more people crammed into it than could ever really be absorbed.
They have a large show coming up at the Center for Contemporary Art that involves an interdimensional, time-travelling wooden ship, an interactive alien landscape, caverns, a number of performances (with up to sixty characters played by various MWers, I’m told), musical acts, dance parties, and a lounge.
And a 400-light, 48-circuit, computer-controlled field of glowing stars that blankets the whole spectacle, which will be in a perpetual nighttime state. That’s what I’ve been working on, along with sculptor Mat Crimmins.
Technical details? Including code? You bet! Details after the jump.
The design is fairly straightforward: each of the 48 circuits has a brightness value (0-255). The circuits are represented by a 48-byte matrix inside the SRAM of an arduino. Modulating the brightness of each circuit is accomplished through pulse-width modulation. Arduinos don’t have 48 channels of PWM (heck, even the Mega only has 14 channels or something like that) so we fake it by blasting a bank of six shift registers (74HC595s) with serial data, toggling the circuits on and off as quickly as possible.
But, arduinos programmed in wiring are slow as hell. They don’t stand a chance of writing to the shift registers quickly enough to avoid horrifying strobing of the LEDs. So, I assist the arduino with two more microcontrollers, ATtiny2313s in this case, each dedicated to the task of strobing the shift registers quickly enough to do a decent PWM.
The arduino writes out its data to the tinys in parallel, so eight pins per tiny are dedicated to incoming data, plus a clock line, plus a reset line. Both tinys share one clock and reset line, so the total number of pins leaving the arduino is 8 + 8 + 2 or 18. Also, the starfield needs to be able to communicate with a computer over USB, so pins 0 and 1 are dedicated to that. If you’re counting, that’s 20 pins total: every single line on the arduino is occupied. Good thing you can use the analog input pins as digital outs!
Initially, I was dismayed to find that, even wired up to a speedy 20 MHz crystal, the tinys could only manage about 63 “frames” per second. With substantial optimization however I was able to get the speed to around 180 Hz, at which point they don’t strobe so bad. Ultimately I wound up hand-optimizing the new pixel (i.e. the clock line) interrupt in assembler and placing certain critical variables in dedicated registers. This wasn’t critical to PWM performance but I’ve always been bothered by how careless avr-gcc is when it pushes a dozen variables to the stack for interrupt service routines.
The secondary engineering challenge for the starfield was the amount of current the whole thing draws. The math gets scary quick: each super bright LED consumes about 20 milliamps of current. Each star has 3 LEDs, for 60 mA of current draw total. There are 384 stars, capable of consuming 23.04 amps total. That’s nothing to sneeze at! The number for the individual circuits aren’t so bad: 8 stars per circuit leads to 480 mA, which is manageable. But I found out the hard way that common transistors sweat a little under this load. It only takes a few seconds at this load for a common 2N4401 to grow hot to the touch.
The next step up is a power transistor in some kind of upgraded package, like a TO-220 or TO-3. These packages are easily heat sinkable but bigger. But, troublingly, the hFE of these transistors is low. Running the numbers on the shift registers, the 74HC595 that we were already using can only safely source something like 9mA of current — assuming that some of the current will be dissipated by the long cable runs over thin-gauge wire, and it’s not so certain at all that we’d be able to switch the full load on and off. So I went with a darlington pair, the TIP120.
Then I found out that one of the drawbacks of darlington pairs is their low switching speed. So as soon as the order came in I spent some time testing the TIP120s with a function generator and dummy load and found them good to around 100k. Phew. Another non-problem for our application.
Another possibility would have been to use power MOSFETs for the load switching. MOSFETs only need voltage to switch loads on and off — unlike a BJT, which must sink or source a small amount of base current. But my experience with MOSFETS is that they’re fairly delicate, easy to destroy through static electricity or improper handling, and susceptible to noise. I’m sure the design would have been fine with a cheap IRF510 or something, but I went with the darlingtons since I’m an amateur and the budget was too thin to tolerate many mistakes.
The next problem was the power supply. What can put out around 30 amps at 5 volts? Well, professional AC/DC power supplies available from Jameco, for one, but I happened to have a few ATX computer power supplies laying around which are capable of driving that sort of load. But when you compromise, you always wind up having to deal with a whole host of secondary challenges: the ATX power supplies were specced to about 25 amps, which made me nervous. So I decided to use two of them. In fact, not only are half the stars powered by each power supply, but half the controller mainboard as well: the entire project is partitioned in two, straight down to the tinies. So each power supply should only see around 15 amps drawn from the 5V rail, max.
One unforseen drawback to using computer power supplies in this context — or at least the ones I already had — is that they have minimum load requirements. Apparently this is typical of switching power supplies. They need to draw an amp or so to keep the switching regulator happy. So, after much consternation, I found a pile of 20 watt resistors at a local surplus shop, which I mounted to some steel tubing with heatsink paste and placed them close to the power supply fans. Attached to the 12v rails, they get quite warm but the temperature appears to be stable around 130 degrees fahrenheit.
Determining what load was necessary was an interesting experiment. Using an oscilloscope I monitored the 5v and 12v rails under various resistive loads and found that around half an amp from the 12v line removed a significant amount of ripple on the 5v rail, substantially quieting things. This corresponds to about 22 ohms and around 6 or 7 watts of heat dissipation. The preferred requirements could be higher, but I’ve been flying by the seat of my pants for this entire project. Besides, the 5v lines to the circuitry are heavily bypassed which removes quite a bit more of the residual noise, and the power supplies have been able to run for many hours without complaining. So I think it’ll be good to install on Thursday.
Below is the source code for the ATTiny2313 firmware. It may prove interesting for anybody who needs to control a pile of LEDs via fake PWM as I’ve done in this project. The first block is the main body of the code, written in C, then the C header file, then the assembly routines for the interrupts.