Fall, 2012RTL-SDR: Inexpensive Software Defined Radio
What is software-defined radio? This is a photo of the dongle:
The device uses IQ baseband demodulation and sampling. Here are some Notes and Slides. Driver Installation InstructionsAll 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 into Matlab or GNU Octave. 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 or SDR There are three tools you must be able to run:
MAC OSX:
>> sudo mkdir /usr/local/bin >> sudo mkdir /usr/local/lib
>> sudo cp rtl_sdr rtl_tcp rtl_test /usr/local/bin/ >> sudo cp lib* /usr/local/lib/
>> rtl_test -t rtl_test -t 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 Windows
>> rtl_test.exe -t 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
>> rtl_test -t 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 and GNU OctaveThere 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.
Using rtl_sdr to capture to a fileExample: 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! 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 Using rtl_tcp to capture and control the device directly from Matlabrtl_tcp comes with command line options which can be used to start the capture with specific frequency and rate. This is useful to save time
but it is also possible to start rtl_tcp without and options, in which case it will start with default parameters. From Matlab it is possible to
change these. Example: to start a tcp erver with default parameters of tuning to 88.5Mhz and sample rate of 2.4Mhz >> rtl_tcp -s 2400000 -f 88500000 Found 1 device(s). Found Elonics E4000 tuner Using ezcap USB 2.0 DVB-T/DAB/FM dongle Tuned to 88500000 Hz. listening... Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...). To capture samples, in the Matlab command window run: >> soc = rtl_sdr_connect; % open local tcp socket to rtl_tcp >> dummy = rtl_sdr_getData(soc,2.4e6); % get 1 second worth of samples, and throw away >> y = rtl_sdr_getData(soc,2.4e6); % get 1 second worth of samples >> soc.close; % close socket Immediately after invoking rtl_sdr_connect, the device will capture data and buffer it. To flush the buffer, you can either use
rtl_sdr_reset, or to read data till the buffer is flushed. To change frequency to 162.4Mhz and rate to 1Mhz and then capture data in Matlab use: >> soc = rtl_sdr_connect; % open local tcp socket to rtl_tcp >> rtl_sdr_setFreq(soc,162400000); >> rtl_sdr_setRate(soc,1000000); >> soc=rtl_sdr_reset(soc); >> y = rtl_sdr_getData(soc,1e6); % get 1 second worth of samples I hope you enjoy this device! please let me know if there are any problems. -- Miki |