With a cupboard full of old hard drives and some spare time, I recently set about making a persistence of vision clock. Using the platter of a hard disk, a slot is cut to allow backlighting to be emit. When the disk is spinning at 5400rpm+ and backlight constant, the disk appears opaque, as the slit is ‘refreshing’ each point of the revolution faster than our eyes. The trick is to measure the revolution time then flash or change the backlight colour at a fraction of this revolution time at the same point each revolution, in order to create a light segment. For example, flashing the light at a frequency twelve times the disk frequency in phase with the disk will create 12 light segments:
Expanding on this, one can create a light based clock, which takes some getting one’s head around on first sight!
It isn’t just hard drives that have to suffer for this: in order to detect the speed of the disk, I used an IR LED/photodiode break detector, salvaged from a floppy drive. The component is a nice horseshoe arrangement, used to detect whether a floppy is in the drive and that saves having to construct something myself. A bit of reverse engineering with a multimeter and I had the pin arrangement:
Taking apart the Maxtor, there where two platters. I took both off with the read arm, cut a slit in one and threw away the other. Having gutted the drive, I stuck 5050 RGB LED strip around the parameter of the area the platters sit. The strip is the perfect height of the casing but I required a few washers to raise the disk above the LEDs. It’s a very tight fit and I’m sure the guys who precision designed these things would cry to look at it!
With the disk remounted, I positioned the IR sensor so that the disk spins through it. A splodge of hot glue and it’s held in place nicely. Having installed custom washers and cutting the disk, it wasn’t mounting true. A bit of tweaking of bolt tightness and I got it running straight enough to clear the IR sensor and registering a HIGH signal each revolution.
The breadboard components:
- 3*TIP122 transistors to drive the RGB strip, with bases connected to the Arduino PWM output pins. Like:
A resistor potential divider, creating the level for the comparator interrupt (pin 7).No longer needed once I wired the IR sensor correctly.
The stage I’m currently at and the main reason I built the thing; it presents an interesting programming challenge and a chance to learn about timer interrupts.
So far I’ve got code that can measure the revolution time using a hardware interrupt triggered by the IR sensor. Using a fraction of that time to blick a colour creates a segmented pattern but not steady or what I would expect. The problem I think being that the blink can be interrupted by the IR sensor, throwing the timing out. I’ve toyed with using a timer1 interrupt set to a fraction of the revolution but then the hardware interrupt gets…interrupted!
Turning to others code, I can check the thing is working properly and get some inspiration. Here’s a demo of it so far. It includes a clock python script that uses pySerial to drive the Arduino via serial. Pretty neat and I can see myself finally learning Python for this: