Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.

Re: Ice Tube Clock loosing time

Modern quartz watches have a calibration factor in prom that is set when they are manufactured. I think the factor is set by cutting traces with a laser on some watches.

The firmware for the Ice Tube Clock could be modified to have a calibration factor.

If the crystal load caps were a bit larger, the clock would start out loosing time. This loss could be adjusted when the hour rolls over by setting the register TCNT2 to a nonzero calibration factor here:

Code: Select all | TOGGLE FULL SIZE
`  // an hour...  if (time_m >= 60) {    TCNT2 = cal_factor; //Add this to adjust rate    time_m = 0;    time_h++; `

This would cause the first second of each hour to be shorter by "cal_factor/256" of a second.

A menu to select cal_factor would be needed. One unit change in cal_factor would result in a rate change of about 0.1 second per day.
fat16lib

Posts: 593
Joined: Wed Dec 24, 2008 1:54 pm

Re: Ice Tube Clock loosing time

I've played with the crystal-caps on my clock a bit, and have gotten the loss from 4-sec/day to 2.5-sec/day, using 15pf caps (18pf dropped it to 3-sec/day). Because I like to tinker, and can't leave well enough alone, fat16lib's mention of a "calibration factor" sounds interesting to me.

Being new to AVR's and C (avr gcc), would the following be how one would try this (or maybe there is more to it than I think)?

1. Calculate the desired calibration factor e.g., (2.5-sec / 24) * 256 = 26.67

2. Declare the variable: float cal_factor = 26.67

3. Insert the above, and fat16lib's line into the code (then compile and download).

Also, maybe the precision of a decimal number is not needed (i.e., just getting the error under 1 sec would be nice), so maybe the calibration factor could just be an integer?
ki4mmm

Posts: 19
Joined: Sun Aug 16, 2009 7:05 am

Re: Ice Tube Clock loosing time

TCNT2 is uint8_t, an unsigned byte so use the closest integer.
fat16lib

Posts: 593
Joined: Wed Dec 24, 2008 1:54 pm

Re: Ice Tube Clock loosing time

TCNT2 is uint8_t, an unsigned byte so use the closest integer.

Thank you!
ki4mmm

Posts: 19
Joined: Sun Aug 16, 2009 7:05 am

Re: Ice Tube Clock loosing time

I've been wanting to play around with one of these:

http://search.digikey.com/scripts/DkSea ... 61-1014-ND

I read somewhere that somebody had some success connecting one to an arduino, so adding one to the Ice Tube clock kit shouldn't be impossible.
eil

Posts: 440
Joined: Sun Aug 31, 2008 11:09 pm