{ "metadata": { "name": "", "signature": "sha256:fcf97378ee75a10174bf437d4163bd02cb667b6f8d52b7f2580f8bdf5df69fa5" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE 123 Lab1 - Real Time Sonar App\n", "\n", "### Written by Miki Lustig and Frank Ong 2015" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Import functions and libraries\n", "from __future__ import division\n", "import numpy as np\n", "from scipy import signal\n", "from numpy import *\n", "\n", "from rtsonar import rtsonar" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Task III: Play with different parameters with the real-time sonar!\n", "\n", "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()`!\n", "\n", "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. \n", "\n", "* 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. \n", "* Submit 4 interesting set of parameters. Explain why you chose them. \n", "\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Copy and paste your 5 functions here:\n", "# genPulseTrain()\n", "# genChirpPulse()\n", "# crossCorr()\n", "# findDelay()\n", "# dist2time()\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# Run this for Real-time Sonar\n", "fs = 44100 # Sampling frequency\n", "f0 = 10000 # Chirp initial frequency\n", "f1 = 18000 # Chirp ending frequency\n", "\n", "Npulse = 460 # Length of Chirp Pulse\n", "Nrep = 40 # Number of repitition in a pulse train (determines vertical length of plot )\n", "Nseg = 4096 # Number of samples between pulses (determines maximum time-of-arrival)\n", "Nplot = 300 # Number of pixels in plot along horizontal direction (higher resolution is slower)\n", "maxdist = 300 # Maximum distance in cm\n", "temperature = 20 # Temperature \n", "\n", "functions = (genChirpPulse, genPulseTrain, crossCorr, findDelay, dist2time) #join the functions together\n", "\n", "stop_flag = rtsonar( f0, f1, fs, Npulse, Nseg, Nrep, Nplot, maxdist, temperature, functions )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# Run this to stop the sonar\n", "stop_flag.set()" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }