Continuing the series Ultrasonic rangefinder project , More testing for ultrasonic rangefinder, Ultrasonic rangefinders arrived, and Ultrasonic rangefinder without amplifier, I tried today to look at creating pings with a non-resonant transmitter: a cheap, mid-range 8Ω loudspeaker that I’d used for the applied electronics class. It was a buyout special from Parts Express, and so is no longer available. There is an analysis of this speaker (or another one like it) in Better model for loudspeaker.
I was curious whether I’d be able to get it to produce sound at 40kHz, so I hooked it up to a pair of output pins of the Teensy 3.1 and used the microphone and preamplifier to listen to it with the Teensy, as in Ultrasonic rangefinders arrived. The results were disappointing (as I expected). The loudspeaker made an audible click, but the waveform showed no evidence of 40kHz signal, even with 10 cycles of excitation. I got echos, but they were of the click rather than of a ping, and were essentially independent of how many cycles of excitation I provided.
I then tested the loudspeaker and microphone combination with my FG085 function generator, and saw that the amplitude of the response varied enormously with frequency (and that some of the largest responses were ones I couldn’t hear—my deafness does not seem to be uniform in the higher frequencies). There are zeroes around 21750Hz and 28500Hz, and no signal above 31750Hz. The microphone and preamp were still working at 40kHz, so the problem is with the loudspeaker, not the mic or preamp.
I should probably get a cheap little speaker that is rated to 20kHz, and see whether it can actually go to 40kHz. Digikey has some $1 and $2 speakers that look suitable, except that they seem to be designed to be pressed against a PC board with a spring, which might make them hard to connect to a breadboard. For about $3, I could get one with pins, but the high-frequency response seems not as good.
I could also try making a pinger at 20kHz, instead of 40kHz, and see whether I can get decent pulse shapes with the existing speaker.
I managed to get a 20kHz ping recorded from the loudspeaker, but I had trouble getting a clean ping, as there was always echo off the floor, my hand, or the tabletop (whatever was supporting the loudspeaker) producing another burst very soon after the first one, interfering with it. I tried separating the mic and loudspeaker to record the direct wave (without much echo), but that was still unclean. I think I need to have a good baffle to make a clean pulse, and a directional mike would be better than the omnidirectional one I currently have.
Here is a sample recording with the loudspeaker putting out 5 cycles (10 half cycles) at 20kHz and a bounce off the bottom of my table. The messiness of the return echo is partly interference from bounces off the floor behind the mic and speaker, and partly the unevenness of the bottom surface of the table (which is made of aluminum slats).
I think that with non-resonant transducers I could get cleaner deconvolution of the echoes, but first I have to find a way to reduce the multi-path problem (perhaps with a directional mike and a baffled speaker?).