{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE 123 Lab1 - Real Time Sonar App\n", "\n", "### Written by Miki Lustig and Frank Ong 2016" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Import functions and libraries\n", "import numpy as np\n", "from scipy import signal\n", "from numpy import *\n", "import matplotlib.pyplot as plt\n", "from rtsonar import rtsonar" ] }, { "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", "* To get the best real-time performance, you should restart the kernel every time you run this lab. \n", "* Submit 4 interesting set of parameters. Explain why you chose them. \n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Copy and paste your 5 functions here:\n", "# genPulseTrain()\n", "\n", " \n", "# genChirpPulse()\n", "\n", " \n", "# crossCorr()\n", "\n", "\n", "# findDelay()\n", "\n", "\n", "# dist2time()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "# Run this for Real-time Sonar\n", "# Change the parameters!\n", "# Your functions will need to be efficient for this to work. \n", "# If you get nothing try thinking about how to speed up your code.\n", "fs = 48000 # Sampling frequency\n", "f0 = 10000 # Chirp initial frequency\n", "f1 = 15000 # Chirp ending frequency\n", "\n", "Npulse = 500 # Length of Chirp Pulse\n", "Nrep = 24 # Number of repetition in a pulse train (determines vertical length of plot )\n", "Nseg = 2048*2 # Number of samples between pulses (determines maximum time-of-arrival)\n", "Nplot = 200 # Number of pixels in plot along horizontal direction (higher resolution is slower)\n", "maxdist = 200 # 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 )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run this to stop the sonar (it will take a few seconds to stop)\n", "stop_flag.set()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.3" } }, "nbformat": 4, "nbformat_minor": 1 }