DSPRelated.com
Forums
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →

How to calculate time differrent between two signals?

Started by Hieu Le Trung ●October 3, 2006
>> Oh, come now! Cross correlation works very well indeed on any two >> signals that are differently delayed versions of the same signal and >> whose period is longer than the differential delay. > >Just wondering why "period is longer than the differential delay" is a >factor? I can see that for two continuous sinusoids, if the >differential delay is longer than a period then you can't uniquely >identify what the real delay is. But IMHO that is nothing to do with >cross correlation. If you show somone a picture of these two sinusoids, >they will be able to tell you the phase delay, but not the actual >differential time delay. > >Just curious. > >Regards >Andrew > >
So i can use "Generalize Cross Correlation" to compute sound source location is it? If yes, which does any algorithm exists or i must look through the theory to implement a new one? And where can i find out some theory about "Generalize Cross Correlation"? Thanks Hieu
Hieu Le Trung skrev:
> >> Oh, come now! Cross correlation works very well indeed on any two > >> signals that are differently delayed versions of the same signal and > >> whose period is longer than the differential delay. > > > >Just wondering why "period is longer than the differential delay" is a > >factor? I can see that for two continuous sinusoids, if the > >differential delay is longer than a period then you can't uniquely > >identify what the real delay is. But IMHO that is nothing to do with > >cross correlation. If you show somone a picture of these two sinusoids, > >they will be able to tell you the phase delay, but not the actual > >differential time delay. > > > >Just curious. > > > >Regards > >Andrew > > > > > > So i can use "Generalize Cross Correlation" to compute sound source > location is it?
Not directly, no. What you try to do is a two-step thing: 1) Compute time delays from data 2) Compute source position from time delays You can use correlation to achieve subtask 1. Once you have done that, you can look up ways of achieving subtask 2.
> If yes, which does any algorithm exists or i must look through the theory > to implement a new one?
The book I suggested in another post is almost mandatory when working with these sorts of problems. Try to get a copy on loan from your local library.
> And where can i find out some theory about "Generalize Cross > Correlation"?
I don't know this particular scheme, but that same book is a very good starting point. Rune
Andrew FPGA wrote:
>> Oh, come now! Cross correlation works very well indeed on any two >> signals that are differently delayed versions of the same signal and >> whose period is longer than the differential delay. > > Just wondering why "period is longer than the differential delay" is a > factor? I can see that for two continuous sinusoids, if the > differential delay is longer than a period then you can't uniquely > identify what the real delay is. But IMHO that is nothing to do with > cross correlation. If you show somone a picture of these two sinusoids, > they will be able to tell you the phase delay, but not the actual > differential time delay. > > Just curious.
You answered your own question. Without the period restriction, correlation yields an ambiguity; all you get is phase delay. If the waveform is aperiodic or has a period known to be longer than the relative delay, the ambiguity is sidestepped. Jerry -- "The rights of the best of men are secured only as the rights of the vilest and most abhorrent are protected." - Chief Justice Charles Evans Hughes, 1927 ���������������������������������������������������������������������
Rune Allnor wrote:
> Andrew FPGA skrev: >>> Oh, come now! Cross correlation works very well indeed on any two >>> signals that are differently delayed versions of the same signal and >>> whose period is longer than the differential delay. >> Just wondering why "period is longer than the differential delay" is a >> factor? > > Seems to me to be a way of saying that cross correlation works for > baseband sampled signals, but not necessarily for bandpass sampled > signals.
Interesting! Please explain. Jerry -- "The rights of the best of men are secured only as the rights of the vilest and most abhorrent are protected." - Chief Justice Charles Evans Hughes, 1927 ���������������������������������������������������������������������
Jerry Avins skrev:
> Rune Allnor wrote: > > Andrew FPGA skrev: > >>> Oh, come now! Cross correlation works very well indeed on any two > >>> signals that are differently delayed versions of the same signal and > >>> whose period is longer than the differential delay. > >> Just wondering why "period is longer than the differential delay" is a > >> factor? > > > > Seems to me to be a way of saying that cross correlation works for > > baseband sampled signals, but not necessarily for bandpass sampled > > signals. > > Interesting!
Ouch! What have I got myself into now? The strongest word of disbelief academia has ever known, and with the exclamation mark... note the caveat "not necessarily" in my previous post.
> Please explain.
There are a couple of terms above that might be ambiguous. "Differential delay" is one such term, I interpreted it as "sampling delay". Now that I read it again, I see that the term could be interpreted as "relative time shift". If that's what you meant, well, then we are comparing apples and polar bears. Assuming you accept me discussing sampling intervals and periods, it is fairly obvious that for Nyquist's theorem to be valid, the period of the signals have to be longer than the sampling interval. In the case of baseband sampling, that is. If the period is not longer than the sampling interval, we are talking about bandpass sampling. Now, one of the useful aspects of cross correlation analysis, is the relation between the slope of the phase, dphi(w)/dw, and the relative time shift tau. In bandpass sampled systems, I can't really see that this same relation obviously holds, or at least can be readily exploited, hence my "not necessarily". OK? < sprinting away for cover > Rune
Rune Allnor wrote:
> Jerry Avins skrev: >> Rune Allnor wrote: >>> Andrew FPGA skrev: >>>>> Oh, come now! Cross correlation works very well indeed on any two >>>>> signals that are differently delayed versions of the same signal and >>>>> whose period is longer than the differential delay. >>>> Just wondering why "period is longer than the differential delay" is a >>>> factor? >>> Seems to me to be a way of saying that cross correlation works for >>> baseband sampled signals, but not necessarily for bandpass sampled >>> signals. >> Interesting! > > Ouch! What have I got myself into now? The strongest word of > disbelief academia has ever known, and with the exclamation > mark... note the caveat "not necessarily" in my previous post. > >> Please explain. > > There are a couple of terms above that might be ambiguous. > "Differential delay" is one such term, I interpreted it as "sampling > delay". Now that I read it again, I see that the term could be > interpreted as "relative time shift". If that's what you meant, well, > then we are comparing apples and polar bears.
I meant the difference between the delays from source to destination of the individual signal paths. We were talking past one another. Sorry! By "interesting!", I meant that I was about to learn something. I was wrong about that too. ... Jerry -- "The rights of the best of men are secured only as the rights of the vilest and most abhorrent are protected." - Chief Justice Charles Evans Hughes, 1927 &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Ok, so if I had a 100kHz sonar probing pulse (unmodulated) that lasted
for 5 ms, and a phased array receiver consisting of only two
elements/channels (for arguments sake). So if I'm trying to measure the
differential time delay of the pulse return arrival,  I probably need a
cross correlation length of at least 5ms if the differential time delay
could be > 1/100kHz =3D 10us to get a unique measurement of the
differential delay?

I'm sampling at 300kHz (say) to keep nyquist happy and the anti-alias
filter happy.  So need to store at least 5ms * 300kHz =3D 1500 samples *
16bits each so need to store 24kbit per channel.  Its an FPGA
implementation of the cross correlation, so assuming xilinx 18 kbit
block rams(BRAM), I need a bit more than 1 BRAM per channel. Which I
guess is ballpark ok given the smallest Xilinx spartan 3 has 4 BRAMS,
and the 2nd smallest as 12.

In reality, the sonar probing pulse most likely is modulated, probably
with a chirp or some such. Could I do better to demodulate, and
decimate each channel first, and then do a cross correlation? That
would reduce the memory and computation requirements of the cross
correlation. (The FPGA memory is expensive, I'm less worried about the
computational expense of the demod/decimate).  But I wonder what that
does to the accuracy of the differential delay measurement (by cross
correlation)?

Probably about time I fired up Matlab to try and answer some of these
questions...
Regards
Andrew











=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF

Andrew FPGA skrev:
> Ok, so if I had a 100kHz sonar probing pulse (unmodulated) that lasted > for 5 ms, and a phased array receiver consisting of only two > elements/channels (for arguments sake). So if I'm trying to measure the > differential time delay of the pulse return arrival, I probably need a > cross correlation length of at least 5ms if the differential time delay > could be > 1/100kHz = 10us to get a unique measurement of the > differential delay?
Yes. Anything shorter, and you can match up periods but you don't know what periods you work with. Assume you index the positive amplitudes in the transmitted pulse from 1 to N. If your correlation window corresponds to, say, 0.2N periods, you can vind out the phase delay between peridods but you have no idea whether you compare the same portions of the signal. ...
> In reality, the sonar probing pulse most likely is modulated, probably > with a chirp or some such. Could I do better to demodulate, and > decimate each channel first, and then do a cross correlation?
Academically speaking: yes. The signals are modulated partially because one wants to increase detection ranges while keeping transmitter levels down; partially to increase spatial resolution of range estimates. Chirp pulses achieve this. In practice, the problem with this is Doppler. The relative speeds of certain sensor/target configurations are on the order of Mach 0.05, which translates almost directly to a frequency shift of some 5% either way.
> That > would reduce the memory and computation requirements of the cross > correlation.
Sure. Working at base band is a huge advantage for narrow-band systems.
> (The FPGA memory is expensive, I'm less worried about the > computational expense of the demod/decimate). But I wonder what that > does to the accuracy of the differential delay measurement (by cross > correlation)?
Little, really. First, it is the bandwidth of the signals, not the sampling bandwidth, that limits the accuracy of the timing estimate. So even if you have denser sampling in the raw data, the "hump" in the correlation function will be equally wide in time domain, in both cases. Add a little bit of noise, and the denser sampling doesn't help that much. Conversely, if you need higher accuracy in timing estimates for the slower sampled wave form, you can do the analysis in frequency domain and investigate the slope of the phase of the cross spectrum. At an added computational cost, of course.
> Probably about time I fired up Matlab to try and answer some of these > questions...
Always a good idea. Rune
> In practice, the problem with this is Doppler. The relative speeds > of certain sensor/target configurations are on the order of Mach 0.05, > which translates almost directly to a frequency shift of some 5% > either way.
> Conversely, if you need higher accuracy in timing estimates > for the slower sampled wave form, you can do the analysis in > frequency domain and investigate the slope of the phase > of the cross spectrum.
Thanks for your insight Rune. I will have to experiment a bit.
> >Hieu Le Trung skrev: >> >> Oh, come now! Cross correlation works very well indeed on any two >> >> signals that are differently delayed versions of the same signal
and
>> >> whose period is longer than the differential delay. >> > >> >Just wondering why "period is longer than the differential delay" is
a
>> >factor? I can see that for two continuous sinusoids, if the >> >differential delay is longer than a period then you can't uniquely >> >identify what the real delay is. But IMHO that is nothing to do with >> >cross correlation. If you show somone a picture of these two
sinusoids,
>> >they will be able to tell you the phase delay, but not the actual >> >differential time delay. >> > >> >Just curious. >> > >> >Regards >> >Andrew >> > >> > >> >> So i can use "Generalize Cross Correlation" to compute sound source >> location is it? > >Not directly, no. > >What you try to do is a two-step thing: > >1) Compute time delays from data >2) Compute source position from time delays > >You can use correlation to achieve subtask 1. Once you >have done that, you can look up ways of achieving subtask 2. >
Ok, i have tried the GCC with PHAT and SCOT. It gave me an array of number, what should i do now to calculate the time delays?
>> If yes, which does any algorithm exists or i must look through the
theory
>> to implement a new one? > >The book I suggested in another post is almost mandatory when >working with these sorts of problems. Try to get a copy on loan >from your local library. >
Which post is it?
>> And where can i find out some theory about "Generalize Cross >> Correlation"? > >I don't know this particular scheme, but that same book is a very >good starting point. > >Rune > >
One more thing, two signals are not the same. Thank you Hieu