Page 1 of 1

Clock Project and time drift problem

Posted: Mon Mar 26, 2012 8:21 am
by panpanta
Hi to all

My name is Panayotis, i am building a clock using Hp-488 board.

I am using 32.768 crystal and print time every second on the boards lcd screen.

I used Medelec (Thanks for the great XL file) int time calculator as a guide to produce the one second measurement.

When i test the project running on the board i noticed drift (goes forward 3 seconds in comparison to my watch in about 2 days.)

You can view the settings and interrupt macro i am using at the attached pictures


Any suggestions will be very helpful.

Thanks in advance

Re: Clock Project and time drift problem

Posted: Mon Mar 26, 2012 10:32 am
by Benj
Hello,

What specification is your crystal? This is normally measured in parts per million, could it be that you are using a fairly inaccurate crystal?

Here are the calculations for a 10 parts per million crystal.

(3276800 /1000000) * 10PPM = +/- 32.76 counts per second.

After two days of this error.

60 x 60 x 24 x 2 x 32.76 = 5660928 - which is equal to about 2 seconds worth of clock pulses.

Re: Clock Project and time drift problem

Posted: Mon Mar 26, 2012 12:21 pm
by panpanta
Hello Benj
Thank you for your quick reply

My Quartz is Raltron 3.2768Mhz
I believe it is OK...

If you are sure it is the quartz i will replace it.
I need to know if i am doing something wrong with flowcode or it is the quartz the problem
I forgot to mention that i use Flowcode V5 Professional and i choose XT at configure chip -> oscillator option because it is bellow 4MHz

You can see it bellow.

Re: Clock Project and time drift problem

Posted: Mon Mar 26, 2012 3:07 pm
by Benj
Hello,

Sounds like its related to the crystal and not your program or the timing would be further out. XT setting is correct for xtal under 4MHz.

Looks like the crystal your using has a 20PPM tolerance which would explain the 3-4 seconds discrepancy after 2 days.

One option would be to replace the crystal.

You could try to find a higher tolerance / lower PPM crystal or if your application is not doing much other then monitoring the time then you could maybe use a 32.768KHz watch crystal as these are used for watches and therefore can be found with very high tolerances / low PPM counts.

Another option would be to stick with the crystal your using now and get the program to manually drop or gain a second or two after every day has passed to try and keep the clock in line with actual timing. The PPM error is constant on a specific crystal so you would have to tune your application to the crystal. Therefore for a one off this is ok but for a production run not very cool. Saying this batches of crystals will normally share a very similar tolerance so if you get a batch and tune your application to the batch then a production run should be ok.

As a note this batch technique is often used when creating high fidelity R/2R DACs as the almost identical batch tolerance reduces the amount of error in the potential divider circuits.

Re: Clock Project and time drift problem

Posted: Mon Mar 26, 2012 3:14 pm
by panpanta
Thank you very much Bemj.

I will try other quartz to see the resault.

Re: Clock Project and time drift problem

Posted: Mon Mar 26, 2012 6:09 pm
by panpanta
Hello Benj

I am seeking for the new quartz but all i can see at Digikey have
tolerance starting from +/- 30ppm to =/- 50ppm and need capacitors
17-18pF

Do you suggest anyone of them (see the Attached picture please)?

I noticed that my Hp448 board has 10pF capacitors... may this be the reason i have time drift
with the quartz i have now or not ?

Thanks once again.

Re: Clock Project and time drift problem

Posted: Tue Mar 27, 2012 9:31 am
by Benj
Hello,

I normally use 22pF caps with my crystals but I can't see 10pF causing any real issues.

Here is a list of Farnell crystals with +/- 10 or 15PPM.

http://uk.farnell.com/jsp/search/browse ... s%3D203436

What about my suggestion of dropping a second or two every time the hour variable rolls over from 23 to 0.

Or what about using a 32KHz watch crystal? What else is your program doing?

Re: Clock Project and time drift problem

Posted: Tue Mar 27, 2012 11:30 am
by panpanta
Hi Benj

The project is a 24h clock.
It has the option to set start time and stop time.
The user will set the desirable amount of time and the clock
will enable a relay contact during this set period of time.
It has to be very accurate because if the user need the same time control
every day the time drift will be a problem after several months or a year.

I was thinking about the solution of dropping one or two seconds every 24 hours
but i like to build an accurate clock.

For now i am looking for a watch 32.768KHz crystal, I don't know if farnell can ship to Greece.
Other similar 32768 crystals i saw has exact the same characteristics but frequency tolerance 20ppm.
Based on your experience 20ppm will give me the result i want or not?
And last what is the best capacitors value for crystal load capacitance 12.5pF?

Thanks in advance

Re: Clock Project and time drift problem

Posted: Tue Mar 27, 2012 12:27 pm
by Benj