Clock Project and time drift problem

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
panpanta
Posts: 7
Joined: Tue Jul 25, 2006 11:27 am
Location: Athens Greece
Contact:

Clock Project and time drift problem

Post 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
Attachments
24h_Timer.JPG
(68.54 KiB) Downloaded 1043 times
interrupt flowcode settings
interrupt flowcode settings
Int.jpg (40.76 KiB) Viewed 4755 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Clock Project and time drift problem

Post 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.

panpanta
Posts: 7
Joined: Tue Jul 25, 2006 11:27 am
Location: Athens Greece
Contact:

Re: Clock Project and time drift problem

Post 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.
Attachments
Quartz 32,768KHz.jpg
Quartz 32,768KHz.jpg (74.66 KiB) Viewed 4741 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Clock Project and time drift problem

Post 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.
Last edited by Benj on Mon Mar 26, 2012 5:10 pm, edited 5 times in total.

panpanta
Posts: 7
Joined: Tue Jul 25, 2006 11:27 am
Location: Athens Greece
Contact:

Re: Clock Project and time drift problem

Post by panpanta »

Thank you very much Bemj.

I will try other quartz to see the resault.

panpanta
Posts: 7
Joined: Tue Jul 25, 2006 11:27 am
Location: Athens Greece
Contact:

Re: Clock Project and time drift problem

Post 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.
Attachments
NewQ.jpg
NewQ.jpg (59.03 KiB) Viewed 4731 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Clock Project and time drift problem

Post 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?

panpanta
Posts: 7
Joined: Tue Jul 25, 2006 11:27 am
Location: Athens Greece
Contact:

Re: Clock Project and time drift problem

Post 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
Attachments
32k20ppm.jpg
32k20ppm.jpg (64 KiB) Viewed 4719 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Clock Project and time drift problem

Post by Benj »


Post Reply