Keeping Time on the PC

How many of those 500+s fast/slow connections in the first graph are from machines with clocks deliberately set incorrectly? At that same website there’s a graph that goes out to +/- 2000s - there are practically no machines in the 500s-2000s range - they’re all greater than 2000s clock “skew”. I suspect nearly all of these machines are deliberately set wrong.

How do you explain … why, when we removed one of the UPSes from the chain, the clock skew cleared up?

Well, let’s start with how the PSU and the RTC ‘communicate’. There’s really only one connector: http://www.playtool.com/pages/psuconnectors/connectors.html#atxmain24
and it provides only DC power to the mobo. No frequency component at all, apart from a little bit of ripple http://en.wikipedia.org/wiki/Ripple_%28physics%29 - that PSU designers do their damnedest to remove.
The only other signal to the mobo is a PWR_OK line which is just an “I’m OK” signal to the CPU.

So, the RTC can not be ‘designed’ to take any timing information from the AC supply.

I suppose it’s remotely possible that two UPSes in series could degrade the AC supply somewhat, and thus make the PSU fail to deliver stable DC to the mobo, but if this was happening I’d expect SERIOUS grief - not just a clock ‘speedup’. DC levels would be borderline or have spikes and/or dropouts in them. If this was the case, I’d be amazed that the system ran at all.

While I don’t dispute what you observed, I can’t see any rational explanation for it, and so don’t agree that “the first thing to check is your source of AC power”.

  • Roddy

Woah, those clocks are not cheap.

I’ve been thinking in passing of getting one for a few years, but not at those prices.

Here’s a good article on the history of timekeeping from the perspective of navigation. It’s wonderfully written and I’d recommend it to anyone curious about modern timekeeping.

http://www.allanstime.com/Publications/DWA/Science_Timekeeping/

Today most people take for granted that we can determine our exact location on Earth to within a few feet, but this wasn’t possible until recent decades because we didn’t have clocks that were accurate enough to do the job. Not only are computers giant clocks, but so are GPS satellites, and if you’ve got a boner for organizing your life around UTC time within a millisecond, a nice GPS receiver can get you near-atomic-clock accuracy.

Also, no hardware uses AC power to keep time. In the US, the power company guarantees that your wall power will have a frequency of 60 Hz as a daily average, and that only applies to the power delivered to the building. If you’ve got a bunch of PCs running in your room, the quality of the sine wave coming out of the wall is probably pretty miserable.

I’m also not a hardware design expert, but I believe UPS act as a low-pass filter for the incoming power signal and any data at 60 Hz should get through untouched. What you observed was likely caused by something much, much more elaborate and had something to do with the interactions of the PC power supply with the UPS system.

For the EE nerds out there here is a detailed explanation of the time accuracy from manufacturer of the chip many (most?) computers use for their RTC: http://www.maxim-ic.com/appnotes.cfm/appnote_number/58

A quick summary is that the accuracy is dependent on the tolerances of the crystal and a joined capacitor. Once installed the crystal is sensitive to temperature extremes and electronic noise. I expect Jeff’s two UPSs were causing the AC to be very noisy at a high frequency and interfering with the RTC chip.

The funny thing is everyone is posting how bad it would be to use the 60Hz AC frequency to tell time, but it’s been used for years in electric clocks. In fact, Jeff’s new nixie clock uses the AC signal as it’s time signal. From the manual for the kit version (looks like fun): “The power line provides a very reliable clock source, courtesy of the power company”.

How accurate is your Nixie clock Jeff?

The time may drift slightly on a PC, but we are talking a few seconds a year and in a constant direction–it would NEVER jump around like that web site seems to make us think it does. That is all variations in networking.

I’m not saying PC clocks are perfectly accurate, just that the drift isn’t something you can measure at a web site–you’d have to test two times that were weeks or months apart to get even a second worth of drift.

why is it that everything you do almost inevitably is on Windoze?
only sometimes do the comments touch on alternative operating systems

Just wanted to add something that I don’t think anyone else has covered here; the Time subsystem in Windows XP is separate from the RTC chip - It’s appears to me that it may well be a Kernel Level 0 driver (i.e. software) that runs on a PID algorithm, using the time from the NTP servers as a set point, and then using PID controls (often found in manufacturing to ensure accurate analogue positioning of pistons, for example) to resync the clock in a predictable manner;

e.g. If your clock is running behind, Windows will interpret each second as perhaps 900ms so that more “seconds” will pass per real-time seconds to get caught up. Similarly, if your clock is too fast, Windows will perhaps make each “second” count as 1.1s, thus slowing your clock down.

Because of this algorithm, it can actually take several minutes to re-sync a clock in Windows XP; and because of the limitations of PID control, it would wreak havoc on timings if your clock is too far away. (Because the proportional control in the PID algorithm becomes too large and too innacurate - Having a kernel clock, like you mentioned, of 3:1 (3 “seconds” to one real second) would no doubt mess up anything which requires proper timing; especially games.

Windows appears to sync it’s own Time subsystem to the RTC chip every so often to ensure no data loss on reboots; the RTC chip runs the clock (as you say, pretty inaccurately) until Windows boots and then the time subsystem takes over from the RTC.

The algorithm, although complex, is far better than most OSes, probably because to ensure security on domain logins, Microsoft require an accurate clock.

Wikipedia has an excellent article on PID algorithms if you wish to research this more. :slight_smile:

What you observed was likely caused by something much, much more elaborate and had something to do with the interactions of the PC power supply with the UPS system.

Fair enough; as I said, I’m no hardware engineer, but I definitely observed the power input messing up the internal PC clock. The drift was severe, too, on the order of 5-10 minutes a day.

the Time subsystem in Windows XP is separate from the RTC chip

There’s a good description of how Windows manages time here… I assume it’s the same as most other operating systems:

http://www.greyware.com/software/domaintime/technical/accuracy/pcclocks.asp

So buy three watches, and ...

… get picked up on suspicion of selling stolen goods.

You learn something new from this blog everyday. Though I dont trust that windows time thingy. I ussually switch that off. I just manually change the time every so often. There’s so many dumb automated features intergrated into windows that I expect them to cause problems so I disable them all.

There’s an interesting website at http://www.ijs.si/time/temp-compensation/ about the effects of temperature on computer time accuracy and using temperature compensation

Another experiment demonstrated that clock skew could be used to determine temperature and then went on to show that the skew could be a security threat against anonymous networks.
http://events.ccc.de/congress/2006/Fahrplan/attachments/1211-23c3hotornotpres.pdf

I’ve had a time fetish for years too. Thanks for the clock links all, I’ve ordered one. For those who share the interest in time, here are two books that I recommend:

_Splitting_the_Second:A_Story_of_Atomic_Time by Tony Jones
Time’s_Pendulum by Jo Ellen Barnett

Stu

For a media centre PC, I’ve found the best source of time sync to be the time signal from a DVB tuner. You don’t need an NTP server or even a network connection (you can get your schedule data from the DVB stream as well.) And of course, it’s the perfect benchmark of time for a system which has it’s entire world centred on TV. My HTPC exclusively uses the dvbdate utility (don’t know if there is an equivalent for Windows MCE, I’m on Linux/MythTV).

Good article on the NIST’s hyper-accurate cesium clocks:

http://www.wired.com/science/discoveries/news/2007/12/time_nist

This is also a problem if you’re using WS-Security extensions, as messages will be rejected if there’s too much of a clock difference between client and service. You can set the time tolerance, but only if you control both machines…

I don’t see how AC frequency could affect a PC’s clock, since the power is regulated to DC long before it hits any internal component (and the CMOS battery is a different circuit anyway). The reason you’re not supposed to daisy chain a UPS is that most UPSes use a step-approximated sine wave when operating from battery, so the batteries on both of them will discharge at the same time and you’ll be no better off than having just one UPS. Or worse, if you have two different kinds of UPS (i.e. one inline, one standby), one might interpret the stepwave as an overload condition and start discharging its battery immediately. I believe that could damage the equipment under some circumstances.

Either way, it’s unrelated to the frequency. Probably the reason for the added clock skew is that since the UPS has to regulate the AC power, you end up with a slightly lowered voltage at the output, and daisy-chaining enough standby models could create a noticeable sag by the time it gets to the PC. At least, that’s my untested cocktail-napkin theory. It sounds more plausible than frequency dependency!