HDD Clock

October 22, 2012

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:

$latex f_{light}=12.f_{disk}=\frac{12}{p_{disk}}$

Expanding on this, one can create a light based clock, which takes some getting one’s head around on first sight!

Donor Parts

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:

<figcaption id="caption-attachment-139" class="wp-caption-text">The pin arrangement for the horseshoe IR block sensor. Using the circuit shown, it was not a clean digital signal (rather 0/1V). After setting up a comparator interrupt using a potential divider at 1V (which did work), I realised I was being stupid and tied the 270ohm resistor to ground instead, given the photodiode a full 5V to work from and allowing me to use the simple digital interrupt.</figcaption></figure>

<figcaption id="caption-attachment-140" class="wp-caption-text">The HDD was a 120GB that had given up the ghost long ago. It doesn’t say but I believe it to be a 7200rpm.</figcaption>

Construction

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!

<figcaption id="caption-attachment-147" class="wp-caption-text">The horseshoe sensor mounted to the chassis. It’s surprisingly well held.</figcaption></figure>

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.

<figcaption id="caption-attachment-146" class="wp-caption-text">The drive rests on a tea towel to stop it vibrating off the desk. An ATX power supply with green and black pins jumped is used for molex and 12V power.</figcaption></figure>

Programming

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: