Main Content

Capture from Frequency Band

This example shows how to use a software-defined radio (SDR) to capture data from a specified frequency band. The example then plots the frequency spectrum of the captured data.

Set Up Radio

Call the radioConfigurations function. The function returns all available radio setup configurations that you saved using the Radio Setup wizard. For more information, see Connect and Set Up NI USRP Radios.

radios = radioConfigurations;

Specify the name of a saved radio setup configuration to use with this example.

radioName = radios(1).Name;

Specify Frequency Band

Specify the start and the end of the frequency band. By default, this example captures the 87.5-108 MHz frequency band, typically allocated to FM radio.

frequencyBand.Start = 87500000;
frequencyBand.End = 108000000;
frequencyBand.Width = frequencyBand.End-frequencyBand.Start;
frequencyBand.MidPoint = frequencyBand.Start + frequencyBand.Width/2;

Configure Baseband Receiver

Create a baseband receiver object with the specified radio. To speed up the execution time of this example upon subsequent runs, reuse the workspace object from the first run of the example.

if ~exist("bbrx","var")
    bbrx = basebandReceiver(radioName);
end

To capture the full width of the frequency band:

  • Set the SampleRate property to a value that is greater than or equal to the width of the frequency band.

  • Set the CenterFrequency property to the value that corresponds to the middle of the frequency band.

Set the RadioGain property according to the local signal strength.

bbrx.SampleRate = frequencyBand.Width;
bbrx.CenterFrequency = frequencyBand.MidPoint;
bbrx.RadioGain = 60;
bbrx.Antennas = "RF0:RX2";

Capture IQ Data

To capture IQ data from the the specified frequency band, call the capture function on the baseband receiver object. Specify the length of the capture.

captureLength = milliseconds(1000);
data = capture(bbrx,captureLength);

Plot Spectrum of Captured Data

Create a dsp.SpectrumAnalyzer object. Set the sample rate of the spectrum analyzer object to the sample rate of the baseband receiver object. Plot the spectrum and spectrogram of the captured data.

PlotPowerLimits = [-120, -60];
 

spectrumScope = dsp.SpectrumAnalyzer;
spectrumScope.SampleRate = bbrx.SampleRate;
spectrumScope.FrequencyOffset = bbrx.CenterFrequency;
spectrumScope.ViewType = "Spectrum and spectrogram";
spectrumScope.TimeSpanSource = "Property";
spectrumScope.TimeSpan = seconds(captureLength);
spectrumScope.YLimits = PlotPowerLimits;
spectrumScope.ColorLimits = PlotPowerLimits;
spectrumScope.SpectrumUnits = "dBFS";
spectrumScope.FullScaleSource = "Property";
spectrumScope.FullScale = double(intmax('int16'));
spectrumScope(data);
release(spectrumScope);

See Also

Functions

Objects

Related Topics