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

Luke Mester lmester60 at gmail.com
Fri Dec 6 19:53:31 UTC 2013


I want to thank everyone for the info! I'm still reading and trying to
learn from it. I think I have another hobby starting.


Monitoring the GPS performance looked like a good start. I have the serial
port connected to a PC and have been monitoring it with the U-Center
software available on the U-Blox site. So far, the minimum number of
connected satellites is 5 and the maximum is 12. I also see a maximum
position error of about 50 meters. Is this good enough or do I need a
better signal? I don't have the receiver located in a very good spot. My
workshop is in the basement. I have it next to a basement window. I have a
view of less than half of the sky. I did check the configuration of the 1
PPS output. It's set to only output pulses when the data is valid. After
monitoring it for a couple of days the 1 PPS signal has not dropped out.


Also, I should say that I'm not planning on having my PIC timer permanently
connected to a GPS. I just want to use it for testing and an occasional
calibration check.


Quartz55,

Yes, you can use a PC with a sound card. There's even a program called
"Windows timing machine" available that does this.  I've tested it and had
poor results. One computer worked better than the other. Neither worked
very well. I think it's probably dependent on the quality of the sound
card. I also wanted the convenience of a small portable timer instead of a
PC.


Tom Van Baak,

I've looked at Brian Mumford's Microset timer. I think it's the best one
available. If I hadn't decided to make my own I'd have bought his. I really
don't need all of the features of his timer.  It just came down to the fact
that my spare time to write code is free and PIC chips only cost about a
buck :-)


I'm using a PIC 18F13K22. My code is in assembly language. The external
clock is 10MHz. Internally it's running at 40MHz using the 4x PLL. The PIC
18 takes four clock cycles to execute one instruction cycle. The hardware
timers advance at the instruction cycle rate, Fosc/4. I chose 10MHz to try
to make the math a little easier. So far I'm only using fixed point math.
I'm trying to avoid using any floating point. Floating point in assembler
would quickly turn a fun project into a nightmare.

 I think that the PIC 18 interrupt latency is 3 instruction cycles. I'll
have to double check the PIC 18 data sheet and verify this. There will also
be some more latency because I have two interrupts occurring
asynchronously. When the pic input pin is triggered an interrupt is
generated. This interrupt routine captures the current value of a free
running timer. Unfortunately, the pic only has 16 bit timers. I needed 32
bits. Because of this, I generate another interrupt whenever the timer
overflows. I use this to manually increment another 16 bits. If an input
pin interrupt occurs during a timer rollover there will be a little more
delay while the timer rollover is handled. I'm sure there are better ways
to code this.

Also, internally I think I'm doing something similar what your picpet does.
My timer displays the clock rate and other info. Internally I'm just taking
a snapshot of a free running timer. I then subtract the last two samples to
get the beat time. I do an average of two beats to get the clock rate and
finally the difference between two beats to show the beat error. From what
you're saying there's an advantage to output the raw timer values. I'd then
see a series of steadily increasing values until the timer rolled over. A
plot would look like a sawtooth waveform. I'll add another log option to
output the raw timer value.

 I'd definitely be interested in talking more about your picpet and it's
isochronous coding. I think this may be getting off-topic for this list. It
looks like this list is more about the hardware used for precision time
measurement than the software. We could continue this topic off list if you
think other members won't be interested.


Finally, Here are some pictures of the timer.

Back <http://mesterhome.com/clock/clock%20timer/Clock%20Timer%20009.JPG>

Front <http://mesterhome.com/clock/clock%20timer/Clock%20Timer%20012.JPG>



More information about the Time-nuts_lists.febo.com mailing list