Re: [time-nuts] ADC sample voting algorithm?

2016-10-06 Thread Angus
Hi,

You may have already done this, but if you log the same pulses with a
counter or actual TDC IC you can view it and see how they compare with
your measurements. 
Then you can look at how to get them closer - or find that it's
actually correct and that's just where the pulse is at the time.

Angus.



On Wed, 5 Oct 2016 16:45:21 -0700, you wrote:

>This is tangentially on topic, I suppose. It’s for my GPSDO.
>
>I notice periodically that the phase measurements seem “noisy.” You can see 
>that over the course of several seconds the value doesn’t change, then it 
>jumps a bunch and then comes right back.
>
>My theory at the moment is that sampling the ADC multiple times in a row might 
>help, but then what’s the best way to (quickly) pick which sample to use?
>
>The mean would allow a bad sample undue influence.
>
>At the moment, I’ve coded taking 3 samples, averaging them and picking the 
>sample that is closest to the mean. If I’m right, and two of the samples 
>happen to be very close to each other and a third is an outlier, then that 
>seems like it would eliminate it.
>
>I guess what I want is the mode, but with 3 samples, that’s going to be poorly 
>defined (if at all).
>
>Anyone have any suggestions (besides a larger sample size)?
>___
>time-nuts mailing list -- time-nuts@febo.com
>To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>and follow the instructions there.
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-06 Thread Poul-Henning Kamp

In message <59ab451c-ca1b-4824-a953-4f0f28b66...@kfu.com>, Nick Sayer via 
time-nuts writes:

>My theory at the moment is that sampling the ADC multiple times in a row might 
>help, but then what’s the best way to (quickly) pick which sample to use?

If you are sampling for noise:  Always the median.


-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread David
I always try to calculate things like the standard deviation and
peak-to-peak to get some idea if the measurement is valid.

A DSO with infinite persistence or envelope mode is great for tracking
this sort of thing down during development.  Only toy DSOs will lack
both.

On Wed, 05 Oct 2016 22:24:09 -0700, you wrote:

>time-nuts@febo.com said:
>> That’s kind of why I’m going down the road of multiple samples - to see 
>> if
>> there’s anything to it. 
>
>I would hack up some way to grab a clump (say 10) of samples and print them 
>out where you can capture them on a PC and analyze them.
>
>I'd start by looking with the old Mark 1 eyeballs, then write hack code to 
>filter out the good stuff so I can see the bad/interesting cases.
>
>If you have a scope, it might be interesting to trigger on PPS and look at 
>the ADC trigger and input voltage.  If you have a digital scope with the 
>remember forever option, that would catch the delayed interrupt bug that Jim 
>Harman reported.
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Hal Murray

time-nuts@febo.com said:
> That’s kind of why I’m going down the road of multiple samples - to see if
> there’s anything to it. 

I would hack up some way to grab a clump (say 10) of samples and print them 
out where you can capture them on a PC and analyze them.

I'd start by looking with the old Mark 1 eyeballs, then write hack code to 
filter out the good stuff so I can see the bad/interesting cases.

If you have a scope, it might be interesting to trigger on PPS and look at 
the ADC trigger and input voltage.  If you have a digital scope with the 
remember forever option, that would catch the delayed interrupt bug that Jim 
Harman reported.

---

The simple way to discard occasional bogus samples is to loop until you get 2 
identical samples.



-- 
These are my opinions.  I hate spam.



___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.

Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Jim Harman
On Wed, Oct 5, 2016 at 7:45 PM, Nick Sayer via time-nuts  wrote:

> I notice periodically that the phase measurements seem “noisy.” You can
> see that over the course of several seconds the value doesn’t change, then
> it jumps a bunch and then comes right back.
>

Hi Nick,

At one point I had a problem with noisy phase readings where the "noise"
took the form of an occasional reading that was low by up to about 50
counts. These events were quite rare - less often than once per hour on
average. After much head-scratching, it turned out that I had an interrupt
conflict that sometimes caused the PPS interrupt to be delayed, Because the
ADC was triggered inside this routine, the analog signal had drooped a
little before the ADC was triggered.

I was able to completely solve this by setting up the ADC sample/hold and
conversion to be triggered directly by the PPS signal, thus eliminating any
dependency on the interrupt latency. The PPS still generates an interrupt,
but in the interrupt routine, all I have to do is wait for the ADC to
finish, clear the Done bit, and reset the trigger.


-- 

--Jim Harman
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Scott Stobbe
It sounds like once in awhile your sampling something else too. Ground
bounce of a 10 MHz buffer, or something coupling onto your phase detector,
or running your adc at the edge of a timing spec?

How large would the outlier be in mV?

On Wednesday, 5 October 2016, Nick Sayer via time-nuts 
wrote:

> This is tangentially on topic, I suppose. It’s for my GPSDO.
>
> I notice periodically that the phase measurements seem “noisy.” You can
> see that over the course of several seconds the value doesn’t change, then
> it jumps a bunch and then comes right back.
>
> My theory at the moment is that sampling the ADC multiple times in a row
> might help, but then what’s the best way to (quickly) pick which sample to
> use?
>
> The mean would allow a bad sample undue influence.
>
> At the moment, I’ve coded taking 3 samples, averaging them and picking the
> sample that is closest to the mean. If I’m right, and two of the samples
> happen to be very close to each other and a third is an outlier, then that
> seems like it would eliminate it.
>
> I guess what I want is the mode, but with 3 samples, that’s going to be
> poorly defined (if at all).
>
> Anyone have any suggestions (besides a larger sample size)?
> ___
> time-nuts mailing list -- time-nuts@febo.com 
> To unsubscribe, go to https://www.febo.com/cgi-bin/
> mailman/listinfo/time-nuts
> and follow the instructions there.
>
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Bob Camp
Hi

If you are looking at a high impedance source with a “normal” ADC, you need a 
buffer amp. 

If you have a signal that decays, it is generally not a good idea to toss all 
the samples into a 
single bucket. You probably need to do some sort of slope estimation. 

The still better solution is to get an ADC that is not super noisy. Most built 
in ADC’s on 
MCU’s are quite noisy when evaluated against their claimed resolution level. 
Even with a few
thousand samples, this may not improve as much as you would wish for. 

Better still, use a converter with a fast enough slope that the ADC noise is 
not an issue. 

Bob

> On Oct 5, 2016, at 8:22 PM, Nick Sayer via time-nuts  
> wrote:
> 
> 
>> On Oct 5, 2016, at 5:00 PM, Bob Camp  wrote:
>> 
>> Hi
>> 
>> What does the signal you are sampling look like? 
> 
> The last time I actually looked (it was a while ago), it looked reasonable as 
> closely as I could look, but the ADC resolution is something like 1mV per 
> LSB, and I’m not sure I looked that closely.
> 
>> 
>> Does it (maybe) have a bit of noise on it?
>> 
>> If it is the output of a “normal” TDC, then the answer is to sample once.
> 
> I dunno about a “normal” one… This one is the one I got from Jim Harman. The 
> phase difference between the divided-by-10 output and PPS goes through a 
> diode, JFET and then an RC (with a much higher discharge resistor).
> 
> As long as you sample at least 1 µs after the PPS (and it takes at least that 
> long to get into the ISR anyway), it *ought* to be stable for dozens of µs.
> 
> That’s kind of why I’m going down the road of multiple samples - to see if 
> there’s anything to it.
> 
> 
> ___
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Nick Sayer via time-nuts

> On Oct 5, 2016, at 5:00 PM, Bob Camp  wrote:
> 
> Hi
> 
> What does the signal you are sampling look like? 

The last time I actually looked (it was a while ago), it looked reasonable as 
closely as I could look, but the ADC resolution is something like 1mV per LSB, 
and I’m not sure I looked that closely.

> 
> Does it (maybe) have a bit of noise on it?
> 
> If it is the output of a “normal” TDC, then the answer is to sample once.

I dunno about a “normal” one… This one is the one I got from Jim Harman. The 
phase difference between the divided-by-10 output and PPS goes through a diode, 
JFET and then an RC (with a much higher discharge resistor).

As long as you sample at least 1 µs after the PPS (and it takes at least that 
long to get into the ISR anyway), it *ought* to be stable for dozens of µs.

That’s kind of why I’m going down the road of multiple samples - to see if 
there’s anything to it.


___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Bob Stewart
In that case, have you taken the time to look at the math of the sawtooth vs 
measured phase?  If you like, you can send me 20 or 30 sequential data samples 
that contains what appears to be good as well as the bad to look at?  And which 
receiver are you using for this?
Bob -
AE6RV.com

GFS GPSDO list:
groups.yahoo.com/neo/groups/GFS-GPSDOs/info

  From: Nick Sayer via time-nuts <time-nuts@febo.com>
 To: 
Cc: Discussion of precise time and frequency measurement <time-nuts@febo.com>
 Sent: Wednesday, October 5, 2016 6:57 PM
 Subject: Re: [time-nuts] ADC sample voting algorithm?
   

> On Oct 5, 2016, at 4:52 PM, Bob Stewart <b...@evoria.net> wrote:
> 
> Hi Nick,
> 
> Are you applying sawtooth correction to your phase measurement? 

Yes, these are post-correction observations. I have some confidence that my 
corrections are scaled appropriately for the ADC values because of their 
stability “most” of the time (meanwhile, the uncorrected values are bouncing 
around inside a 12 ns corridor).

> If not, are you merely seeing a hanging bridge that dissolves into at a 
> normal sort of tick-tock movement?
> 
> Bob
> 
> From: Nick Sayer via time-nuts <time-nuts@febo.com>
> To: Discussion of precise time and frequency measurement <time-nuts@febo.com> 
> Sent: Wednesday, October 5, 2016 6:45 PM
> Subject: [time-nuts] ADC sample voting algorithm?
> 
> This is tangentially on topic, I suppose. It’s for my GPSDO.
> 
> I notice periodically that the phase measurements seem “noisy.” You can see 
> that over the course of several seconds the value doesn’t change, then it 
> jumps a bunch and then comes right back.
> 
> My theory at the moment is that sampling the ADC multiple times in a row 
> might help, but then what’s the best way to (quickly) pick which sample to 
> use?
> 
> The mean would allow a bad sample undue influence.
> 
> At the moment, I’ve coded taking 3 samples, averaging them and picking the 
> sample that is closest to the mean. If I’m right, and two of the samples 
> happen to be very close to each other and a third is an outlier, then that 
> seems like it would eliminate it.
> 
> I guess what I want is the mode, but with 3 samples, that’s going to be 
> poorly defined (if at all).
> 
> Anyone have any suggestions (besides a larger sample size)?
> ___
> time-nuts mailing list -- time-nuts@febo.com <mailto:time-nuts@febo.com>
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts 
> <https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts>
> and follow the instructions there.
> 
> 

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


   
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Bob Camp
Hi

What does the signal you are sampling look like? 

Does it (maybe) have a bit of noise on it? 

If it is the output of a “normal” TDC, then the answer is to sample once.

Bob

> On Oct 5, 2016, at 7:45 PM, Nick Sayer via time-nuts  
> wrote:
> 
> This is tangentially on topic, I suppose. It’s for my GPSDO.
> 
> I notice periodically that the phase measurements seem “noisy.” You can see 
> that over the course of several seconds the value doesn’t change, then it 
> jumps a bunch and then comes right back.
> 
> My theory at the moment is that sampling the ADC multiple times in a row 
> might help, but then what’s the best way to (quickly) pick which sample to 
> use?
> 
> The mean would allow a bad sample undue influence.
> 
> At the moment, I’ve coded taking 3 samples, averaging them and picking the 
> sample that is closest to the mean. If I’m right, and two of the samples 
> happen to be very close to each other and a third is an outlier, then that 
> seems like it would eliminate it.
> 
> I guess what I want is the mode, but with 3 samples, that’s going to be 
> poorly defined (if at all).
> 
> Anyone have any suggestions (besides a larger sample size)?
> ___
> time-nuts mailing list -- time-nuts@febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Bob Stewart
Hi Nick,
Are you applying sawtooth correction to your phase measurement?  If not, are 
you merely seeing a hanging bridge that dissolves into at a normal sort of 
tick-tock movement?
Bob

  From: Nick Sayer via time-nuts <time-nuts@febo.com>
 To: Discussion of precise time and frequency measurement <time-nuts@febo.com> 
 Sent: Wednesday, October 5, 2016 6:45 PM
 Subject: [time-nuts] ADC sample voting algorithm?
   
This is tangentially on topic, I suppose. It’s for my GPSDO.

I notice periodically that the phase measurements seem “noisy.” You can see 
that over the course of several seconds the value doesn’t change, then it jumps 
a bunch and then comes right back.

My theory at the moment is that sampling the ADC multiple times in a row might 
help, but then what’s the best way to (quickly) pick which sample to use?

The mean would allow a bad sample undue influence.

At the moment, I’ve coded taking 3 samples, averaging them and picking the 
sample that is closest to the mean. If I’m right, and two of the samples happen 
to be very close to each other and a third is an outlier, then that seems like 
it would eliminate it.

I guess what I want is the mode, but with 3 samples, that’s going to be poorly 
defined (if at all).

Anyone have any suggestions (besides a larger sample size)?
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


   
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Nick Sayer via time-nuts

> On Oct 5, 2016, at 4:52 PM, Bob Stewart <b...@evoria.net> wrote:
> 
> Hi Nick,
> 
> Are you applying sawtooth correction to your phase measurement? 

Yes, these are post-correction observations. I have some confidence that my 
corrections are scaled appropriately for the ADC values because of their 
stability “most” of the time (meanwhile, the uncorrected values are bouncing 
around inside a 12 ns corridor).

> If not, are you merely seeing a hanging bridge that dissolves into at a 
> normal sort of tick-tock movement?
> 
> Bob
> 
> From: Nick Sayer via time-nuts <time-nuts@febo.com>
> To: Discussion of precise time and frequency measurement <time-nuts@febo.com> 
> Sent: Wednesday, October 5, 2016 6:45 PM
> Subject: [time-nuts] ADC sample voting algorithm?
> 
> This is tangentially on topic, I suppose. It’s for my GPSDO.
> 
> I notice periodically that the phase measurements seem “noisy.” You can see 
> that over the course of several seconds the value doesn’t change, then it 
> jumps a bunch and then comes right back.
> 
> My theory at the moment is that sampling the ADC multiple times in a row 
> might help, but then what’s the best way to (quickly) pick which sample to 
> use?
> 
> The mean would allow a bad sample undue influence.
> 
> At the moment, I’ve coded taking 3 samples, averaging them and picking the 
> sample that is closest to the mean. If I’m right, and two of the samples 
> happen to be very close to each other and a third is an outlier, then that 
> seems like it would eliminate it.
> 
> I guess what I want is the mode, but with 3 samples, that’s going to be 
> poorly defined (if at all).
> 
> Anyone have any suggestions (besides a larger sample size)?
> ___
> time-nuts mailing list -- time-nuts@febo.com <mailto:time-nuts@febo.com>
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts 
> <https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts>
> and follow the instructions there.
> 
> 

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


[time-nuts] ADC sample voting algorithm?

2016-10-05 Thread Nick Sayer via time-nuts
This is tangentially on topic, I suppose. It’s for my GPSDO.

I notice periodically that the phase measurements seem “noisy.” You can see 
that over the course of several seconds the value doesn’t change, then it jumps 
a bunch and then comes right back.

My theory at the moment is that sampling the ADC multiple times in a row might 
help, but then what’s the best way to (quickly) pick which sample to use?

The mean would allow a bad sample undue influence.

At the moment, I’ve coded taking 3 samples, averaging them and picking the 
sample that is closest to the mean. If I’m right, and two of the samples happen 
to be very close to each other and a third is an outlier, then that seems like 
it would eliminate it.

I guess what I want is the mode, but with 3 samples, that’s going to be poorly 
defined (if at all).

Anyone have any suggestions (besides a larger sample size)?
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.