Re: A question regarding timing

From: Jim King (
Date: Wed Feb 14 2001 - 05:46:59 PST

  • Next message: Jeff Hunt: "ISS/Shuttle reboost"

    "Rush Austin" <> wrote:
    > > Does anyone know how to read the battery-powered clock directly?
    > >
    > Windows programmers have the Win32 Application Programming Interface (API)
    > at their disposal.  The Win32 API offers the following function:
    > Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As
    > which loads a SYSTEMTIME structure with the current system time; given in
    > UTC.  The SYSTEMTIME structure is defined as:
    > Private Type SYSTEMTIME
    >         wYear As Integer
    >         wMonth As Integer
    >         wDayOfWeek As Integer
    >         wDay As Integer
    >         wHour As Integer
    >         wMinute As Integer
    >         wSecond As Integer
    >         wMilliseconds As Integer
    > End Type
    > This function and structure can be called/referenced from Visual Basic, C,
    > C++, Access, FoxPro, etc...I cannot offer suggestions for other platforms.
    This returns the OS's time, not the battery-backed RTC's time.  To access
    the RTC's time you'd need to do low-level I/O (i.e. IN and OUT instructions
    in assembly, or inb() and outb() in C; I'm sure there's something equivalent
    in VB).  I tossed all my references to that sort of thing a few years ago
    and I can't recall the I/O port numbers off hand.
    I have an always-on Internet connection, so I use software that uses NTP or
    SNTP to communicate with a time server on the Internet.  The NTP daemon on
    Unix will constantly adjusts the OS's clock based on a drift rate it
    determines; in practice I've found that it will almost always keep the clock
    within a few tens of milliseconds of the time server.  The SNTP software
    that I use on Windows isn't as sophisticated - it only does step adjustments
    at the moment that it connects to the time server.  But unless the PC's
    clock has a horrendous drift rate (some of them do) having the software
    correct the time every half hour or hour usually results in step corrections
    of under 100 ms.  For really good time synchronization I have an inexpensive
    OEM GPS receiver that outputs a 1PPS signal synchronized to GPS time (as
    well as time and navigation info); feeding this into the Unix NTP software
    will result in synchronization to within 10 microseconds or so.  See for more info.
    Wristwatches:  My wife bought a handful of $10 Casio wristwatches at a
    discount store, set them all, put them on a shelf, and then let them run for
    a couple weeks.  Then she picked the one that had the least error, and
    returned all the others to the store.
    Unsubscribe from SeeSat-L by sending a message with 'unsubscribe'
    in the SUBJECT to

    This archive was generated by hypermail 2b29 : Wed Feb 14 2001 - 05:47:24 PST