File Exchange Pick of the Week

Our best user submissions

Accessing low-cost software defined radio 2

Posted by Guest Picker,

Idin's pick this week is Communications Toolbox Support Package for RTL-SDR Radio by MathWorks Communications Toolbox Team.

There has been a proliferation in the availability and usage of low-cost hardware platforms such as Raspberry Pi, BeagleBoard, and USRP boards. These boards can be used for quickly realizing ideas in the physical world, as well as great educational tools. MathWorks has invested heavily over the last few years to work with as many of these platforms as possible, which makes my life as a MathWorks application engineer much more exciting (see list of supported hardware here).

The USB-based software-defined radio (SDR) card from NooElec selling for under $20 is a nifty piece of hardware for any wireless communications enthusiast. There are a few different versions of this radio, but I will focus on the one pictured below (officially: NooElec NESDR Mini SDR and DVB-T USB Stick (R820T)).

What makes this radio more accessible is the MATLAB support package, which allows off-the-air signals to be captured directly into MATLAB and/or Simulink. This means you can make simple receivers to demodulate/decode signals that are present around us.

What can you do with this radio?

The radio front-end on this card supports frequencies from 25MHz to 1.7GHz, which means you can receive FM radio, some navigation signals, and most GSM and LTE bands in use in the United States. The bandwidth is limited to about 3MHz, so you can easily cover FM radio or GSM, but you can't do a full LTE receiver (most LTE deployments go up to 10MHz). But even on LTE, you can still capture and decode the LTE broadcast information (MIB), which is transmitted within the middle 1.4MHz of the band (the middle 72 OFDM subcarriers). If you have access to LTE Toolbox, this should be a relatively simple exercise.

What's already there?

When you download the MathWorks support package, you will get a few example models including an FM receiver (for both MATLAB and Simulink), a spectral analysis app, and an FRS/GMRS walkie-talkie receiver. So you can listen to your favorite FM radio stations, or receive signals from an off-the-shelf walkie-talkie.

How does it work?

My favorite piece about this support package is its simplicity. With the support package, you simply get a "receiver block" in Simulink, and a corresponding System object in MATLAB. In Simulink, a simple spectrum analyzer looks like this:

where you set three parameters for the radio (as shown below): its center frequency, sampling rate, and tuner gain.

The MATLAB interface is just as straight forward.

% Create receiver System object
receiver = comm.SDRRTLReceiver(...
    'CenterFrequency',102.5e6, ...
    'EnableTunerAGC',true, ...
    'SampleRate',1e6, ...
    'SamplesPerFrame',256*20, ...
    'OutputDataType','double');
% View spectrum; assuming "analyzer" is already initialized
for count = 1:5000
    data = step(receiver); % no 'len' output needed for blocking operation
    data = data-mean(data);   % remove DC component
    step(analyzer,data);
end

For the curious, the spectrum analyzer object, analyzer, can be initialized as follows:

analyzer = dsp.SpectrumAnalyzer(...
    'SpectrumType','Power density',...
    'SampleRate',1e6, ...
    'SpectralAverages',50);

So What?

I would argue that every electrical engineering student taking a digital communications course must own one of these devices. Even for the non-student, and the generally curious person, this will be the best $20 you will spend this year. And the MATLAB support package for the radio makes this one of the cheapest and easiest learning tools for wireless communications.

Comments

Let us know what you think here or leave a comment for MathWorks Communications Toolbox Team.


Get the MATLAB code

Published with MATLAB® R2014a

9 views (last 30 days)  | |

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.