[time-nuts] First success with very simple, very low cost GPSDO, under $8

Chris Albertson albertson.chris at gmail.com
Wed Apr 9 13:37:46 EDT 2014


On Tue, Apr 8, 2014 at 10:44 PM, Mark Sims <holrum at hotmail.com> wrote:

> I'm not sure how the Arduino environment handles interrupts,  but in C you
> need to declare any variables altered by an interrupt as "volatile" so that
> the compiler optimization routines know not to assume they contain known
> values.
> Also any code that accesses them needs to do so with interrupts turned
> off...  otherwise you can wind up with corrupted values.   Imagine that the
> mainline code is accessing a multi-byte variable.  The code accesses the
> lower byte,  in comes an interrupt that changes the variable (new low and
> high bytes,  then the interrupt routine returns to the mainline code),  and
> then the mainline code proceeds to access the (now changed) high byte of
> the variable...  the resulting value is a mishmash of the old and new
> values.
>

You are 100% correct.   You can read in the code I posted that all
variables used in the interrupt handler are declared "volatile"  The
Arduino programming environment uses the GCC C++ compiler

But I think you over looked one point that makes this project easier:  We
KNOW 100% for certain that the interrupts happen only once per second.  So
the foreground code knows for certain it has exclusive access to shared
variables for a given period of time.  There is zero chance of a problem in
the next .999 seconds after an interrupt.

I tested this for 30+ hours and no problem was detected.  But yes. iff a
second PPS happens just a millisecond  later you have a potential problem
but then t=you also have a broken GPS receiver and the GPSDO would not work
no matte what you did.

The test I ran sent the OCXO signal to both an HP counter and the Arduino.
 My spot checking over a 24 hour run showed the two agree.  (I added code
to display the count to an LCD screen that was physically close to the
counter and just looked by eye to see that were the same, The last digitals
(0.1Hz) differs by one as I would expect.)

Then as maybe you read in my next post the OCXO failed. The arduino
measured "0 Hz" and quickly moved the DAC output to full 5 volts trying to
pull the frequency back up to 10MHz from 0.

My next test will be to feed a 10MHZ and PPS signals into the Arduino from
a Thunderbolt.  The TB signal is near perfect and I will look at the
"noise" reported by the Arduino.   Something to try while I unsolder the
can.

-- 

Chris Albertson
Redondo Beach, California


More information about the time-nuts mailing list