Skip to content
jsgf edited this page Sep 13, 2010 · 4 revisions

The Ice Tube Clock uses a 32.768kHz crystal to maintain time. A crystal oscillator is very accurate, but not perfect, and the clock’s time may drift over time (generally on the order of a few seconds per week). The drift may be affected by temperature and other environmental effects, but some of it is just purely a property of your particular crystal.

My firmware has the ability to set a drift correction parameter to try and compensate for the drift. It allows drifts of up to ±0.5 second per hour to be corrected, on a scale of -64 to 64. A negative number makes seconds shorter and so speeds up the clock; positive makes seconds longer, slowing it down.

To set up drift correction do:

  1. Set the drift correction to 0 in “set drft”
  2. Set the time as accurately as possible against a good reference (a GPS is ideal, but a computer with internet time should be good). Note what time you did this.
  3. Wait a week or two without touching the time setting (the longer the better calibration)
  4. Check the time, and work out how much it has drifted.
  5. If it hasn’t, then you’re done! Lucky you, you have a perfect crystal!
  6. If it has, then you need to work out:
    1. How many hours it is since you set the time
    2. How big the drift is
    3. Work out seconds/hour
    4. Set the drift setting to (seconds/hour)*128, negative if the clock is slow, and positive if it is fast

For example:

If you’ve set the clock at 9am on Nov. 13th, and you check it again at 9am on Nov. 27th. Over that period, the time has drifted +20 seconds.

The period is precisely 2 weeks = 14 days = 336 hours

The drift is 20 / 336 = 0.05952 seconds/hour

Therefore the drift correction parameter is going to be 0.05952 * 128 = 7

(Note: I’m planning on automating this process more, but that will take a while to implement.)

Clone this wiki locally