CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Clock gains 1 second per hour

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
yamazaki



Joined: 24 Nov 2012
Posts: 3

View user's profile Send private message

Clock gains 1 second per hour
PostPosted: Sat Nov 24, 2012 4:52 pm     Reply with quote

Re RTC routine by ckielstra in Code Library:
http://www.ccsinfo.com/forum/viewtopic.php?t=26177
I'm sorry for ressurecting this topic, but there's a question made some posts earlier that wasn't fully answered.

I've implemented this RTC routine too, but my clock gains 1s every hour, compared to my computer.

Is this acceptable? Or is there a problem with my oscillator circuit? I'm using a 20.000 (20MHz) cristal with 15pF capacitors (I'm not sure about their accuracy though). How can I improve the precision? Also, I'm running it on a protoboard, does it changes something?

I've changed the cristals and the capacitors, without success (sometimes it gets even worse).

Thanks.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Nov 24, 2012 5:12 pm     Reply with quote

Quote:

1s every hour, compared to my computer.


surely you jest !!!

since when did a random PC clock become the "time god " ???

how does your time compare to a TIME STANDARD ???

that is a question we can bite into.

how do you know that your PC is not OFF by a second per hour?

in fact how do you know anything for sure ??

LOL
Very Happy Very Happy Very Happy Very Happy Very Happy
yamazaki



Joined: 24 Nov 2012
Posts: 3

View user's profile Send private message

PostPosted: Sat Nov 24, 2012 5:19 pm     Reply with quote

That's a good point. But, even so, we assume (at least I do) the computer's clock is a good reference. And gaining 1s every hour is pretty imprecise for me. It's 12 minutes per month, and 2 hours per year. That's a lot of time.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Nov 24, 2012 5:35 pm     Reply with quote

I'd expect better than 100 parts per million from almost any quartz crystal.

Could be a layout issue, if you've got large loop areas.

However, you do need to establish a good reference frequency first.

Mike
yamazaki



Joined: 24 Nov 2012
Posts: 3

View user's profile Send private message

PostPosted: Sat Nov 24, 2012 5:42 pm     Reply with quote

Isn't the computer a good one? If not, which one?
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Nov 25, 2012 8:56 am     Reply with quote

Quote:

a good one?


A good one is one that is traceable to NIST or some other recognized standard.

A quality frequency counter comes to mind as a useful reference in my case.

In developing research instruments, i have seen numerous instances of PC's with pretty good battery RTC timing but modestly POOR short interval operating time keeping in the range of hours while booted.

Most PCs do NOT use the RTC source during operation, referring to it at the OS level when booted only. hence long term and short term accuracy may diverge significantly.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 25, 2012 9:16 am     Reply with quote

yamazaki,
Your question is not directly related to the software routine as posted here. Please ask your question in the other General forum.


+++++++++++++++++++
Topic moved to main forum per request.

- Forum Moderator
+++++++++++++++++++
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Nov 25, 2012 5:32 pm     Reply with quote

Quote:
Isn't the computer a good one? If not, which one?

Using a PC will take ages.

Try one of the broadcast standards for your part of the world.

A Google search yields several suggestions.

Or borrow/cadge a good commercial frequency meter/generator.

Mike
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Nov 25, 2012 8:12 pm     Reply with quote

Just for that reason I sync my PC clock to the NIST once a day, because it can be so imprecise....
_________________
Google and Forum Search are some of your best tools!!!!
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Nov 25, 2012 10:12 pm     Reply with quote

Very strange one last night - my W7 pc normally syncs to the time servers. Last night it was suddenly off an hour .. exactly - said it was 10:30PM instead of 11:30 (it had been fine earlier in the day). When I tried to sync it manually, the first three sites listed on the sync list "timed out" - tried one farther down the list and it sync'd correctly and all was well. Have not seen it before (or since). Anybody else see anything like that yesterday ?

As for the RTC that is drifting, one option would be to add a calibration routine that stores a correction factor in EEPROM that gets added or subtracted to keep more accurate time (this assumes your crystal etc. are fairly stable - if temps are wandering around and the crystal changes with temp very much, that would not work).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Nov 26, 2012 12:11 am     Reply with quote

You can use a PC provided you are running an active NTP daemon that is phase locking its clock onto other servers.

That's the point of NTP.

Just "grabbing the time" at startup is not good enough. I've seen my Workstation PC's clock slide significant amounts over the course of one day too. (several seconds)...

However, my linux server running NTP and referencing several hosts... no fears. (one of these days, I'll get the GPS hooked up and use that... but until then..)

Anyway -- make NTP your friend. (and not in "get the time every X seconds".

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Mon Nov 26, 2012 8:29 am     Reply with quote

Remember that its easy for firmware/software to lose time. Its much harder for it to cause a clock to run fast. So gaining time points to hardware most likely. So the PIC is fast relative to the PC, but maybe both are actually running slow... or fast, or... well, almost anything is possible. Also is it really 1s every hour, or are there hours when no time is lost, then two seconds, then one, and so on. Is the loss or gain regular or does it happen "every now and then"?

My experience of PC OS clocks is that, like all software based clocks, they run slow, generally as interrupts are missed due to high processor load. Way back in the 400MHz days I rebuilt a speciallised radar system, making it PC based (Windows 95 no less :-). I had to give the two remote radars GPS clocks and run a utility called Tardis to regularly, every hour if I remember right, time sync the PC clock. Otherwise they'd loose more than a minute overnight, which wasn't good for the radar data as one of the pair, twenty or more miles away could interfere with the other.

You are using a 20MHz crystal and with good design, including PCB layout with guard ring etc you'd get the 100ppm or better folk are talking about. The alternative is a 32768KHz watch crystal, but these are not great compared to other, higher frequency crystals. They have a narrow stablish temperature range, which is fine when they are on your wrist, which is a fairly temperature stable environment generally, but they are not so good in equipment that gets hotter and colder than you do.

To be honest, one second an hour without trimming (and watches are usually trimmed to give good timekeeping) sounds about all I'd expect from a watch crystal "out of the box", and with a 20MHz crystal you're probably not going to get any better in the medium to long term on a prototype board with all its stray capacitance and connecting lead inductance. To get the expected performance you really need a well-designed PCB and probably a half-decent case to give at least some degree of temperature stability.

RF Developer
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Nov 26, 2012 11:07 am     Reply with quote

RF_Developer wrote:

To be honest, one second an hour without trimming (and watches are usually trimmed to give good timekeeping) sounds about all I'd expect from a watch crystal "out of the box", and with a 20MHz crystal you're probably not going to get any better in the medium to long term on a prototype board with all its stray capacitance and connecting lead inductance. To get the expected performance you really need a well-designed PCB and probably a half-decent case to give at least some degree of temperature stability.

RF Developer


He could always use a TCXO... that would definitely help.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group