EE 123 Lab1 - Real Time Sonar App

Written by Miki Lustig and Frank Ong 2015

In []:
# Import functions and libraries
from __future__ import division
import numpy as np
from scipy import signal
from numpy import *

from rtsonar import rtsonar

Task III: Play with different parameters with the real-time sonar!

The function rtsonar() in rtsonar.py provides a wrapper to create a real-time sonar plot using user-defined processing functions. Copy and paste your functions genPulseTrain(), genChirpPulse(), crossCorr(), findDelay(), and dist2time() to the code cell below. Scroll down to the bottom and you should be able to run rtsonar()!

The detection resolution and sensitivity will depend on the parameters you will choose for the sonar. The longer the pulse is, the worse time resolution you will get, but much stronger matched filtering amplitude. You can buy the time resolution by using pulse compression with chirp pulses at the expense of increasing the bandwidth.

  • Run the sonar with different parameters. You can get interesting targets by moving your laptop, moving yourself next to the computer, using a book as a reflecting surface. It would be easier for you to distinguish the target if you move it back and forth. Play with the pulse lengths, the frequency sweeps, etc.
  • Submit 4 interesting set of parameters. Explain why you chose them.
In []:
# Copy and paste your 5 functions here:
# genPulseTrain()
# genChirpPulse()
# crossCorr()
# findDelay()
# dist2time()
In []:
# Run this for Real-time Sonar
fs = 44100 # Sampling frequency
f0 = 10000 # Chirp initial frequency
f1 = 18000 # Chirp ending frequency

Npulse = 460 # Length of Chirp Pulse
Nrep = 40 # Number of repitition in a pulse train (determines vertical length of plot )
Nseg = 4096 # Number of samples between pulses (determines maximum time-of-arrival)
Nplot = 300 # Number of pixels in plot along horizontal direction (higher resolution is slower)
maxdist = 300 # Maximum distance in cm
temperature = 20 # Temperature     

functions = (genChirpPulse, genPulseTrain, crossCorr, findDelay, dist2time) #join the functions together

stop_flag = rtsonar( f0, f1, fs, Npulse, Nseg, Nrep, Nplot, maxdist, temperature, functions )
In []:
# Run this to stop the sonar
stop_flag.set()