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.