The HDD Clock uses the principles of persistence of vision to draw a clock face. The design is quite simple. A HDD platter has a slit cut into it. When spinning at 4200RPM the slit becomes an invisible blur to the naked eye. The circuit keeps track of the location of the slit and when the slit is in an appropriate spot on the clock surface an LED briefly lights up the area behind the drive platter. The end result appears as steady coloured lines drawn at specific rotations to create the hands of a clock.
The donor HDD is a 2.5″ notebook drive with glass platters. It spins at 4200RPM which is sufficient for our persistence of vision method and the slow speed actually makes it easier to “draw” a thin line representing the hands as the LED pulse can be longer. The shorter the pulse the dimmer the apparent light and on high rotational speeds the thicker the clock hand.
Modern HDD with glass platters are surprisingly difficult to cut. Fortunately there were 3 platters in this drive. The first 2 shattered during cutting. The cut was made using a diamond engraving bit on a Dremel while the platter was submerged underwater (I think this was the key to preventing the platter from breaking). Behind the platter white paper was mounted to the drive to help reflect more of the LED light, and SMD 3 colour LEDs were mounted in 5 locations around the outside of the platter in groves.
The circuit is based around an ATMEGA88. Timekeeping is done by a DS1388 real time clock connected to a 32.768kHz crystal. Not the most accurate timepiece but sufficient to prove the clock works. The DS1388 has a built in trickle charger for a supercap, and the 5.5F capacitor can hold time for several days without a power. This was chosen over a CR2032 lithium battery as it won’t need to be replaced. As the LEDs are pulsed it is possible to pump in excess of 1A through them before thermal runaway becomes an issue. As such the LEDs are driven by simple NPN transistors. The time is set by 3 buttons (set, up and down). Finally the microcontroller needs to know where the slit is at any given time, the slit is therefore tracked by an open optocoupler, mainly because this worked out cheaper than a hall-effect sensor.
The software is the more interesting part of this build. It is broken up into several parts, the time keeping routines, the control interface, and the drawing routines.
Time keeping routines
The software takes the form of a state machine. The timekeeping routine runs continuously in the main program loop when the system is in the default state. It continuously reads out the current hour, minute and second from the two wire interface to the DS1388 and then converts the resulting Binary Coded Decimal to three integers. These integers represet the location of the three slits as drawn by the drawing routine. This loop is repeated infinitely until the control interface takes the state machine to a different state at which point one of the other states will have control over the integers.
The control interface
The clock is set via three buttons, up, down and set. As mentioned earlier the program is a state machine. There are three states SYS_NORMAL, SYS_HOUR, SYS_MINUTE and SYS_SECOND. In the normal state the program will run the time keeping routines. In the other three states we’re taking direct control over the hour, minute or second hand using the up and down buttons. The set button will move between states.
- In the normal state the up and down buttons do nothing. The set button will move the state machine to the hour state.
- In the hour state the up and down buttons control the position of the hour slit. The set button will cause the microcontroller to update the hour value in the DS1388, then move the state machine to the minute state.
- In the minute state the up and down buttons control the position of the minute slit. The set button will cause the microcontroller to update the minutevalue in the DS1388, then move the state machine to the second state.
- Likewise for the second state after which the set button will return the state to normal and timekeeping routines will resume reading the freshly updated time from the DS1388.
The drawing routine
Drawing is achieved through the use of external interrupt 0 and two timing interrupt service routines.
INT0 is triggered by the optocoupler and indicates that a slit has just passed. As the optocoupler is not in the 12 o’clock position the slit will be somewhere else on the clock. INT0 therefore triggers TIMER1
TIMER1 is setup with a preset compare value. The TIMER1_COMPA ISR is triggered after a pre-determined time. This time has been tuned during compile to ensure that the slit will now be at the 12 o’clock position. TIMER1 is reset and reset and starts TIMER2.
The TIMER2_COMPA ISR is triggered 300 times in one rotation of the slit, the 300 locations is tracked through a variable called “tick_count”. Each time it is triggered all LEDs on the board are turned off. The ISR then checks to see if the current “tick_count” is equal to the value of seconds×5, minutes×5 or hours×25. If any of these cases is true the appropriate LED is turned on. Finally the tick count is reduced by 1 representing the next position.
This drawing routine will simply set the second, minute and hour hand according to what these global variables are currently set to. Any part of the program can write out data to these variables so the drawing routine controls LEDs in a single position regardless of the the current state of the state machine.
Unfortunately this clock is nothing more than a proof of concept. The motor on the harddisk is actually quite loud with the cover removed. Also an insufficient number of LEDs was used so the display ends up being quite dim. This was somewhat mitigated by painting the HDD platter black however it still isn’t quite as good as hoped. For next time, more LEDs!