I know the hardware types are busy with gps, wwvb, internet and other hardware mods but here is a simple way to add a calibration factor.
Low cost quartz watches like my $20 Casio are rated at ± 15 seconds/month. I have built RTCs with a crystal like the one in the Ice Tube Clock that are accurate to less than one second per day so it should be possible to improve the accuracy of the Ice Tube Clock.
The idea is to shorten or lengthen the first second of each hour. This will allow the rate of the clock to be adjusted in units of 24/256 or about 0.1 second per day.
This mod has not been tested on the Ice Tube Clock since my daughter won’t let me touch her clock so there may be bugs.
Here is the mod that I tested on a 168 Arduino simulator.
Code: Select all
// use a calculator for this calculation
// if losing time
// cal_factor = - (<seconds lost per day>*256)/24;
// if gaining time
// cal_factor = (<seconds gained per day>*256)/24;
//
int8_t cal_factor = <set it to the above result here>;
if (cal_factor < 0) {
// clock slow - shorten first second of hour
TCNT2 += -cal_factor + 1;
}
else if (cal_factor > 0) {
// clock fast - lengthen first second of hour
uint8_t tmp = TCNT2;
while ((TCNT2 - tmp) < cal_factor);
TCNT2 = tmp;
}
Code: Select all
// an hour...
if (time_m >= 60) {
time_m = 0;
time_h++;
// lets write the time to the EEPROM
eeprom_write_byte((uint8_t *)EE_HOUR, time_h);
eeprom_write_byte((uint8_t *)EE_MIN, time_m);
}
Here is a chart of measured results on the Arduino test setup for -50 < cal_factor < 50.