Capture from Frequency Band with Multiple Antennas
This example shows how to use a software-defined radio (SDR) to capture data from a specified frequency band using multiple antennas. 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 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.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 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 independently tunable antennas on the SDR.
bbrx.SampleRate =122.88e6; bbrx.CenterFrequency = [frequencyBand.MidPoint-frequencyBand.Width/4,... frequencyBand.MidPoint+frequencyBand.Width/4]; bbrx.Antennas = [
"RF0:RX2",
"RF1:RX2"];
Set the RadioGain
property according to the local signal strength.
bbrx.RadioGain =60; bbrx.CaptureDataType = "double";
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(
100);
data = capture(bbrx,captureLength);
Resample then Shift Captured Data
Resample then shift the captured data channels by modulating with a carrier waveform.
resampledData = resample(data,length(bbrx.Antennas),1); for antenna = 1 : length(bbrx.Antennas) carrierGen = dsp.SineWave(... Frequency=bbrx.CenterFrequency(antenna)-frequencyBand.MidPoint,... SampleRate=bbrx.SampleRate*length(bbrx.Antennas),... SamplesPerFrame=length(resampledData),... ComplexOutput=true); resampledData(:,antenna) = resampledData(:,antenna).*carrierGen(); end
Plot Spectrum of Captured Data
Create a dsp.SpectrumAnalyzer
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.
PlotPowerLimits = [-120,
-60];
spectrumScope = dsp.SpectrumAnalyzer; spectrumScope.SampleRate = bbrx.SampleRate*length(bbrx.Antennas); spectrumScope.FrequencyOffset = frequencyBand.MidPoint; spectrumScope.YLimits = PlotPowerLimits; spectrumScope.SpectrumUnits = "dBFS"; spectrumScope.FullScaleSource = "Property"; spectrumScope.FullScale = 1; spectrumScope(resampledData); release(spectrumScope);