[time-nuts] Using a UBlox NEO-6 GPS module for calibrating a PIC microprocessor based timer.

Chris Albertson albertson.chris at gmail.com
Sun Dec 1 11:56:41 EST 2013


It would be good if you could get a short description if your setup.
But the "normal" way to use the 1PPS signal is to measure a local
oscillator.  You would phase lock your 10MHz oscillator to the 1PPS
signal.  Measure the raising edge of the 10MHz signal and the raising
edge of the 1PPS and keep the time between those constant.   Then you
use the 10MHZ signal for timing.   The trick is to make adjustments to
the 10MHz VERY slowly.    Now what you've done is in effect averaged
many minutes of 1PPS pulses.  This is going to have to be done in
hardware.  (An XOR gate can work)

One other important thing.  If you are indoors the satellite signal
may be weak and sometimes blocks or fooled by multi path.  The 60nS
spec assumes you are outdoors with a clear view of the entires sky
from horizon to horizon with no reflective metal objects around.  Many
people place the Antenna on a mast on top of the building.    So, your
indoor setup may stop receiving satellites now and then.    Two things
you should do (1) detect this by reading the NMEA output.  It is just
plain ASCII text and don't use the PPS if the time is no good.  and
(2) let your local 10MHz oscillator "freewheel", stop adjusting it
when the PPS is not accurate.   Your PIC needs a serial port to read
this data.

If you were using the 1PPS for an interrupt, yes that will work but at
the few microseconds level.  Interrupts have latency as the processor
has first be in an interruptible state and then has to save internal
state.    Don't use interrupts the signal needs to latch a counter.
That is accurate to +/- one count.

A lot of people just buy a Thunderbolt GPS as they already have this
done the above and some more too.

But for your purposes I think all you need is the ability to calibrate
a local 10MHz oscillator "now and then".  Run the GPS system and
adjust the 10MHz crystal then if it is a GOOD double oven crystal
oscillator it should run well enough for days



On Sat, Nov 30, 2013 at 11:54 PM, Luke Mester <lmester60 at gmail.com> wrote:
> One of my hobbies is collecting and repairing mechanical clocks. I was
> looking at buying one of the specialized electronic timers used to measure
> the performance of mechanical clocks. I really couldn't justify the cost
> just for hobby use.
>
> Since I have electronics and programming skills I decided to build my own
> timer using a PIC chip. This became a much bigger project than I expected!
>
> I have my clock timer running and have most of the software features that I
> need working. I then realized that I need some way to calibrate it and
> verify it's accuracy.
>
> I didn't have any source of accurate time available.  After searching the
> internet and finding this mailing list I decided to try a GPS module. I
> bought a $20 module from DX.com. It has a built in antenna, voltage
> regulator, serial interface and most important, a 1 PPS output.The GPS is a
> UBlox NEO-6M. After reading the specs on this module I see that they claim
> a 99% accuracy of <60ns for the time pulse signal. What does this mean?
> What about the other 1%? How much variation can the time pulse have? If
> it's really 60ns it's much better than I need.
>
> I'm hoping that some of the time experts on this mailing list can give me
> some idea what to expect from this GPS module. Also, if there are any
> settings that I should change to get better timing performance. There are a
> huge number of settings available when I run it's configuration program. I
> have no idea what most of them do.
>
> I'm using one of the hardware timers on the PIC chip to measure the time
> interval. The PIC is running with a 100ns (10MHz) instruction cycle. The
> timer will provide 100ns resolution. I'm getting occasional variations of
> about a microsecond. Because I'm using interrupt driven code to capture the
> timer value there will be some unavoidable jitter in the timing. I was
> expecting about 4 or 5 cycles (400ns - 500ns) but I'm getting more than
> twice that. Is it safe to assume that these are due to problems in my
> hardware or software? Is this from variations in the GPS PPS output? Maybe
> I'm just not interpreting the data correctly.
>
> Below are links to some data plots:
>
> Four plots are shown. The first two are the Rate and Beat error that my
> timer reports while monitoring the GPS PPS signal. Rate is normally the
> average of two beats ( two time interval samples). If a clock is not in
> beat (the tick and tock take different amounts of time) the displayed rate
> would jump back and forth. Averaging two beats eliminates this jump. I have
> disabled this average in my code so that the rate is now showing each beat
> and not the average of two. I turned it off because I expect that this
> averaging could hide possible problems with my timer.  Beat error is the
> difference between the two beats. This shows the rate change for each pair
> of beats. This is needed so that you can get the clock pendulum or balance
> wheel adjusted properly.
>
> Raw Data <http://mesterhome.com/clock/data/RawData.png>
>
>
> Average Data <http://mesterhome.com/clock/data/AveData.png>
>
> Average data has been filtered with a 100 sample running average. The plot
> looks really good. The average is just hiding the instability.
>
>
> I also noticed variations that appeared to be due to temperature changes. I
> borrowed a temperature data logger from work and did some testing. The
> temperature and rate graphs track perfectly. I can see my furnace cycling
> and my programmable thermostat moving the temperature setting up and down!
> That got me interested in trying a TCXO instead of the standard crystal
> that I was using. A $3.00 TCXO from EBay made a huge difference! Both of
> these plots have the running average applied. You can't see the temperature
> changes with the raw data.
>
> Crystal <http://mesterhome.com/clock/data/RTvTP.png>
>
>
> TCXO <http://mesterhome.com/clock/data/RTvTPTC.png>
>
> In case anyone is interested, here is a link to a data file captured from
> the clock timer. It's in CSV format. The first column labeled "Rate" is the
> time for each beat of the clock. "Rate Avg" is a running average rate and
> "Beat E" the beat error.
>
> Data file <http://mesterhome.com/clock/data/tcxo.csv>
>
> Finally, I think I might be turning into a time nut! For the clocks that I
> work with this timer is already far better than I need. Millisecond
> accuracy Is good enough to test most mechanical clocks. Microsecond is
> great! I know that a microprocessor based timer is capable of better
> performance. I then had the problem of what I could use to measure the
> performance of my timer. I Needed a better clock than my timer. Now I'm
> wondering if this cheap Chinese GPS is good enough. I'm having fun tweaking
> the hardware and software to see just how good I can get it to perform!
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.



-- 

Chris Albertson
Redondo Beach, California


More information about the time-nuts mailing list