[Top][All Lists]

Re: [Discuss-gnuradio] Using DSP for precise zero crossing, measurement?

 From: John Ackermann N8UR Subject: Re: [Discuss-gnuradio] Using DSP for precise zero crossing, measurement? Date: Tue, 19 Sep 2006 15:04:45 -0400 User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

```Lee Patton wrote:
```
```Thanks, Bob -

I think this problem is a little trickier than previously assumed
because:

1) I believe John wants to measure frequency drift over time (i.e.,
drift of one clock with respect to a reference)  So, the clock signals
cannot be assumed to be 100% coherent.  Otherwise, there would be no
drift to measure.  The problem here is that there is no underlying model
for how this drift occurs. (It's what he's trying to find out!)  The
signals are probably very close to coherent over some finite window, but
the problem becomes one of determining a window size that helps
integrate out noise but doesn't do too much averaging of the drifting
signal to obtain parameter estimates.
```
```
```
The two signals are definitely not coherent. The offset is likely to be small, but it's there.
```
```
The real goal is not to measure the long term drift, but rather the short term variation (i.e., if the deltat between F1 and F2 is 1us, how much does it wiggle around that 1us value from second to second).
```
```
```2) John wants to measure to the best possible accuracy.  So, while we
assume A1=A2=1, this might not be the best assumption.  Even if he
measures the amplitude at the output of his clocks, there is no
guarantee that both digitizing channels are completely calibrated.  They
may be "good enough," but that depends on his application.
```
```
```
Ideally, I'd like to avoid measuring the amplitude with any device other than the ADC that's being used for the sampling.
```
```
```3) Relating to (1), I think John needs estimates of instantaneous
frequency over time.  A sliding window method similar to the one
outlined below would work. Again though, how is the window size chosen
if the nature of the drift isn't known?  Similarly, there are adaptive
techniques that could be used.  They should track to some degree, but
again, at what point do they break lock, and how do we know?
```
```
You got it.

```
As you all know, I'm no mathematician. On the airplane ride home from the Digital Communications Conference Sunday night, my friend Tom (who's an RF engineer but not a DSP theory guy) and I roughed out a simple idea like this (please feel free to laugh and throw things):
```
1.  determine when the slope of the waveform was positive.

```
2. start grabbing samples at some point shortly before the nominal zero crossing.
```
```
3. continue grabbing samples until some point shortly after the nominal zero crossing.
```
```
4. use an appropriate set (e.g., the endpoints, or a least-squares fit) of those samples to determine the slope of the signal around the zero crossing.
```
```
5. find the two samples that most closely bracket the zero crossing, and use the slope derived in step 4 to interpolate between those two samples to find the real zero crossing time.
```
6.  use any extra samples in some magical way to
```
decrease the impact of any noise on the interpolation (told you, we aren't statisticians or DSP experts!).
```
```
7. timestamp the samples so we can determine the time between zero crossing of F1 and zero crossing of F2
```
8.  log that difference to later feed to the Allan Deviation program

```
One interesting question was whether we were better served in this algorithm by having more bits in the ADC for better voltage discrimination, or a higher sample rate for better frequency discrimination.
```
```
I'm sure that this method has serious flaws, but perhaps the zero crossing has the advantage of being amplitude-independent (so long as you stay close enough to the middle of the waveform so that the slope is approximately constant).
```
John

```