Together with my friend and colleague John Berezney, I decided to make a sonar system using a microphone and speaker. The idea is to make an active sonar system using PC speakers as output and a microphone as an input. I got some inspiration for this project from this website: http://eddiem.com/projects/chirp/chirp.htm
The first step is to make a chirp, which is just a type of pulse that changes frequency (see Figure). The audio speakers I have can only make pulses up to 20kHz (I think?), so I make chirps that vary between around 4kHz and 16kHz. I used Labview software to program the chirp and make it come out of my speakers.
The equation for this chirp, C(t) is a function of the pulse length T as well as the minimum and maximum frequencies in the chirp f_min and f_max. Typically I would choose a pulse length of T=2 milliseconds and f_min=4kHz and f_max=12kHz. The first part of the equation with the exponential is just an envelope function that prevents the frequency content from leaking into adjacent frequencies. The equation is:
Once we have a chirp coming out of the speakers, the next trick is to process the recorded audio that is coming in through the microphone. There are many ways to do this. I chose to use a matched filter. The idea is that whenever the microphone picks up a chirp that matches the one I sent, it makes a spike. This trick (matched filters) is used in radar all the time. The math for turning the microphone recording R(t) into a useful sonar signal S(t) using a matched filter is:
Note that we have to take the complex conjugate of the Fourier tranform of the chirp signal, multiply that by the Fourier transform of the Recording in frequency space, and then inverse Fourier transform to get a signal as a function of time. The signal S(t) has spikes wherever there is a reflection. Here you see S(t) which has a strong signal where the microphone picks up the direct wave, and a weaker signal for all the reflections.
The final step is to keep making chirps (my program could make around 4 per second) and then plot the intensity vs distance vs time (yes a 3D graph on a 2D plot!). To do this, I made an intensity graph, where height represents distance away in the reflection, and the time scrolls horizontally. I was holding a sound-reflecting clipboard, and walked away around 3 meters, and then returned to the computer. You can see that as a high intensity reflection going vertical on the graph (far away) and then closer.
John and I have some fun ideas for improving our sonar, I will keep the world updated as we make more improvements! I would be happy to hear if you guys have some fun ideas for improvements! I did all the signal processing and speaker output using Labview software. I am happy to give you the source code if you are interested.
Hi, This is very interesting. I have little experience with LabView (mostly Matlab till now and I am hoping to learn). Would it be possible to share the code? You can send at hsuri@ufl.edu. Thanks.
ReplyDeleteI'm very happy to see that someone is interested in this random project! I added a link to the files here: https://docs.google.com/folder/d/0B0twtL0ZJcByemZUczRqRWoxV1k/edit Please let me know if you have any problems getting it to work, and what you end up doing with it since I am curious. Cheers!
DeleteHi Bob, Thanks for the link but it does not appear to work. It is giving me access denied error, not sure if it is an artifact of my browser or some setting error. Please let me know. Thanks again.
DeleteOK I changed the settings, the link should work now! Let me know if you have any other issues with the code.
DeleteSuperbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. best pc microphone
Deleteapparently the file seems to be an image and i can't download or add to my drive
ReplyDeleteThe link in my previous comment goes to Labview .vi files. Does that answer your question?
ReplyDeleteI don't seem to be getting anything that matches your Intensity graph as I walk away and close to the mic.
ReplyDeleteCan I send you a screen shot of the intensity graph , maybe you can help me?
Thanks
please, do share your images, I will post them and try to help you debug
DeleteI have sent you a screen shot of the Intensity Graph in your 'HangOut' messages part in Gmail.
DeletePlease could you let me know what I may be doing wrong.
Thanks
I never heard from you... if you still want to debug, please post your screenshot somewhere that I can access it.
DeleteVery interesting, How do you keep the microphone from picking up the chirp directly from the speaker and just focus on the reflected sound?
ReplyDeleteThanks for you interest. To answer your question: I don't. The first peak is the direct wave, and it is much stronger than the reflected waves.
DeleteI Have it working properly, and I compiled the .exe but I don't have near the resolution you have on your intensity chart screenshot, having a hard time telling the waves apart. Any Ideas?
DeleteScreenshot
Deletewww.doverparanormal.96.lt/Untitled.jpg
Maybe it's just a question of adjusting the levels that are displayed. Maybe try using a logarithmic chart: "mapping: logarithmic". or when you right click on the legend, turn off "autoscale Z" and use a small range that will show the small reflections more clearly. Also, cranking up the volume on the speaker will give you the best chance of picking up a signal.
DeleteOne odd thing is that you have your samples/second set at 15,000, whereas your max frequency is 14,000. By the Nyquist criteria, you should either up your samples/Second above 28,000, or lower your max freq to below 7500.
Also, I never did this, but you could find the max peak (direct reflection) and line up your charts to that so that they have the same absolute distance. At the moment, the direct wave is not a perfectly horizontal line because of timing inconsistencies between the speaker out and microphone in. A few milliseconds makes all the difference.
Let me know how it goes!
The helped greatly, thanks. I am not sure if it is my microphone or if something else is at play, The only way I can receive a clear echo is if I use a large reflective panel. Maybe this is normal....I mean it is sound we are using. I did have a problem with what I think was reverb, I moved to a larger room and it helped.
DeleteGreat! I think it's normal that the signal are weak, for my data I was holding a reflective clipboard that was pointing at the microphone and the chirps were almost painfully loud!
DeleteYou could try experimenting with the chirp duration, and also your sampling rate. My intuition is that higher sampling rate is always better, and that chirp duration longer is better, but that when chirps get too long it will be difficult to distinguish two independent scatters. So if you use chirp of 10ms duration, the best resolution you get is 0.01ms*330m/s = 3.3m. Maybe that's OK! But I don't know for sure. Maybe longer chirps are OK... Maybe you could figure it out for us :)
Can you share your data? I'd be curious to see what you managed to get!
any luck with playing with the chirp length?
DeleteHas anyone thought about playing with an Aliens M314 scanner? I think the idea of a 2 mic, 2D sonar that also can detect and show doppler shift would also be a fun project to play with.
ReplyDeleteHi, can you tell me what was the intensity of the sound used in this project? Also have you figured out sound intensity treshold for decent results?
ReplyDeleteI don't know. With the low-quality microphone I was using, I had to crank up the speakers and used a clipboard as a reflector to be able to measure anything.
DeleteWould be interesting to convert this to a frequency-swept continuous-wave system. The reflected wave interferes with the sending wave (maybe requiring some hardware modifications?) and the phase difference tells you how far away an object is (simplified) - as if your sweep rate of the frequency & detected frequency tells you the time delay w/r/to the sweep rate of your output frequency. In theory I believe this gives higher SNR and Dynamic Range.
ReplyDeleteI wondered about this difference a lot on optical coherence tomography, which is an optical analogue to Sonar/Ultrasound.
— Demis
Let's explore that idea. In optics, the fundamental carrier wave (photons) is much too high-frequency to detect directly, and so interference techniques have to be used. In acoustics, the frequencies are within the range of ADC frequency (e.g. a microphone). So to make the system analogous, let's not get too crazy and introduce a 1 MHz resonator that can be modulated at acoustic frequencies or anything. Let's choose a "carrier wave" of like 10kHz that is also audible. Then, "frequency scanning" that carrier wave between 1-2000 Hz or something would enable this system to work. Or just simply adding some 1-2000Hz noise onto the 10kHz carrier wave. Either way, the pulses would sound like a high-frequency tone that lasts for a long time. One advantage of this right away is that you are probing acoustic reflectivity in a narrower range, which might improve fidelity of the signal. It would probably be important to have the right amount of bleed in of direct-wave into the microphone. So maybe being more careful about the acoustic isolation of speaker and direct wave into microphone could give a hardware-analog to the fiber-coupler tuning of direct and reflected with in OCT. Finally, performing the same type of Fourier analysis to get depth resolved intensity. Fundamentally, you'd be getting more signal if you use a longer pulse so I think this should work. You would lose a bit on "moving" targets since the fundamental assumption is that nothing's moving. But to start with, it would probably get much better results than what I was able to do. I imagine that it could be difficult to prevent the "direct wave" from swamping the reflected signal.
DeleteActually, what you are describing could be done simply by modifying the pulse to include a higher frequency carrier wave. Either way, I would be very curious to see the results if you do try this!
Another thing that could help would be electrically isolating the speaker and microphone. In addition to acoustic bleed-in, I suspect that there was electrical bleed-in from the speakers to microphone through my bad-quality sound card.
Deletenice project bob, keep update
ReplyDeleteThis is really interesting, I recently started working on a similar project. I am having troubles analyzing the signals without labview ... do you know softwares that could work the same ? I have not checked but I guess labview isn't opensource
ReplyDeletePaul
Thanks! Pretty much any software will do, I just chose Labview because it's pretty quick to make something work. You just need to find a way to get audio going out and audio streaming in. You could probably even make a smartphone app that you hook up to a speaker if you were so inclined.
DeleteAmazing. Do you think that this can work underwater? I'm thinking about creating a ROV with a sonar to be able to find underwater objects or fishes.
ReplyDeleteUnderwater sonar is definitely a thing! Usually they use higher frequencies of sound called "ultrasound."
DeleteHi Bob. I think it is very cool that you have been replying to posts so many years after writing the article. Great article by the way! I've been wondering if it is possible to create a microphone array using standard PC parts, but I think maybe the timing will not be precise enough?
DeleteHey im or her thinking of buying this microphone... looks pretty good and i produced good experience with hyperX. Can anyone answer me the actual question about keyboard sounds. I would place behind our keyboard... will the noise always be to loud and made my good friend in discord complain over it? hyperx quadcast amazon
ReplyDeleteM-Audio BX8D3 Speakers in UAE, Professional Multimedia Speakers in UAE, Speakers in UAE
ReplyDeletehttps://gccgamers.com/m-audio-bx8d3.html
M-Audio BX8D3 Speakers in UAE, Safe Shopping Multiple Payment Options Express Delivery GCC Gamers Moneyback Guarantee.
1633433905975-8