RTC Calibration #893
-
I've designed a watch using the ATTINY1616 which so far is working quite well. It is using the TIME library to keep time and RTC as the clock source, goes to sleep (at 1.3uA - unbelievable!) and only wakes up when a button is pushed, shows the time, and returns to STANDBY. The issue: while the watch keeps time for a day or so, it eventually drifts and needs to be re-set. I've built several of them and the drift is always different - is there a method I can use to calibrate the RTC in my setup function and apply a linear offset to make timekeeping more accurate? Do I need to use a watch crystal to keep accurate time over the long term? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
If you are not using a watch crystal then I think I most of your time drift would go away if you did. Having said that, I've done some work with the 32kHz crystal calibration register and with that you can get things to 20 ppm if your crystal loading is correct (crystal load is 1/2 of the cap value used, since it's effectively two in series, plus stray - I use 12 pf loading caps on each xtal leg, so the total loading is then 6 pF from caps which is then in parallel with 6 pF from stray capacitance). To determine the adjustment register value I see how many seconds the clock is off after running 8 hours (for time reference I use time.gov or WWV sound track on 303-499-7111), determine the PPM correction needed and then hard code that into the adjustment register. Also be aware that the adjustment registers is not looking for a 2s compliment value. Instead, the register expects data in the form of sign (high bit) and magnitude value (7 low bits). |
Beta Was this translation helpful? Give feedback.
-
I was calibrating the clock (1.5PPM reference), but found the clock drifts drastically with temperature. The chip has an internal temperature sensing, and is constantly adjusting the oscillator based on that. When I started to adjust for temperature, it worked better, but the calibration was specific to the device. Meaning, I couldn't apply it to other devices reliably. If you are wearing the watch 24/7, your body temp will keep it from drifting wildly. From what I understand, that's the way most watches work unless they have a radio. I think using a watch crystal would be your best option. |
Beta Was this translation helpful? Give feedback.
-
Yeah, if you want even passable levels of accuracy, you gotta use a crystal. I'm, going to launch the ulramini line wherein you can omit pin header on the crystal, pims, solder a crystal and loading caps onto the board, and then if you chose componjent values right, get the crysdtal to work. It is VERY fiddly and VERY frustrating to work with. . Note that ANY system like this MUST have a way of getting periodically getting it's time updated unless you happen to have an atomic clock in the basement (and it would still need a means of getting that updated. My plan for my room is to have a raspi sting there which auto syncs time, and then have it command a (via http) an ESP-8266 + tiny1626, the esp8266 would get the request, and then say "Hey, reset your clocks everyone, iot's curently midnight" via 433 MHZ ook RF, which is what I uise to talk to less powerful AVRs that don't have an ESP tagging along. Would likely give it am appopriiate DNS names.... Big Ben? Too popular. But Narbondel (the infrared clock uised by cave dwelling evil things a series of novel) might be too obscure.... AnArrow ("time flies like an arrow fruit flies like a bananna") might be good |
Beta Was this translation helpful? Give feedback.
If you are not using a watch crystal then I think I most of your time drift would go away if you did. Having said that, I've done some work with the 32kHz crystal calibration register and with that you can get things to 20 ppm if your crystal loading is correct (crystal load is 1/2 of the cap value used, since it's effectively two in series, plus stray - I use 12 pf loading caps on each xtal leg, so the total loading is then 6 pF from caps which is then in parallel with 6 pF from stray capacitance). To determine the adjustment register value I see how many seconds the clock is off after running 8 hours (for time reference I use time.gov or WWV sound track on 303-499-7111), determine the P…