[chbot] Determining delay between two similar signals

Richard Jones richardandjanenz at gmail.com
Mon Jul 6 09:33:56 BST 2020


Hi Robin,

I can't see anything wrong with the code example
https://bitbucket.org/GreyCat/calc-sound-delay/src/default/
Maybe the problem is your test waveform? Correlating with a continuous sine
wave could give you an indeterminate result in time with a peak on every
cycle.
You need a signal with a well defined pattern that can be located in time.
Hence the long sync patterns used to achieve symbol sync in digital radio.
With your anemometer ultrasonics probably working in the 40kHz region you
could try something like sending 4 cycles, then reverse phase by 180° send
another 4 cycles.
Then correlate sliding along the received waveform over the 8 cycle period
against the ideal waveform and you should detect a maximum correlation well
defined in time. You may need to look closely at the received waveform
considering the Q of the sender and receiver to decide how to design your
sync waveform for acceptable performance.

The ultrasonic HC-SR04 modules measure distance fairly well using a simple
burst. You might get sufficiently good performance using the analogue
electronics of an HC-SR04 module while replacing the processor and using a
counter timer to measure either the first zero crossing or average the time
of flight on multiple zero crossings. This document is an interesting read
with oscilloscope waveforms:
http://www.pcserviceselectronics.co.uk/arduino/Ultrasonic/electronics.php

I have been wondering if you could send the signal in each direction to
eliminate the temperature variation of the speed of sound in air?

Let us know how you get on.

Cheers

Richard

On Sun, Jul 5, 2020 at 6:32 PM Charles Manning <cdhmanning at gmail.com> wrote:

> Hi Robin
>
> An FFT is probably not the best way to go as, generally, that is going to
> be maths heavy.
>
> 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.
>
> I assume you're using a single tone rather than mised audio. Keeping it to
> a single tone will make life much easier.
>
> 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.
>
> 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.
>
>
>
>
>
> On Sun, Jul 5, 2020 at 6:17 PM Mark Atherton <markaren1 at xtra.co.nz> wrote:
>
>> http://www.dspguide.com/ch7.htm specifically convolution
>>
>> http://www.dspguide.com/ch7/3.htm has some basic drawings
>>
>> The latter may have a pictorial example of what you are trying to do
>>
>> DSPguide is a brilliant book.
>>
>> HTH
>>
>> -Mark
>>
>>
>>
>>
>> On 5/07/2020 5:27 PM, Robin Gilks wrote:
>>
>> > Me again!
>> >
>> > I'm still getting nowhere with my project that will use ultrasonic
>> > transducers to measure wind speed.
>> >
>> > I understand that I need to run a cross correlation between the original
>> > transmitted signal and the delayed received one in order to work out the
>> > delay and hence (with a fixed distance between transducers) the speed of
>> > the wind.
>> >
>> > Trouble is, when I try to find basic information I end up in a cloud of
>> > matlab and scipy mazes that don't help me at all. I just don't seem to
>> be
>> > able to make the leap from basic idea to usable code on an embedded
>> > system. It really doesn't help me to read that I need to an FFT when I
>> > wouldn't know an FFT from a dead elephant!
>> >
>> > A typical example of what I find is thus (from
>> > https://www.dsprelated.com/showarticle/26.php):
>> >
>> > "A well-known solution to estimate delay is to calculate the
>> > cross-correlation between the two signals. An efficient implementation
>> > calculates |ifft(fft(a) .* fft(b)|, using FFT for cyclic convolution.
>> > A peak in the result indicates the integer-sample delay with best
>> alignment."
>> >
>> > warblefarblegarble :(
>> >
>> > Thought a couple of times that I'd found a code snippet that delivered
>> the
>> > goods but on trying them out they don't actually work. e.g.
>> > https://bitbucket.org/GreyCat/calc-sound-delay/src/default/
>> > I feed in 2 audio files, one of which I have trimmed a 150ms from the
>> > front of with Audacity and it tells me the delay is 3-4 times what I'd
>> > actually created.
>> >
>> > Confused...
>> >
>>
>>
>> _______________________________________________
>> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
>> https://lists.ourshack.com/mailman/listinfo/chchrobotics
>> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
>> Meetings usually 3rd Monday each month. See http://kiwibots.org for
>> venue, directions and dates.
>> When replying, please edit your Subject line to reflect new subjects.
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20200706/ec6ba87d/attachment.html>


More information about the Chchrobotics mailing list