5G NR Waveform Capture and Analysis Using Software-Defined Radio
This example shows how to use the 5G Waveform Generator app to generate and transmit a standard-compliant 5G NR waveform continuously over the air using a software-defined radio (SDR). The example then shows how to capture the transmitted waveform from the air using an SDR and analyze the signal in MATLAB®.
Introduction
This diagram shows the main steps of the example.
Generate a baseband waveform by using the 5G Waveform Generator app.
Transmit the generated waveform over the air, directly from the app, by using a connected SDR hardware (requires an SDR support package).
Capture the over-the-air waveform in MATLAB by using another connected SDR hardware or the same SDR hardware (requires an SDR support package).
Analyze the PDCCH/PDSCH error vector magnitude (EVM) of the captured waveform in MATLAB.
To transmit and capture waveforms with SDRs, you must install the corresponding hardware support package. This list provides information on which radios can be used by this example along with the required products.
ADALM-PLUTO (requires Communications Toolbox Support Package for Analog Devices® ADALM-PLUTO Radio)
USRP™ B200/B210/N200/N210/USRP2/N300/N310/N320/N321/X300/X310 (requires Communications Toolbox Support Package for USRP™ Radio )
USRP™ E310/E312 (requires Communications Toolbox Support Package for USRP™ Embedded Series Radio)
AD9361/FMCOMMS2/3/4/5 (requires Communications Toolbox Support Package for Xilinx® Zynq®-Based Radio)
Generate Baseband Waveform
In MATLAB, on the Apps tab, click the 5G Waveform Generator app.
In the Waveform Type section, click Downlink FRC. In the leftmost pane of the app, you can set the parameters for the selected waveform. For this example:
Set Frequency range to
FR1 (410 MHz - 7.125 GHz)
.Set MCS to
64QAM, R=3/4
.Set Subcarrier spacing (kHz) to
30
.Set Channel bandwidth (MHz) to
10
.Set Duplex mode to
FDD
.Set RNTI to 0.
Select the OCNG check box.
On the app toolstrip, click Generate.
Transmit Generated Waveform
On the Transmitter tab of the app, in the Transmitter Type section, select your SDR for waveform transmission.
If you have an ADALM-PLUTO radio corresponding to the Communications Toolbox Support Package for Analog Devices® ADALM-PLUTO Radio, select
Pluto
.If you have a USRP™ B200, B210, N200, N210, USRP2, N300, N310, N321, X300, or X310 radio corresponding to the Communications Toolbox Support Package for USRP™ Radio, select
USRP B/N/X
. In this case, this examples requires a secondary SDR and MATLAB session to capture the transmitted signal. Otherwise, you can use the same SDR for reception as you do for transmission.If you have a USRP™ E310 or E312 radio corresponding to the Communications Toolbox Support Package for USRP™ Embedded Series Radio, select
USRP E
.If you have a AD936x or FMCOMMS5 radio corresponding to the Communications Toolbox Support Package for Xilinx® Zynq®-Based Radio, select
Zynq Based
.
Specify your transmission parameters, such as Center frequency (Hz) and Gain (dB). The app automatically obtains the baseband sample rate from the generated waveform and performs any oversampling, if necessary.
Capture Transmitted Waveform
Set Up Receiver Processing Parameters
Set the downlink waveform parameters used in the app for receiver processing.
rc ="DL-FRC-FR1-64QAM"; % Reference channel bw =
"10MHz"; % Channel bandwidth scs =
"30kHz"; % Subcarrier spacing dm =
"FDD"; % Duplexing mode rnti =
0; % Radio network temporary identifier
Configure SDR Receiver Object
To capture the waveform that the app continously transmits, create an hSDRReceiver
object and then set the object properties.
Set
rx.CenterFrequency
to3.4e9
, as specified in the Transmitter tab of the app.Set
rx.SampleRate
to a value greater than or equal to the Transmitter sample rate (Hz) parameter value in the app.Set
rx.Gain
to any valid value that provides a successful decode of the captured waveform. Valid values of gain include'AGC Fast Attack',
'AGC Slow Attack'
, or an integer value for the Zynq-Based, USRP Embedded, or ADALM-PLUTO radios. USRP radios only support integer values.
rx = hSDRReceiver("Pluto"); % SDR receiver object rx.CenterFrequency =
3.4e9; rx.SampleRate =
30.72e6; rx.Gain =
60;
Specify the number of contiguous 5G frames to capture. One frame equates to 10 milliseconds.
framesToCapture =1; % Derived parameters captureDuration = milliseconds(10)*(framesToCapture+1); % Increase capture frame by 1 to account for a full frame not being captured
Initiate Waveform Capture
Initiate a capture of the 5G NR waveform transmitted by the app.
rxWaveform = capture(rx,captureDuration);
## Establishing connection to hardware. This process can take several seconds.
Plot the power spectral density (PSD) of the received signal.
spectrumPlotRx = spectrumAnalyzer; spectrumPlotRx.SampleRate = rx.SampleRate; spectrumPlotRx.SpectrumType = "Power density"; spectrumPlotRx.YLabel = "PSD"; spectrumPlotRx.Title = "Received Signal Spectrum"; spectrumPlotRx(rxWaveform);
Measure EVM of Received Waveform
Generate and extract a nrDLCarrierConfig
object for a specific test model (TM) or fixed reference channel (FRC) using the hNRReferenceWaveformGenerator
helper file.
rcwavegen = hNRReferenceWaveformGenerator(rc,bw,scs,dm); cfgDL = rcwavegen.Config;
Use the hNRDownlinkEVM
function to analyze the waveform. In this example, the function performs these steps.
Estimates and compensates for any frequency offset.
Estimates and corrects I/Q imbalance.
Synchronizes the DM-RS over one frame for frequency division duplexing (FDD) or two frames for time division duplexing (TDD).
Demodulates the received waveform.
Estimates the channel.
Equalizes the symbols.
Estimates and compensates for common phase error (CPE).
Computes the physical downlink shared channel (PDSCH) EVM.
Computes the physical downlink control channel (PDCCH) EVM.
For more information on the hNRDownlinkEVM
function, see the EVM Measurement of 5G NR Downlink Waveforms with RF Impairments example.
Define the configuration settings for the hNRPDSCHEVM
function.
cfg = struct(); cfg.PlotEVM = true; % Plot EVM statistics cfg.DisplayEVM = true; % Print EVM statistics cfg.Label = rc; % Set to TM name of captured waveform cfg.SampleRate = rx.SampleRate; % Use sample rate during capture cfg.IQImbalance = true; cfg.TargetRNTIs = rnti; cfg.CorrectCoarseFO = true; cfg.CorrectFineFO = true; [evmInfo,eqSym,refSym] = hNRDownlinkEVM(cfgDL,rxWaveform,cfg);
EVM stats for BWP idx : 1 PDSCH RMS EVM, Peak EVM, slot 1: 7.744 110.834% PDSCH RMS EVM, Peak EVM, slot 2: 7.645 110.288% PDSCH RMS EVM, Peak EVM, slot 3: 7.256 93.874% PDSCH RMS EVM, Peak EVM, slot 4: 7.766 117.640% PDSCH RMS EVM, Peak EVM, slot 5: 7.388 105.840% PDSCH RMS EVM, Peak EVM, slot 6: 7.154 98.483% PDSCH RMS EVM, Peak EVM, slot 7: 7.664 108.556% PDSCH RMS EVM, Peak EVM, slot 8: 7.427 104.623% PDSCH RMS EVM, Peak EVM, slot 9: 8.205 112.831% PDSCH RMS EVM, Peak EVM, slot 10: 8.218 120.166% PDSCH RMS EVM, Peak EVM, slot 11: 8.015 115.119% PDSCH RMS EVM, Peak EVM, slot 12: 7.493 97.563% PDSCH RMS EVM, Peak EVM, slot 13: 7.659 123.200% PDSCH RMS EVM, Peak EVM, slot 14: 7.972 106.357% PDSCH RMS EVM, Peak EVM, slot 15: 7.704 109.554% PDSCH RMS EVM, Peak EVM, slot 16: 7.557 116.319% PDSCH RMS EVM, Peak EVM, slot 17: 7.745 109.726% PDSCH RMS EVM, Peak EVM, slot 18: 7.268 104.755% PDSCH RMS EVM, Peak EVM, slot 19: 7.697 109.558% PDSCH RMS EVM, Peak EVM, slot 21: 7.655 111.468% PDSCH RMS EVM, Peak EVM, slot 22: 7.394 98.480% PDSCH RMS EVM, Peak EVM, slot 23: 6.969 105.538% Averaged RMS EVM frame 0: 7.667%
Averaged overall PDSCH RMS EVM: 7.667% Overall PDSCH Peak EVM = 123.2002%
The output of the hNRDownlinkEVM
function shows that the demodulation of the received waveform is successful. The interference from the DC component of the SDR to the DC subcarrier causes high EVM values in the measurements.