Detecting 20kHz ultrasonic pulses

Hello everyone,

For an experimental indoor positioning system, I'm trying to detect short 20kHz sound-pulses generated using an arduino and a piezo disk.

It turns out that it's relatively easy to make the spikes visible using a cheap electret microphone and laptop with the help of audacitys equalizer over a distance of 3m and more.
That required amplyfing the signal by ~55dB and applying an bandpass with several 100dB/octave :confused:

Now I'm looking for a way to detect said pulses using an arduino. My experience with analog circuits is pretty limited, so I would appreciate any advice on how to amplify, filter and read the signal from the electret microphone.

edit: I forgot to mention that using a frequency of exactly 20kHz is not a requirement, that's just the highest freq my usb-soundcard can record, and I know, that an electrec mic can deal with it.
It's important to be inaudible, though, so 20kHz or higher.

lg, couka

The arduino can only sample at ~10kHz, so you can't do this directly. And I suspect you'll need a fair bit of analogue gain to get a reasonable signal level - at least 40, perhaps 60dB. Given the gain-bandwidth limits of cheap amplifiers I suspect you'll need 2 stages.

You could then heterodyne the signal down to a much lower frequency and sample there, or use a hardware filter/rectifier/peak detector.

Do you know the frequency accurately? Or is this for something like a bat detector?

It may be worth looking at eg HC-05 ultrasound shields - they're cheap, and have a reasonable range, and do all the hard analog stuff for you.

depends what you're trying to do.....

regards

Allan.

The inexpensive HC-SRO4 ultrasonic rangefinders simply have a lot of gain following the sensor and then a comparator that detects signal sound level above a predetermined level. The output of the threshold detector goes to an edge triggered interrupt pin on the HC-SR04's microcontroller.

In the linked thread, I posted some observations on using hacked HC-SR04 for communications that might be of interest: Using HCSR 04 for communication - Project Guidance - Arduino Forum

Interestingly, the original version of HC-SR04 receiver is tuned for about 18 kHz.

Whether this is a design flaw or bad choice of components is not clear, but hacking one as suggested by MrMark should work well for 20 kHz.

allanhurst:
The arduino can only sample at ~10kHz, so you can't do this directly.

Its possible, but at the expense of driving the ADC faster than recommended for nominal performance,
ie the signal quality degrades. And you have the problem of lacking enough processing power to handle
the samples.

Maybe repurposing an ultrasound distance sensor (the sort with separate TX and RX transducers) could
be viable?

use a magnetic micro phone or use a small speaker as micro phone; Just google "using small speaker as microphone schematic".

What about the LM567?

MarkT:
Its possible, but at the expense of driving the ADC faster than recommended for nominal performance,
ie the signal quality degrades. And you have the problem of lacking enough processing power to handle
the samples.

When I was playing with FSK modulation on hacked HC-SR04s, I just used digitalRead on a saturated receive signal, so effectively a one bit ADC. Processing continuously measured the pulse intervals and mapped that to one of N expected frequency bins.

I think my receive processing worked well enough, but the piezo receive sensor wanted to output at it's resonant frequency unless driven very hard (i.e very close to the transmitter). An electret microphone shouldn't have this problem, but it's going to be more sensitive to other environmental noise.

If one really wants to do higher resolution digital signal processing on ultrasonic signals, maybe a a Teensy or STM32 with a faster A/D and more processing horsepower would be a more appropriate platform.

Riva:
What about the LM567?

One concern is that to do ranging indoors, one can only use short bursts before echos become a problem. The HC-SR04 uses only 8 full cycles of 40 kHz. Without looking I'm not sure how well the LM567 detects very short bursts.

Sorry for repliying so late, I catched a cold.
Maybe I should explain better what I want to do.
My idea was to have 3 transmitters in a room that send ultrasound signal with a time difference of say 100ms. A mobile receiver (could be a toy car, for example) detects those signals and calculates its distance to each transmitter based on time of flight and based on that, its position.

allanhurst:
I suspect you'll need a fair bit of analogue gain to get a reasonable signal level - at least 40, perhaps 60dB. Given the gain-bandwidth limits of cheap amplifiers I suspect you'll need 2 stages.

Yes, is that reasonable? I never build an amplifier above some 100x amplification.

allanhurst:
You could then heterodyne the signal down to a much lower frequency and sample there, or use a hardware filter/rectifier/peak detector.

The mic will pick up other sounds that a present in a room e.g. people speaking etc. and those signals are probably way louder than the Ultrasound pulse. That's why I thought I would need some kind of narrow bandpass filter to get rid of that first.

allanhurst:
Do you know the frequency accurately? Or is this for something like a bat detector?

Yes, I generate it. I want to build an indoor positioning system.

allanhurst:
It may be worth looking at eg HC-05 ultrasound shields - they're cheap, and have a reasonable range, and do all the hard analog stuff for you.

I have tried using the cheap HC-SR04, but they have a limited measurement angle of around 15°. As far as I can see, that's useless unless I roughly know in which direction the transmitter is, relatively to the receiver (Which I don't)

MrMark:
In the linked thread, I posted some observations on using hacked HC-SR04 for communications that might be of interest: Using HCSR 04 for communication - Project Guidance - Arduino Forum

Thank you, modifying an HC-SR04 is something I didn't think about yet. I'll dig into that for a while :slight_smile:

MarkT:
Maybe repurposing an ultrasound distance sensor (the sort with separate TX and RX transducers) could
be viable?

I couldn't find any cheap ones (<5$) yet, especially none that solve the problem with the limited angle and still have enough range (say 4m).

kesirajus:
use a magnetic micro phone or use a small speaker as micro phone;

I don't understand how that solves the problem of processing the signal.

Riva:
What about the LM567?

I'll take a look into that, thank you.

lg, couka

A mobile receiver (could be a toy car, for example) detects those signals and calculates its distance to each transmitter based on time of flight

You will have a serious problem with reflections from walls or other objects.

You might be interested in Pozyx, an indoor localization system that uses a combination of radio, sound and IMUs. Expensive, though!

MrMark:
If one really wants to do higher resolution digital signal processing on ultrasonic signals, maybe a a Teensy or STM32 with a faster A/D and more processing horsepower would be a more appropriate platform.

I have read about working 2D (!) ultrasound opponent finder in robotic competition implemented on ATMega. He was sampling at 320 kHz and programming in Assembler but he had good results. I guess 1D ultrasound should be easily implemented in Arduino because it is much less work for the MCU and ADC.

jremington:
You will have a serious problem with reflections from walls or other objects.

You might be interested in Pozyx...

How so? The first time a signal is detected should be the one of interest and with 100ms delay, there shouldn't be much echo left, I hope :confused:

I know about pozyx, but yah, too expensive really.

lg, couka

The problem with reflections is that they invalidate the line-of-sight assumption that you are making.

Look up "trilateration" or "multilateration" for discussions of the issues.

Great learning project, though!

jremington:
The problem with reflections is that they invalidate the line-of-sight assumption that you are making.

Maybe I'm missing something, but I understand the concept to be that there is always a line of sight path and leading edge detection will see the signal following that path first and ignore anything else for a period sufficiently long for the indirect signals to fade. This much I think this is workable.

There are challenges in time synchronizing the transmitters and the receiver such that time of transit can be calculated. One approach would be to modulate time of transmission on the transmitted signal and decoding that gets hard with the inevitable multipath.

I understand the concept to be that there is always a line of sight path

The line-of-sight assumption would be extremely unwise in the case of a robot attempting to navigate the floor of a room containing even one item of soft furniture. See reply #9 for the scenario.

As I said, a great learning project!