Vetinari's clock

Lord Vetinari is a fictional character in Terry Pratchett's Discworld series. In his waiting room, he installed a clock which produces an irregular ticking and nevertheless keeps a perfectly accurate time. This is a real life realization of this clock. The seconds hand is irregular but in average the clock keeps on time.

Principle of operation

This project is based on an analog clock driven by a quartz oscillator. In this kind of clock, the timebase is produced by a quartz oscillating at 32768 Hz whose frequency is halved 15 times to produce a 1Hz signal. This signal drives a solenoid which moves the seconds hand of the clock. We just need to drive directly the solenoid from a microcontroller to make the time pass at the pace we want.

Principle of operation of the clock.

The microcontroller which drives the clock is a MSP430G2211 from TI. It has several features which make it a perfect fit for this kind of project :

It is compatible with the MSP430 Launchpad which can program it for $4.30.

It is cheap ! (included in the Launchpad or free samples provided by TI)

It is very low power, which is required in this kind of battery powered project.

The firmware is extremely simple, an interrupt is triggered by a 32768 Hz quartz oscillator which wakes the µC up every 1/64th of a second. The length of each second is initially randomly chosen (by a linear feedback shift register) between 10/64th and 118/64th of a second. This ensures that after counting N seconds, an average of N true seconds have elapsed.

Nevertheless, the standard deviation of the number of true seconds elapsed is proportional to N , thus it increases with time (even if the relative error is proportional to 1/ N and decreases with time). The firmware includes a compensation mechanism which produces seconds which are in average a little bit shorter when the clock is too early compared to the real time and longer seconds when the clock is late. The time remains accurate to a few seconds.

Finally, the MSP430G2211 requires a minimal voltage of 2.2V, the clock cannot run on a single 1.5V battery like the original clock. Thus I used two 1.5V batteries connected in series.

Possible improvements

After a few tests, it seems that the clock is using a little bit too much current which shortens the batteries lifetime. (which is around a few weeks) I don't know why...

The random numbers are generated by a deterministic algorithm. We could imagine using a random physical process to produce these numbers (like the thermal current noise in a diode)

Maybe I should use some clamping diodes to protect the µC against voltage spikes from the coil. The fact that it survived until now suggests that these are not really needed.

According to some comments, this clock does not behave exactly as an authentic Vetinari's. The irregularity in the ticking should be much more subtle and hardly noticeable. So the when it occurs, the person who notice it wonders if he is not mad. Nevertheless I find the current version of the clock much more fun to watch so I'll leave it like that !

Pictures

Video