PDA

View Full Version : DT_Elapsed timer, how to compensate for inaccuracy over long periods ?



BrianS
- 25th April 2011, 15:50
Using Darrel Taylor's Elapsed_INT-18.bas and running it over a period of 62 hours and 33 minutes the timer appears to be running fast by Approximately 5 minutes.
Could it be my 20 mhz clock is off frequency causing this? If so what would be a good way to compensate for this? I need this to be somewhat more accurate then it is. Time from the timer was compared against MS Windows desktop clock. I would think it would be fairly accurate to compare against that.
Total windows time was 62 hours 33 minutes and timer was 63 hours and 38 minutes.

Thanks,
Bryan

Darrel Taylor
- 25th April 2011, 16:16
PC clocks are usually horrible time keepers.
I had the same problem a while back, thinking the PC would be accurate.

Syncronize the time on the PC with an NTP server before starting the test, and sync it again at the end of the test.
You'll be amazed how far off the PC's clock is.

Also, is your 20Mhz source a crystal, or a resonator?
Resonators are no good for time keeping.

I've tested the elapsed timer to hold within about 4 seconds a week. (with a good crystal)

BrianS
- 25th April 2011, 16:22
I'll try that. I don't have a manual way to sync the PC's clock to a time server as it is locked out and is updated by a local server. So, I don't know exactly when it's clock is updated to a time server. I try to find a better way to compare the time to.

Thanks,
Bryan

Charles Linquis
- 26th April 2011, 02:50
If you really want accurate timekeeping, you can set up an interrupt on zero-crossings of the AC power line.
Or - If you are brave, I can send you a portion of a program I wrote that contacts NTP time servers (requires a Lantronix XPort or similar) and PBPL.
Or - if you are outdoors, you can get time from a GPS module.

BrianS
- 27th April 2011, 15:31
If you really want accurate timekeeping, you can set up an interrupt on zero-crossings of the AC power line.
Or - If you are brave, I can send you a portion of a program I wrote that contacts NTP time servers (requires a Lantronix XPort or similar) and PBPL.
Or - if you are outdoors, you can get time from a GPS module.

Thanks,
Turns out it was the PC clock was updated by the time server during the period I was monitoring the timer. Found that the timer code/circuit keeps very accurate time for my needs.

Bryan