Main Content

Capture from Frequency Band

This example shows how to configure a software-defined radio (SDR) as a baseband receiver to capture data from a specified frequency band. The example also 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.

savedRadioConfigurations = radioConfigurations;

To update the dropdown menu with your saved radio setup configuration names, click Update. Then select the radio to use with this example.

savedRadioConfigurationNames = [string({savedRadioConfigurations.Name})];
radio = savedRadioConfigurationNames(1) ;

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 basebandReceiver object with the specified radio. Because the object requires exclusive access to radio hardware resources, before running this example for the first time, clear any other object associated with the specified radio. In subsequent runs, to speed up the execution time of the example, reuse your new workspace object.

if ~exist("bbrx","var")
    bbrx = basebandReceiver(radio);
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 = 30;

To update the dropdown menu with the antennas available for your radio, call the hCaptureAntennas helper function. Then select the antenna to use with this example.

antennaSelection = hCaptureAntennas(radio);
bbrx.Antennas = antennaSelection(1);

Capture IQ Data

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

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

Plot Spectrum of Captured Data

Create a spectrumAnalyzer object. To speed up the execution time of this example upon subsequent runs, reuse the spectrum analyzer 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.

if ~exist("spectrumScope","var")
    spectrumScope = spectrumAnalyzer;
end
spectrumScope.SampleRate = bbrx.SampleRate;
spectrumScope.ChannelNames = bbrx.Antennas;
spectrumScope.FrequencyOffset = bbrx.CenterFrequency;
spectrumScope.ViewType = "Spectrum and spectrogram";
spectrumScope.TimeSpanSource = "Property";
spectrumScope.TimeSpan = seconds(captureLength);
spectrumScope.SpectrumUnits = "dBFS";
spectrumScope.FullScaleSource = "Property";
spectrumScope.FullScale = double(intmax('int16'));
spectrumScope(data);
spectrumScope.show;
release(spectrumScope);

To call the capture function again and to update the spectrum analyzer by rerunning the current section, click Capture and plot frequency spectrum.

 

See Also

Functions

Objects

Related Topics