Southpark:
The diagram below would make everything clear to all.
That is spot on...
GoForSmoke:
1 ms, your average time to measure is 16000 cycles. Unsigned 16 bit counts to 32767. What's the problem?
Since the time values are unsigned you can always subtract an earlier time from a later time to know the elapsed time regardless of unsigned rollover. It's a non-issue as long as you do the unsigned subtraction. It's like a 12 hour clock. The number of hours starting at 9 and ending at 2 are 2 - 9 = 5. To subtract 9 from 2, move counter clockwise 9 from 2 and you have the answer 5. That is unsigned subtraction. As long as your time variables can hold the largest interval needed, you're good.
You might look into just how accurate the 16MHz of your boards really is.
I think I understand what you are saying. More than half the time, time2 is truly greater than time1 and the clock has not reset. This becomes more of an issue when I was doing the following:
volatile unsigned long Time1;
volatile unsigned long Time2;
...
unsigned long deltaTime1 = Time2 - Time1;
I think what I need is:
volatile uint16_t Time1;
volatile uint16_t Time2;
...
uint16_t deltaTime1 = Time2 - Time1;
...and this would work as long is I do not exceed 2^16-1/16,000,000 seconds?
Smajdalf:
The only problem of using Arduino Uno is "poor" stability of used ceramic resonator. But any other method aiming for better accuracy must get better clock source and there is no reason why (standalone) ATMega couldn't use such clock source to get the same accuracy.
I thought the UNO uses a crystal vice a ceramic oscillator. Truly I thought there is a ceramic oscillator onboard and a crystal mounted to the PCB. Is this not correct?
I am going to be buying a GPS shield for the PPS signal. I hear it is accurate to within 10ns if you have a 4 satellite fix. So safe to say it is more precise and accurate than arduino. Ultimately I would like to keep the timer separate from a GPS, but use the GPS to characterize the UNOs crystal. I plan to characterize the uno's crystal over a period of a couple weeks. Time to figure out an allan deviation. My plan is to use the atmegas on-board temperature sensor to temperature compensate the crystal. I understand that Tchip does not equal Tcrystal but assume that it will be close enough. If temperature compensation is not effective, I may just keep the GPS attached and have some boot up routine that characterizes the crystal.
The actual measurement will use timer1 with no prescaler and timer0 or timer2 prescaled to cover about 2 seconds (I also could use software and assume the pulses are 1 second apart and forgo the second timer). Every second I will store the clock cycles per second and then analyze the data. I am assuming the PPS is a short duration 5 volt high pulse at 1 second intervals.