-
Notifications
You must be signed in to change notification settings - Fork 4
Drift correction
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:
- Set the drift correction to 0 in “set drft”
- 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.
- Wait a week or two without touching the time setting (the longer the better calibration)
- Check the time, and work out how much it has drifted.
- If it hasn’t, then you’re done! Lucky you, you have a perfect crystal!
- If it has, then you need to work out:
- How many hours it is since you set the time
- How big the drift is
- Work out seconds/hour
- 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.)