<div dir="ltr"><div>Hi Robin</div><div><br></div><div>An FFT is probably not the best way to go as, generally, that is going to be maths heavy.</div><div><br></div><div>Basically what you're trying to do is reconstruct the signal  from what you are receiving then measure the phase difference between the transmitted and the received signal.</div><div><br></div><div>I assume you're using a single tone rather than mised audio. Keeping it to a single tone will make life much easier.</div><div><br></div><div>I recommend starting off with taking the tx and rx signals and feeding them into an oscilloscope and seeing the signal delay and then working from there.</div><div><br></div><div>There is another way to do this which is to use the flight time from the tx to the rx as the delay in an oscillator. If the wind is blowing from tx to rx then it will carry the signal faster resulting in a frequency shift.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 5, 2020 at 6:17 PM Mark Atherton <<a href="mailto:markaren1@xtra.co.nz">markaren1@xtra.co.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><a href="http://www.dspguide.com/ch7.htm" rel="noreferrer" target="_blank">http://www.dspguide.com/ch7.htm</a> specifically convolution<br>
<br>
<a href="http://www.dspguide.com/ch7/3.htm" rel="noreferrer" target="_blank">http://www.dspguide.com/ch7/3.htm</a> has some basic drawings<br>
<br>
The latter may have a pictorial example of what you are trying to do<br>
<br>
DSPguide is a brilliant book.<br>
<br>
HTH<br>
<br>
-Mark<br>
<br>
<br>
<br>
<br>
On 5/07/2020 5:27 PM, Robin Gilks wrote:<br>
<br>
> Me again!<br>
><br>
> I'm still getting nowhere with my project that will use ultrasonic<br>
> transducers to measure wind speed.<br>
><br>
> I understand that I need to run a cross correlation between the original<br>
> transmitted signal and the delayed received one in order to work out the<br>
> delay and hence (with a fixed distance between transducers) the speed of<br>
> the wind.<br>
><br>
> Trouble is, when I try to find basic information I end up in a cloud of<br>
> matlab and scipy mazes that don't help me at all. I just don't seem to be<br>
> able to make the leap from basic idea to usable code on an embedded<br>
> system. It really doesn't help me to read that I need to an FFT when I<br>
> wouldn't know an FFT from a dead elephant!<br>
><br>
> A typical example of what I find is thus (from<br>
> <a href="https://www.dsprelated.com/showarticle/26.php" rel="noreferrer" target="_blank">https://www.dsprelated.com/showarticle/26.php</a>):<br>
><br>
> "A well-known solution to estimate delay is to calculate the<br>
> cross-correlation between the two signals. An efficient implementation<br>
> calculates |ifft(fft(a) .* fft(b)|, using FFT for cyclic convolution.<br>
> A peak in the result indicates the integer-sample delay with best alignment."<br>
><br>
> warblefarblegarble :(<br>
><br>
> Thought a couple of times that I'd found a code snippet that delivered the<br>
> goods but on trying them out they don't actually work. e.g.<br>
> <a href="https://bitbucket.org/GreyCat/calc-sound-delay/src/default/" rel="noreferrer" target="_blank">https://bitbucket.org/GreyCat/calc-sound-delay/src/default/</a><br>
> I feed in 2 audio files, one of which I have trimmed a 150ms from the<br>
> front of with Audacity and it tells me the delay is 3-4 times what I'd<br>
> actually created.<br>
><br>
> Confused...<br>
><br>
<br>
<br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div>