Thursday, December 11, 2014

Sonar sounder

Computer sound cards can record at 44.1 kHz, and the CPU can process this data in real time.  With a little thought, this can be pressed into service to make a simple sonar setup.  I wrote a small Python program that uses NumPy, GStreamer, and GTK to make a real-time sonar display.  With a microphone and reasonable speakers, you can sense moving targets pretty easily.  I used cheap, 10 W speakers, and made a low-ultrasound sonar waveform that works well enough.

This picture below shows the setup.  The two white speakers emit the waveform.  The microphone is a small electret wired microphone and is sitting on the laptop keyboard.  The big wooden disk is a target.



The program plays a pre-recorded waveform on the speakers while simultaneously recording audio from the microphone.  In essence, the program implements two GStreamer pipelines.  A transmit pipeline

gst-launch filesrc location=<whatever.wav> ! wavparse ! pulsesink

which gets restarted every time it finishes, and a receive pipeline

gst-launch pulsesrc ! fakesink

from which the recorded data are snatched from the fakesink using signal handoffs right before the data are deleted.  Once the data are recorded, they're sliced into equal pulses (the pulse durations are known beforehand) and aligned so that the peaks are all at the start of the recorded pulses.  Consecutive blocks of pulses are averaged sample-by-sample to reduce noise without impacting resolution.  The result looks like the following screenshot, in which the target's echo appears between 77 cm and 166 cm.



Next steps for this project:
1. Apply a constant false alarm rate (CFAR) detector to the data with a user-defined trigger and window. 
2. Locate targets using the centroid of CFAR detection blobs. From that,
3. Estimate target velocity.
4. (Farther out.)  Switch to a dual pulse repetition frequency (PRF) waveform to improve velocity and range resolution simultaneously.

No comments:

Post a Comment