Something I did in a recent project where I did the RTC function in the PIC based on the timer1 oscillator with a 32kHz crystal is to have a signed long variable that is the number of seconds until I add (if the variable is positive) or subtract (if the variable is negative) one second to the time. This is just decremented or incremented (as appropriate for its sign) each second along with the rest of the RTC. When it hits zero, I add or subtract a second, then reload the counter. Harold > Hi, > > I am working with a RTC from Philips (PCF8593) but did work in the past > with > Maxim ones, and they always face you with the accuracy problem, and how to > finetune the setup to get the max accuracy. > > Given the basic accuracy of the device is directly related to the crystal > accuracy, having 20-50ppm typically is more than 5 minutes / year, but > that > is what you can get. > > Datasheet suggest to use a variable cap to finetune frequency to get > better > accuracy, but I do not really understand the added value of that when > comparing with digital compensation from the PIC. I mean, I plan to have > it > running for some time, then assuming temperature being almost constant > (+-6=BA > C) the difference I would get with an accurate cronometer, could be let's > say RTC goes fast by 1 min, 27 sec in a month for instance, that number > can > be written on EEPROM and then used by the PIC to reprogram the RTC > regularly, say once a week, to automatically compensate. I guess this is > much better than playing with variable caps that are so sensible than even > touching them will change the oscillator frequency. Or I am missing > something? This is not even suggested in the datasheet, and I wonder why. > > -- > Ariel Rocholl > Madrid, Spain > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist