Main Content

Capture from Frequency Band with Multiple Antennas

This example shows how to configure a software-defined radio (SDR) as a baseband receiver to capture data from a specified frequency band using multiple antennas. The example also plots the frequency spectrum of the captured data.

Introduction

This example shows how to use the basebandReceiver object to capture a wide frequency band by using two radio antennas with different center frequencies. Because each antenna captures at least half of the frequency band, you can capture a wider frequency band than using a single antenna. To view the whole frequency band, the example upsamples and shifts 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.

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 470–694 MHz frequency band, typically allocated to TV broadcasting channels 21–48.

frequencyBand.Start = 470000000;
frequencyBand.End = 694000000;
frequencyBand.Width = frequencyBand.End - frequencyBand.Start;
frequencyBand.CenterFrequency = frequencyBand.Start + frequencyBand.Width/2;

Configure Baseband Receiver

Create a baseband receiver object with the specified radio. Because the object requires exclusive access to radio hardware resources, clear any object associated with the specified radio.

clear bbrx
bbrx = basebandReceiver(radio);

To capture the full width of the frequency band with two antennas:

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

  • Set the CenterFrequency property to the values that correspond to the middle of each half of the frequency band.

  • Set the Antennas property to values that correspond to two antennas that can use different center frequencies on the SDR.

To use the maximum sample rate available for your radio, call the hMaxSampleRate helper function. Alternatively, you can set a custom sample rate.

maxSampleRate = hMaxSampleRate(radio);
bbrx.SampleRate =  maxSampleRate;
bbrx.CenterFrequency = [frequencyBand.CenterFrequency - frequencyBand.Width/4,...
    frequencyBand.CenterFrequency + frequencyBand.Width/4];

To update the dropdown menu with antennas that can use different center frequencies, call the hIndependentFrequencyCaptureAntennas helper function. Then select the antennas to use with this example.

[firstAntennaSelection, secondAntennaSelection] = hIndependentFrequencyCaptureAntennas(radio);
bbrx.Antennas = [firstAntennaSelection(1),secondAntennaSelection(1)];

Set the RadioGain property according to the local signal strength.

bbrx.RadioGain = 10;

Beacuse the resampling operation (after capture) requires double precision input data, configure the baseband receiver to return the captured data in double precision.

bbrx.CaptureDataType = "double";

Capture IQ Data

To capture IQ data from the two halves of 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);

Resample and Shift Captured Data

Resample the captured data to the full bandwidth of the frequency band.

resampledData = resample(data,length(bbrx.Antennas),1);

Shift the upsampled data from each antenna to the matching half of the frequency band by using the center frequency difference between the corresponding antenna and the frequency band.

shiftedData = zeros(size(resampledData));
for antenna = 1 : length(bbrx.Antennas)
    frequencyOffsetGen = dsp.SineWave(...
        Frequency=bbrx.CenterFrequency(antenna) - frequencyBand.CenterFrequency,...
        SampleRate=bbrx.SampleRate * length(bbrx.Antennas),...
        SamplesPerFrame=length(resampledData),...
        ComplexOutput=true);
    shiftedData(:,antenna) = resampledData(:,antenna).*frequencyOffsetGen();
end

Plot Spectrum of Frequency Band

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 resampled rate of the captured data. Plot the spectrum of the resampled data.

if ~exist("spectrumScope","var")
    spectrumScope = spectrumAnalyzer;
end
spectrumScope.SampleRate = bbrx.SampleRate*length(bbrx.Antennas);
spectrumScope.ChannelNames = bbrx.Antennas;
spectrumScope.FrequencyOffset = [frequencyBand.CenterFrequency,frequencyBand.CenterFrequency];
spectrumScope.SpectrumUnits = "dBFS";
spectrumScope.FullScaleSource = "Property";
spectrumScope.FullScale = 1;
spectrumScope(shiftedData);
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