{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE123 Lab 2: Software Defined Radio\n", "\n", "### Written by Miki Lustig and Frank Ong" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before you start, you must make sure that the rtl-sdr drivers and its python support are installed. If you have not done so in the prelab, then follow the instructions on the class website: \n", "\n", "https://inst.eecs.berkeley.edu/~ee123/sp16/rtl_sdr_install.html\n", "\n", "In the first part of the lab, we will look at the power spectrum of the NOAA radio signal and introduce settings of the SDR along the way. In the second part of the lab, we will decode Mode-S ADS-B packets from the SDR, which allows us to track airplanes in realtime.\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## About the SDR\n", "\n", "The rtl-sdr usb dongles enables you to obtain samples from the electromagnetic spectrum around you. In very general terms, the dongle contains several components:\n", "\n", "1. The antenna couples to received electromagnetic fields and tiny currents are produced in it. \n", "2. A tuner IC circuit amplifies the signal, filters it, demodulates it to an intermediate frequency where it is filtered again. The dongles we distributed in class contain either the Refael Micro 820T (Black dongles) tuner or the Elonics E4000 (white dongles). \n", "3. All dongles are equipped with the realtek RTL2832U (hence rtl-sdr). Although the chip is capable of doing many things (like decoding TV in Europe), we use only its analog to digital converters and its USB interface. The RTL2832U samples the signal that is coming from the tuner and spits out samples to the computer through the USB interface. \n", "\n", "The SDR returns samples at a desired rate up to 2.4MS/s of a part of the spectrum around a desired center frequency. For example, setting a center frequency $f_0 = 88.5\\cdot 10^6$ and a sampling rate of $Fs=2\\cdot 10^6$ will result in a complex valued sequence $x[n]$ whos DTFT corresponds to the physical frequency range of $87.5\\cdot 10^6 < f < 89.5\\cdot 10^6$. In other words, the digital frequency $\\omega=0$ of $X(e^{j\\omega})$, the DTFT of $x[n]$, will correspond to the physical frequency $88.5$MHz. The digital frequency $\\omega=\\pi$ will correspond to $89.5$MHz and $\\omega=-\\pi$ will correspond to $87.5$MHz.\n", "\n", "Q) How come the sequence $x[n]$ is complex valued ??? \n", "\n", "A) Consider the case when there is a transmitter which outputs a pure frequency at 89MHz. We choose a center frequency of 88.5MHz and sampling rate of 2MHz. The spectrum of $x[n]$ will not be symmetric, and has to be complex valued! The received signal would be $x[n] = e^{i2\\pi500000/2000000n} = e^{i\\pi/2n}$ which will have a single frequency at $\\omega=\\pi/2$ --> corresponding to 89MHz. \n", "\n", "\n", "\n", "To learn about what you can do with SDR's, I recommend you watch this youtube video. Most (not all) the stuff shown there can be done using rtl-sdr. At minute 5:00 you will see an example of ADS-B, which you will partly implement in this lab." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "# A video on what you can do with Software defined radio. The B200 is a high-end SDR which is capable to much more than the rtl-sdr. \n", "# however, most of the stuff shown in the video could be done with the rtl-sdr as well. \n", "YouTubeVideo('cygDXeZaiOM')" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = \"1\";\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force !== \"\") {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force !== \"\") {\n", " window._bokeh_timeout = Date.now() + 5000;\n", " window._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"