[time-nuts] First success with very simple, very low cost GPSDO, under $8
albertson.chris at gmail.com
Thu Apr 10 06:35:50 UTC 2014
To many "ifs" and "you could...". The Arduino is what it is. There
is no capture register, no interrupt priorities and the counter is
16-bits and the overflow actually takes one cycle. The code is
posted. You can read it. Every second it does what is suggested and
computers the difference in cycles from 5000000. Mostly it gets zero.
It ran for close to 100,000 continuous seconds without a glitch and
then the OCXO failed.
There is really no problem that requires a "fix". (other than an
ovenized crystal that only works well when it's cold) The goal was
to have minimally complex design to use as a baseline.
The real experiment begins AFTER this. That is to add one
"improvement" at a time and see what is gained in performance.
So I think I have every flavor of sophistication backed out. I am
only counting cycles and the PI contents are only roughly tuned. I'm
at the point where if one more thing is removed it stops working.
That is the baseline.
One thing I added was the "I" term. I had just a "P" controller but
had to move to PI because P would not lock even after one hour and if
I moved the gain up it would over shoot and never lock. Adding "I"
was only 3 lines of C code and makes it lock in a few minutes.
On Wed, Apr 9, 2014 at 9:43 PM, Tom Van Baak <tvb at leapsecond.com> wrote:
>> You are right in the I don't even need data cycles. All I want is the
>> error which is 5,000,000 minus the count. this is hopefully zero.
> Correct. Keep the counter running. No need to zero it, ever. Use differential measurements. Essentially you are using binary modulus arithmetic.
>> This would be easier if we have a 32 bit counter that could be reset
>> to zero each second. In the past I think people have built counters
>> like this but now I can buy a $3.80 Arduino that does the counting,
>> ADC and DAC and computer USB interface. So I put up with a harder to
>> use 16-bit nonresetable counter
> In applications like this, never reset a counter to zero; this opens chances for off-by-one errors and cycle slips. Just compute differences. The start-up value of the timer is irrelevant.
> Moreover, 32-bits is unnecessary. Perhaps you didn't understand Bob's posting. Even 16-bits is more than enough. Let me explain.
> You only need enough bits to cover the worst case OCXO frequency drift or the worst case GPS jitter error, per second. For example, if your OCXO stays accurate to 1 ppm it can't possibly drift more than 1 us per second. Similarly, it's a safe assumption that your GPS 1PPS stays within 1 us of correct time. Therefore, the maximum number of 100 ns ticks you will be off in any second is +/-10. So even a 8-bit counter is enough. Does this make sense now?
> If you were building a general purpose arbitrary frequency counter, then a resetable 32-bit counter would be nice. But you're not. A GPSDO is a special case where you know the frequency will always be very close to 5 or 10 MHz every second. So you only need a few bits to measure the error each second.
> To use your decimal example, if the measurements are mostly 5000000 but sometimes 4999999 or 5000001 you only need to look at the last digit for your error. In hex this would be 4C4B40, 4C4B3F, 4C4B41, only the bottom two bits are needed (0, F, or 1).
> The bottom line is you don't need timer interrupts, you don't need time. You don't need 32-bits. You probably don't need 16-bits. You don't need semaphores. All you're interested in is how far off the oscillator is each second. One interrupt (for the GPS 1PPS) is all you need. If your CPU has a capture register you don't need interrupts at all. Then you don't need volatile either. Since your error is limited to +100 and -100 you can use 8-bit integers. You don't need to test for 30 hours; instead the code will be simple enough that it is air tight by design, not by luck. You will avoid interrupt collisions by not having more than one interrupt; you don't have to enable or disable interrupts either. You'll be surprised how simple it all gets.
> 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.
Redondo Beach, California
More information about the Time-nuts_lists.febo.com