gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] [PATCH 1/1] Initial draft; how to estimate time1 offset


From: Andy Walls
Subject: Re: [gpsd-dev] [PATCH 1/1] Initial draft; how to estimate time1 offset
Date: Thu, 07 Nov 2013 08:44:04 -0500


On Thu, 2013-11-07 at 10:04 +0800, Sanjeev Gupta wrote:
> 
> On Wed, Nov 6, 2013 at 8:20 PM, Greg Troxel <address@hidden> wrote:
>         My impression is that fudge1 is added to the offset, and that
>         for
>         typical timecodes (e.g. ublox binary), a fudge of around
>         0.110s is
>         normal, indicating that the timecode arrives 110 ms late,
>         which would
>         produce an offset of -0.110s.
>         
>         It would be nice to go through this carefully with the signs,
>         and to
>         usea value that appears in practice.
>         
>         It would also be nice to collect typical values.
> 
> 
> Greg, Andy,
> 
> Please see the enclosed image.  The righthand side is before midnight,
> the left is today (I merged the peerstats).
> 
> 
> Assuming I have decided that the value is -0.47 , what will be my
> time1 value?  -0.47 or +0.47 ?


+0.47.

IIRC, ntpd references everything to the system clock.  So here is the
relationship

        offset_clockN = time_clockN + fudge_time1_clockN - time_system_clock


For now assume the time_system_clock is "truth".

The objective is to have the average offset_clock0 == 0, so we take the
observed average offset from the peerstats for clock0 and combine it
with the fudge_time1_clock0.

        0 = time_clock0 + (fudge_time1_clock0 - offset_clock0) - 
time_system_clock
        0 = time_clock0 + fudge_time1_clock0' - time_system_clock

The new

        fudge_time1_clock0' = fudge_time1_clock0 - offset_clock0

If you started your calibration test with

        fudge_time1_clock0 == 0

then the new

        fudge_time1_clock0' = -offset_clock0


------

But we know that the system_clock really isn't truth, because we know
the PPS is probably better.  For a better fudge_time1_clock0, we want to
reference to the PPS (clock1) and not the system_clock: 

        offset_clock0 = time_clock0 + fudge_time1_clock0 - time_system_clock
        offset_clock1 = time_clock1 + fudge_time1_clock1 - time_system_clock

Subtracting those two yields:

        offset_clock0 - offset_clock1 = 
                        time_clock0 + fudge_time1_clock0 - (time_clock1 + 
fudge_time1_clock1)

We will assume that fudge_time1_clock1 (for the PPS) is a constant that
is correct.

We have an objective to make the average offset of clock0 relative to
clock1 == 0, so

        0 = time_clock0 + (fudge_time1_clock0 - offset_clock0 + offset_clock1)
                                - (time_clock1 + fudge_time1_clock1)

        0 = time_clock0 + fudge_time1_clock0' - (time_clock1 + 
fudge_time1_clock1)

The new

        fudge_time1_clock0' = fudge_time1_clock0 - offset_clock0 + offset_clock1

If you started the calibration with 

        fudge_time1_clock0 = 0

then the new

        fudge_time1_clock0' = -offset_clock0 + offset_clock1


Again, the offset_clockN numbers are stable averages you extract from
the peerstats file for clock0 and clock1 respectively, and that clock1
is the PPS which we trust as truth.

        
Regards,
Andy





reply via email to

[Prev in Thread] Current Thread [Next in Thread]