Ax Man surplus in Minneapolis is a magical place. They have tons and tons of electronic and industrial surplus, plus a bunch of just general weird crap. It helps that the place is packed with the bizarre inventions of the owners and employees (robotic mannequins with mismatched limbs, motion sensing babies that cry when you walk by with a chilling robotic scream, etc.).
Last time I was up there, I found a board with a bunch of seven-segment displays, a chip, and a 6-pin connector. I thought the chip might be an LED driver I could look up, so I took a $2 bet and bought it, figuring I might be able to reverse engineer it.
The chip turned out to be a common LED driver, the MAX7221. I applied the circuit tracing technique I described earlier, and found that the connector easily mapped to power, ground, and signalling for the chip. So I made a clock out of it. Also, I spotted why the board was sent to surplus:
What a waste for Tactile Systems Technology…a whole run of boards fully populated, thrown out because of a silk screen typo :-). That company is still around — they make medical gear, so I guess the thought of a life saving device with a typo was a non-starter.
Build directions after the break.
To test it, I just needed to build a little Arduino circuit and sketch to drive it using Eberhard Fahle’s MAX7221 library. I played with it for a while before finally settling on a clock design based on an ATtiny44, an Arduino-compatible microcontroller that’s about $2 retail. I slapped on a 16MHz crystal (since the ATtiny’s onboard oscillator isn’t precise enough for timekeeping), a DHT11 temperature sensor ($2.44 from FastTech), and two tactile buttons. Here’s two shots of the breadboard from front and back:
In developing the software, I found that Eberhard’s MAX7221 library was too big to fit on the 4kB of flash and 256 bytes of RAM of the ATtiny44. I had an ATtiny84 with twice the flash and RAM, but I wanted to use this chip and be rid of it. So I wrote my own simplified MAX7221 library, leaving out the font and detailed options of Eberhard’s. I also added a blink facility so I could get that classic 12:00 VCR blink action :-). You can get it here if you want: max7221lib. No documentation, because I can’t be bothered, but it’s simple.
For timekeeping, I found Michael Margolis’s Time library. Initially, it seemed that it would be too big for me to use (it seemed to bump the compiled size up by 2kB by itself!), but I happened to notice that the size shrunk drastically when I removed my call to the version of setTime() that took day/month/year/hour/minute/second. This is because the code behind this has to do all kinds of complicated calendar algorithms to convert the time — when I switched to UNIX time to initialize the clock to midnight — setTime(30L*24*60*60) — it worked quite well and used very little space.
For power, I took an old USB charger, chopped off the end, and soldered on a 2-pin 0.1″ header, topping it in hot glue for insulation. I tied a knot and zip-tied it to the frame for mechanical stability.
In the end, the total cost was $2 for the board, $2 for the ATtiny44, $2 for the charger, $2.50 for the temperature sensor, and near-zero for the wire and crystal. All told, a decent clock+thermometer for $8.50. Source code is here if anyone is interested…should work with any MAX7221 chip hooked up to seven-segment displays: AxeManClock.zip.