The Cyber-Spy.Com Usenet Archive Feeds Directly
From The Open And Publicly Available Newsgroup
This Group And Thousands Of Others Are Available
On Most IS NNTP News Servers On Port 119.
Cyber-Spy.Com Is NOT Responsible For Any Topic,
Opinions Or Content Posted To This Or Any Other
Newsgroup. This Web Archive Of The Newsgroup And
Posts Are For Informational Purposes Only.
From: firstname.lastname@example.org (Tom Bruhns)
Subject: Re: Audio Phase meter cct wanted
Date: 19 Nov 2002 10:48:38 -0800
References: <email@example.com> <firstname.lastname@example.org>
NNTP-Posting-Date: 19 Nov 2002 18:48:38 GMT
So...now that I have you hooked on the basic idea, I'll toss out just
a bit more info.
First of all, if you generate your sine wave in the same processor, or
at least locked to the same clock, you'll be ahead. That way, you can
get the sine frequency exactly on the DFT's frequency. Interestingly,
you can use the same algorithm to generate a sine wave; just
initialize the state variables to values representing the phase and
amplitude you want. It's possible for roundoff errors to cause the
amplitude to increase or decay, or the frequency to be slightly off,
but at least it's one way to do the job. If you have to measure the
phase between two signals you don't generate, but which you know to be
from the same original source and therefore the same frequency, then
it would be helpful to lock the digitization clock to them.
Next, it can be helpful to sample at exactly 4 times or 8 times the
input frequency. If you use 4 times, for example, then the phase
shift between successive samples is just exactly 90 degrees, and in a
"canonical" biquad, the state variables will be samples of a sine wave
90 degrees out of phase. Then it becomes relatively easy to find the
phase angle of that wave, just the arctangent of the ratio of the two
state variables. You really start to get into trouble with finite
precision arithmetic if the number of samples per cycle is large and
you are using a canonical biquad.
However, if the freq is low and you want to take more samples to get
more data to include in your processing, you can set up a little
different filter topology. One that has worked very well for me is to
have each state variable be the output of a "digital integrator" which
implements y(k+1)=c*u(k)+y(k)...just add the scaled input to the
current value to get the next value. A cascade of two of those stages
looks very similar to a cascade of two analog integrators, and that's
the basis of an analog state variable filter. Then you arrange the
feedback to get the complex pole pair on the unit circle in the
z-plane...it all ends up looking very much like what you'd do with the
analog state variable filter to do the same thing. Then the two state
variables (the digital integrator outputs) are very nearly 90 degrees
out of phase, for that case of lots of samples per cycle.
Results: the instruments we build are general purpose vector spectral
analysis instruments. They work by digitizing the input and
performing FFTs. They are only digitizing to 14 or 16 bits, but I
have no trouble displaying stable phase relations down to about a
millidegree or so, if the inputs are reasonably "clean". So with only
audio range signals, you can see the difference in length between
cables feeding the "same" signal to two channels. 10 millidegrees at
20kHz, for example, is only about 1.4 nanoseconds. You can generally
do things like swapping channels and averaging to remove the
systematic error in the measuring instrument, if your inputs are
stable. I would expect to be able to do as good at a single frequency
with an inexpensive stereo delta-sigma ADC and a processor that can
handle the math fast enough and to enough bits of precision. Guess
that could all be a PC with a sound card. :-) Doesn't even have to
be fast if you can do the processing after acquisition of the signal.
You might even be able to do the math in Excel or Matlab or Scilab.
"John Jardine" wrote in message news:...
> Tom, thanks for the supporting info.
> Just recently I've tried a number of methods for the (precise) extraction of
> the phase difference between two signals and from what you have said I think
> it's worth giving the Goertzel a 'go'. Yes, the Goertzel routine looks quite
> small and it's going to be easy enough to simply programme the thing in
> Basic (floating point to start with) and trying out some different
> implementations and variables (data sets, sample rates etc) and simply
> examine the ensuing numbers.
> I've generally found that most of the digital methods out there all seem to
> offer some kind of theoretical perfection but when it gets down to the nitty
> gritty they start falling apart at the seams due to bedevilment by non
> infinite sample rates, imperfect S/N ratios or as you mention, sensitivity
> to sample set start/stop points.
> I have though had results far better better using digital methods than
> anything in the analogue area. I've also found no outright digital winner so
> it's simply?! a question of finding an optimum (whole system) method that
> does not break my bank.
> I've seen the algorithm used in commercial phase modulated modems so in one
> sense it has proved itself to be quite effective. The Goertzel may be the
> Thanks again
Go Back To The Cyber-Spy.Com
Usenet Web Archive Index Of
The sci.electronics.design Newsgroup