chirp

EE123: Digital Signal Processing

chirp

Spring, 2017

Driver Installation Instructions

All the installation instructions below were derived from the following links:

Here, we will provide you with binaries and basic installation that will enable you to get tune to a frequency and get samples to a file or in python. If you are bold, you can go to the aove websites and follow the installation instructions. There are instructions there to install additional software, such as GNU-radio, SDR

There are three tools you must be able to run:

  • rtl_test: this will test the device and its function.

  • rtl_sdr: enables saving raw samples into a file

  • rtl_tcp: networked interface that enables loading data, changing frequency, gain etc.

MAC OSX:

Option I: Macports

  • Intall Macports (Link), if you don't have it already. You will need to have Xcode and Xcode commandline tools installed too.

  • Install rtl-sdr drivers:

>> sudo port install rtl-sdr

Option II: Our pre-compiled binaries

  • Download and extract the archive rtlsdr_osx.zip

  • If they do not exist, in the terminal, create the following directories. (You will need administrator password)

>> sudo mkdir /usr/local/bin
>> sudo mkdir /usr/local/lib
  • In the terminal go to the directory path of the archive you downloaded and copy the files to the right place:

>> sudo cp rtl* /usr/local/bin/
>> sudo cp lib* /usr/local/lib/

Testing RTL-SDR

  • Connect your USB dongle to your computer and run the rtl_test. You should get the following output:

>> rtl_test
Found 1 device(s):
  0:  Generic RTL2832U

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Windows

  • Download and extract the archive rtlsdr_win.zip

  • You should see the file zadig.exe, zadig_xp.exe and two directories: x32 and x64. these correpond to 32bit and 64bit rtl_sdr binaries.

  • To link the rtl-sdr library to Python, the rtl_sdr binaries have to be available in the system path. One way to do this is to copy all files under rtlsdr_win.zip\x32 or rtlsdr_win.zip\x64 to C:\Anaconda (or whatever location you chose to install Anaconda)

  • Plug your RTL device in for the first time, Windows may request a driver or automatically install a driver from Microsoft - this is OK as it will be replaced in the next few steps. Don't install the software on the CD that comes with the device.

  • Run the Zadig.exe file (Zadig_xp.exe if you are using Windows XP) and you should see the following with an empty list:

  • Click on Options and select “List All Devices”:

  • Choose the one that says “Bulk-In, Interface (Interface 0)”. This should be the primary endpoint of your RTL device:

  • In the box to the right of the green arrow make sure “WinUSB” is chosen - not libusb or libusbk. The big button underneath will say “Replace Driver” or “Reinstall Driver”. Before you proceed make sure the USBID matches the VID/PID.

  • Note that if you insert the dongle into a different USB port you may have to use Zadig again. It seems that you can change which driver is loaded depending on the USB port used. So you could use one USB port for RTLSDR and another port for using the dongle to watch DVB-T with the supplied Windows application.

  • In a command line window, run the test:

>> rtl_test.exe
Found 1 device(s):
  0:  ezcap USB 2.0 DVB-T/DAB/FM dongle

Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
Found Elonics E4000 tuner
Supported gain values (18): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 43.0 45.0 47.0 49.0
Benchmarking E4000 PLL...
[E4K] PLL not locked for 51000000 Hz!
[E4K] PLL not locked for 2227000000 Hz!
[E4K] PLL not locked for 1114000000 Hz!
[E4K] PLL not locked for 1241000000 Hz!
E4K range: 52 to 2226 MHz
E4K L-band gap: 1114 to 1241 MHz

Linux

  • Marcus D. Leech has kindly integrated the forementioned build steps into his gnuradio installation script at rtlsdr/build-gnuradio. This is the most user-friendly option so far. It will install the entire gnu-radio suit, which is lots of fun!

  • Otherwise, follow the instructions on http://sdr.osmocom.org/trac/wiki/rtl-sdr to compile and install binaries from source.

  • After installation, in a command line window, run the test:

>> rtl_test
Found 1 device(s):
  0:  ezcap USB 2.0 DVB-T/DAB/FM dongle

Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
Found Elonics E4000 tuner
Supported gain values (18): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 43.0 45.0 47.0 49.0
Benchmarking E4000 PLL...
[E4K] PLL not locked for 51000000 Hz!
[E4K] PLL not locked for 2227000000 Hz!
[E4K] PLL not locked for 1114000000 Hz!
[E4K] PLL not locked for 1241000000 Hz!
E4K range: 52 to 2226 MHz
E4K L-band gap: 1114 to 1241 MHz

Getting data into Matlab

This year, we will be using python instead of Matlab, but I've left instructions just in case. There are a couple of ways to capture data and transfer it into Matlab. The most simple way is using the rtl_sdr executable to capture data and save it into a file. Then, reading the data from a file into Matlab. The other way is using rtl_tcp which enables communication with the device over TCP connection. I've written several matlab functions that can be used to interact with the device directly from Matlab. Unfortunately these do not work in GNU octave as they use Matlab built-in java interpreter. I will release GNU octave code soon.

  • Download and extract the archive rtlsdr/rtlsdr_matlab.zip. It contains all the code to work with the device from Matlab.

Using rtl_sdr to capture to a file

Example: to tune to 88.5Mhz and set the sample rate to 2.4Mhz use:

>> rtl_sdr  -s 2400000 -f 88500000  capture.bin

Use crtl-c to break the capture. Warning… the file will grow very quickly!

To load into Matlab/Octave use the provided function loadFile.m in the Matlab commandline

>> y = loadFile('capture.bin');

You will see that the samples are complex!
This is because the device uses IQ baseband demodulation and sampling to represent a single side of the spectrum. Here are some Notes and Slides about Quadrature demodulation and sampling.

Because of the automatic gain, in many cases the first couple of seconds of capture will not be useful. You should therefore discard them. An alternative is to use manual gain, but you have to be careful not to overrange when the signal is strong. The Supported gain values (18): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 43.0 45.0 47.0 49.0.

Example: to tune to 88.5Mhz and set the sample rate to 2.4Mhz and maximum gain use:

>> rtl_sdr -s 2400000 -f 88500000 -g 49.0  capture.bin

I hope you enjoy this device!

please let me know if there are any problems.

-- Miki