2010-10-23
There are a lot of these Larson scanner implementations out there on the web. I was a fan of Knight Rider, and Battlestar Galactica as a youth (and the BSG re-imagining more recently too). Many times I have thought about building a light chaser to do the KITT/Cylon effect. I've forced myself to overlook the many kits electronics magazines have put out over the years, it always seemed so incredibly tacky, even for someone as geeky as me. Well I have finally embraced my terminally geeky Sci-Fi roots and gone ahead and built my own... I blame the 'flu which had me off work for two days and looking for something to do.
The implementation is quite straight forward, almost too trivial to bother documenting... A common-cathode array of 17 LEDs are driven directly from an Atmel ATtiny2313 microcontroller. The LEDs are mapped to the B, D, and A ports in LSB-MSB order, arranged right-to-left (i.e. PORTB[0] is on the right and PORTA[1] is on the left). The supply voltage is 5 volts, intended to be derived directly from the 5V supply rail of my PC PSU. There is a 100 nF capacitor across the supply pins, but otherwise nothing beyond MCU, LEDs and resistors. 1 K limiting resistors are used for each LED drive line so that an arbitrary number of LEDs may be on at any time without pushing the ratings of the MCU device (peak supply current < 60 mA which is highly conservative). The LEDs used are extremely bright, high efficiency devices and running them at their 20 mA rating would be dazzlingly bright anyway - perhaps a feature if you so desire the over-the-top late-70s effect (but bear in mind the tiny2313 is rated 200 mA Vcc supply max).
The template for the LED array produced using a little bit of PostScript. (The PostScript file is included in the firmware package if you want to use it.) I decided to mount the LEDs in a spare drive bay bezel to Cylonify my workstation, so it is based around the standard drive-bay size. The holes were punched and the LEDs held in place with a little hot-melt glue. The wiring harness uses rainbow cable rather than my usual twisted bundle of fine magnet wire - I did not desire the otherwise rather daunting task of sorting out 18 identical wires!
Two firmware versions were written. The first is a very straight forward bit-shifting one with suitable busy-waiting delays. It simply illuminates the LEDs in turn, pausing at the edges a little. It took me about 7 minutes to write, it is hardly elegant and can probably be done better. You can change the delays to taste with the two defines at the top of the file.
The alternative version uses PWM and implements the more pleasing filtered exponential decaying display you can see in the video at the top of this page. It took quite a bit longer to write, but is still very brute-force. Feel free to improve it as you see fit. The basic scheme is a PWM logic loop with a decay routine for each LED bucket that runs as fast as possible and a roughly 30 Hz interrupt that scans back and forth filling the buckets.
Using the PWM code the circuit pulls about 11 mA average. The bit-shift version lights only one LED at once and uses a slower clock so it pulls only about 4.5 mA. The clock rate on the bit-shift version could be dropped much more without changing the functionality, but the current saving is minimal so I did not bother, it uses the device default 1 MHz RC clock. The PWM code is very timing constrained and could really use a bit more clock rate for smoothest display rendering, it runs at 8 MHz.
A solar cell connected to a pizeo element lets one snoop on the display PWM...
I built this little solar cell/piezo tool for checking infra-red remote controls around the house and otherwise listening to amplitude modulated lightwave signals. It is completely passive, no power supply or amplification, so while relatively insensitive it is never flat when you need it!
5 comments.