NB-IoT PRACH Waveform Generation
This example shows how to generate LTE-Advanced Pro Release 15 narrowband internet of things (NB-IoT) waveforms consisting of the narrowband physical random access channel (NPRACH).
Introduction
3GPP introduced a new air interface, NB-IoT, optimized for low data rate machine type communications in LTE-Advanced Pro Release 13. NB-IoT provides cost and power efficiency improvements as it avoids the need for complex signaling overhead required for other LTE-based systems.
You can use LTE Toolbox to generate standard compliant NB-IoT uplink complex baseband waveforms, representing the 180 kHz narrowband carrier, suitable for test and measurement applications. The NB-IoT uplink physical layer channels and signals are:
Narrowband demodulation reference signal (DM-RS)
Narrowband physical uplink shared channel (NPUSCH)
Narrowband physical random access channel (NPRACH)
In this example, we demonstrate NPRACH allocation in the resource grid and the generation of NPRACH waveforms, as defined in TS 36.211 Section 10.1.6 [ 1 ].
NPRACH Allocation
This section provides an overall description of the NPRACH allocation in time and frequency.
From a time point of view, an NPRACH transmission is defined as NRep repetitions of NPRACH preambles, in which an NPRACH preamble is defined as a set of P symbol groups. TS 36.211 Section 10.1.6.1 defines a symbol group as a sequence of N identical symbols preceded by a cyclic prefix. For this reason, the symbol group, rather than the OFDM symbol, can be considered as the atomic unit of NPRACH. The duration of an NPRACH symbol group is a function of the preamble format, as described in TS 36.211 Table 10.1.6.1-1 for frequency-division duplexing (FDD) and Table 10.1.6.1-2 for time-division duplexing (TDD). This figure shows a schematic of the symbol groups for the three NPRACH preamble formats for FDD.

From a frequency point of view, the NPRACH is characterized by single-tone transmission with frequency hopping and a subcarrier spacing defined in TS 36.211 Table 10.1.6.2-1. Each symbol group occupies a single subcarrier, following the frequency hopping pattern described in TS 36.211 Section 10.1.6.1. SubcarrierOffset defines the frequency location of the first subcarrier allocated to NPRACH. NumSubcarriers defines the total number of subcarriers allocated to NPRACH. Among those, the subcarrier location of the first symbol group of the first preamble is determined by NInit. For all subsequent preambles, the frequency of the first symbol group of each NPRACH preamble depends on the pseudorandom sequence defined in TS 36.211 Section 7.2 and initialized by NNCellID. This figure shows a schematic of the frequency hopping pattern for the first two repetitions of preamble format 0 for FDD, given the default NPRACH configuration used in this example. You can see that the first symbol groups of the two preambles occupy different subcarriers.

NPRACH Configuration
In this section, we configure the parameters required for NPRACH generation. For a list of all the allowed ranges for the parameters in the ue and chs structures, see lteNPRACH.
% Define the user equipment (UE) parameters ue = struct(); ue.NBULSubcarrierSpacing = '15kHz'; % Uplink subcarrier spacing ('3.75kHz', '15kHz') ue.NNCellID = 0; % Narrowband cell identity ue.Windowing = 0; % Number of time-domain samples over which the function applies windowing and overlapping of OFDM symbols. % Set Windowing to empty ([]) to use its default value. ue.DuplexMode = 'FDD'; % Duplex mode ('FDD' or 'TDD') if strcmpi(ue.DuplexMode,'TDD') ue.TDDConfig = 1; % TDD configuration. For a list of all supported TDD configurations for a given NPRACH format, see TS 36.211 Table 10.1.6.1-2 end % Define the channel parameters chs = struct(); chs.NPRACHFormat = '0'; % Preamble format ('0','1','2' for FDD, '0','1','2','0-a','1-a' for TDD) chs.Periodicity = 80; % NPRACH resource periodicity in ms chs.SubcarrierOffset = 12; % Frequency location of the first subcarrier allocated to NPRACH chs.NumSubcarriers = 24; % Number of subcarriers allocated to NPRACH chs.NRep = 8; % Number of NPRACH repetitions if strcmpi(ue.DuplexMode,'FDD') chs.StartTime = 8; % NPRACH starting time in ms (8,16,32,64,128,256,512,1024) else % TDD chs.StartTime = 10; % NPRACH starting time in ms (10,20,40,80,160,320,640,1280,2560,5120) end chs.NInit = 2; % Initial subcarrier for NPRACH chs.NPRACHPower = 30; % NPRACH power scaling in dB for plot visualization
NB-IoT PRACH Waveform Generation
In this section, we create the NPRACH resource grid and the time-domain waveform. The example generates a waveform that spans chs.Periodicity milliseconds and is sampled with the same sample rate used for the uplink signals with subcarrier spacing given by ue.NBULSubcarrierSpacing.
[waveform,info,resourceGrid] = lteNPRACH(ue,chs);
Plot Transmitted Grid
Plot the NPRACH resource grid. You can observe the frequency hopping pattern of the NPRACH symbols. Note that the resource grid plot uses the power levels of the NPRACH to assign colors to the resource elements. To disable the plot of the resource grid, set the value of displayGrid to 'off'.
displayGrid = 'on'; % Display the NPRACH resource grid ('on','off') hNPRACHResourceGridPlot(chs,resourceGrid,displayGrid);

Summary and Further Exploration
This example shows how to generate a time-domain waveform and visualize the resource grid for a single NB-IoT PRACH configuration. The generated NPRACH waveform spans chs.Periodicity milliseconds and is sampled with the same sample rate used for the uplink signals with subcarrier spacing given by ue.NBULSubcarrierSpacing. This allows you to generate an NPRACH waveform and add it to an existing NB-IoT uplink waveform. For more information about the generation of an NB-IoT uplink waveform, see NB-IoT Uplink Waveform Generation.
Selected Bibliography
3GPP TS 36.211. "Physical channels and modulation", 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
Local Functions
This example uses this local function:
function hNPRACHResourceGridPlot(chs,resourceGrid,displayGrid) %hNPRACHResourceGridPlot Plots the NPRACH resource grid % hNPRACHResourceGridPlot(CHS,RESOURCEGRID,DISPLAYGRID) plots the NPRACH % resource grid. Set DISPLAYGRID to 'off' to disable the plot of the % resource grid. if strcmpi(displayGrid,'on') figure % Create an image of the NPRACH resource grid im = image(resourceGrid); % Adjust plot colors, axes, and add title and labels cmap = parula(64); colormap(im.Parent,cmap); axis xy; xlabel('OFDM symbols') ylabel('Subcarriers') title(sprintf('NB-IoT PRACH RE Grid (Format = ''%s'')',chs.NPRACHFormat)) end end