物理层 手册专题 1,733 字

Matlab:默认函数 —— LTE 下行(OFDM)解调

在本节中,我将用'半真实数据'演示 OFDM 解调的工作原理。所谓半真实,是指这里使用的数据并非来自实际的 eNB,而是由真实硬件矢量信号发生器生成、并由矢量信号分析仪配合特殊同步信号采集得到的。因此你无需实现同步算法和大量补偿,那对一个示…

采集:2026-11-18T02:08:40+08:00 · 查看英文原文 ↗

原始来源:https://www.sharetechnote.com/html/Handbook_LTE_DL_Demodulation_Ex01.html

正文

在本节中,我将用’半真实数据’演示 OFDM 解调的工作原理。所谓半真实,是指这里使用的数据并非来自实际的 eNB,而是由真实硬件(矢量信号发生器)生成、并由矢量信号分析仪配合特殊同步信号采集得到的。因此你无需实现同步算法和大量补偿,那对一个示例而言实在过于繁重。如果你有兴趣以初学者水平入手 LTE DSP,这或许会有所帮助或启发。

解调本身很短:接收机丢弃循环前缀,对每个 OFDM 符号做 512 点 FFT,再从 FFT 频点上读出资源粒子。本节先展示结果,然后给出信号配置,最后给出产生该结果的 Matlab 代码。

以下是本节涵盖的主题。

  • 结果
  • 数据的 LTE 配置
  • Matlab 代码
  • 参考文献 如果定时已知,一个普通的 FFT 能否恢复出 LTE 资源网格?下图对子帧 0 中时隙 0 的七个 OFDM 符号给出了答案。每一行是一个符号,每一列是处理的一个阶段。

以下是此处所列 Matlab 源代码的结果。(A) 显示子帧 0 第一个时隙内各符号的频域结果。(B) 是列 (A) 的 I/Q 图(实部与虚部)表示。你会注意到存在一定程度的旋转(相移)。(C) 是对列 (B) 做相位补偿后的结果。

子帧 0 中时隙 0 的七个 OFDM 符号的 FFT 幅度、原始星座图及相位补偿后的星座图

图注:子帧 0 中时隙 0 的七个 OFDM 符号的 FFT 幅度、原始星座图及相位补偿后的星座图

各行是时隙 0 的 OFDM 符号 0 至 6。列 (A) 是 FFT 幅度,列 (B) 是原始星座图,列 (C) 是经过固定相位旋转后的星座图。

  • 符号 0:呈梳状频谱,因为只有部分资源粒子在控制区内携带能量。
  • 符号 1 至 4:300 个子载波构成的平坦块,在直流处有一个凹陷,并有四簇干净的 QPSK 点。
  • 符号 5:频谱中心附近出现窄缺口,星座图中出现额外的点。
  • 符号 6:中心处同样的缺口,星座图中出现一圈点。
  • 原点处的点:直流子载波以及 300 个子载波之外未使用的 FFT 频点。 最后两行与其他行不同,原因是同步信号。对于帧结构类型 1,36.211 v19.3.0 条款 6.11 将 PSS 映射到时隙 0 和 10 的最后一个 OFDM 符号,将 SSS 映射到它前面的符号。两者都使用直流附近的 62 个子载波,每侧各有 5 个保留子载波。这些保留子载波正是列 (A) 中符号 5 和 6 处的窄缺口。

星座图显示的信号与此一致。SSS 由二进制序列构成,因此其取值为实数。补偿后,它们在列 (C) 中符号 5 的实轴上形成两个额外的簇。PSS 是 Zadoff-Chu 序列,具有恒定的幅度和变化的相位。因此其取值在符号 6 中散布成一个圆圈,而其周围的数据仍停留在四个 QPSK 簇中。

一个固定的 PhaseOffset 就能校正全部七个符号。因此相位在 0.5 ms 的时隙内没有漂移,信号发生器与分析仪之间的残余频偏很小。列 (B) 中的旋转只是一个公共相位,实际接收机会用小区特定参考信号将其消除。

  • PSS 在符号 6,SSS 在符号 5:FDD 下时隙 0 的最后两个符号。
  • SSS 取值为实数:补偿后实轴上有两个簇。
  • PSS 取值具有恒定幅度:星座图中呈一个圆环。
  • 一个相位值适用于所有符号:时隙内未见频率漂移。 FFT 输出只有结合信号配置才有意义。带宽决定占用的子载波数,CFI 决定哪些符号承载控制区。信号发生器使用了以下设置。

我在本示例中使用的数据来自以下 LTE 配置。

  • System BandWidth = 5 Mhz
  • Number of RB = 25
  • Physical Cell ID = 0
  • CFI = 1
  • Sampling Rate = 7.68 Mhz 一个 5 MHz 的 LTE 载波有 25 个 RB,即 300 个 15 kHz 子载波。数据文件名 LTE_DL_5M_25RB_S_7_68_SG_Trig.bin 同样体现了 25 个 RB。在 7.68 Msps 下,FFT 有 512 个频点,因此载波之外和直流频点的共 212 个频点不携带数据。经过 fftshift 后,载波占据频点 107 至 407,这正是列 (A) 中的平坦块。

CFI = 1 表示控制区长度为一个 OFDM 符号。因此符号 0 承载了整个控制区:参考信号、PCFICH、PHICH 和 PDCCH。该信号的许多资源粒子在此符号中不携带能量,这使得符号 0 的频谱呈现梳状。Physical Cell ID = 0 决定了 PSS 和 SSS 序列以及参考信号的位置。

  • 25 个 RB:300 个子载波,即 512 个频点中的第 107 至 407。
  • 7.68 Msps:30.72 Msps 参考速率的四分之一。
  • CFI = 1:符号 0 是唯一的控制符号。
  • Physical Cell ID = 0:决定 PSS、SSS 和参考信号图样。 在做任何 FFT 之前,代码必须先回答两个问题:每个 OFDM 符号从哪里开始,其循环前缀有多少个采样。这里第一个答案是给定的数,第二个则来自 LTE 参数集(numerology),由 20 MHz 按比例缩放到 5 MHz。

以下是产生上述图形的 Matlab 源代码。这段代码是刻意写长的。如果用 for 循环,我本可以写得非常短,但那样看起来更难理解。所以我尽量把每一步逐步写出来。希望这样即使显得有点冗长,你也能更容易地看懂。

clear all;

% you can download the data file in this example from here.

% this is for reading the baseband IQ data of OFDM symbol in time domain.

% detailed explantion for this three line and file format in this example is described in

% Matlab : Read Number in Binary file page.

fid = fopen(‘LTE_DL_5M_25RB_S_7_68_SG_Trig.bin’,‘r’);

[data,count] = fread(fid, ‘single’);

fclose(fid);

% This variable represents the first sample in the first OFDM symbol.

% How do I know this ? This is just a magic number I could figure out from the vector signal

% analyzer. Just think this is just a given number. If you seriously want to work in this

% area, try to implement the algorithm to find this number on your own.

Offset = 280228 + 2 ;

% Nfft represents the FFT size for the specified system bandwidth. 512 is the FFT size for

% 5 Mhz System Bandwidth.

Nfft = 512;

% SamplingScale is to figure out the number of samples in CP and OFDM Symbol for each specific system

% Bandwidth from the 20 Mhz Bandwidth. Physical Layer Parameters - FDD, Downlink will help you understand

% the meaning of each numbers here.

SamplingScale = (double(Nfft)/2048);

CP_LengthList = SamplingScale * [160;144;144;144;144;144;144];

Symbol_LengthList = SamplingScale * [2048;2048;2048;2048;2048;2048;2048];

% This is to compensate the phase rotation shown in track (B) of the result.

% How do I figure out this number. I just got it by eye balling and a couple of try and error.

% If you seriously want to work in this area, try to implement the algorithm to find this

% number on your own.

PhaseOffset = exp(-j*pi/2.5)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demoulate the symbol 0 within the slot 0 of Subframe 0.

% ChuckStart here indicates the index(position) of the first sample within the binary file.

% You would notice that I skip the first CP length. This is the same effect of removing the

% first CP as described in CP removal described in RE Map to/from Antenna page.

ChunkStart = Offset …

  • CP_LengthList(1);

% This variable indicates the number of samples within the first OFDM symbol excluding the CP

ChunkLength = Symbol_LengthList(1);

% This is to read I/Q data pair.

DataChunk = data(2ChunkStart-1:2(ChunkStart+ChunkLength));

% This is to separate I and Q into a separate array (vector)

DataChunkI = DataChunk(1:2:length(DataChunk));

DataChunkQ = DataChunk(2:2:length(DataChunk));

% This is to combine I array and Q array into a complex number array.

DataChunkComplex = DataChunkI + j*DataChunkQ;

% This is to convert the time domain OFDM Symbol into Frequency Domain and Normalize it.

DataChunkFFT = fftshift(fft(DataChunkComplex,Nfft));

DataChunkFFT = DataChunkFFT/max(abs(DataChunkFFT));

DataChunkFftMag = abs(DataChunkFFT);

% This is to plot the FFT result in magnitude.

% The result of this block is shown in track (A) of the figure at the beginning of the page

subplot(7,5,[1 3]);

plot(DataChunkFftMag);xlim([1, length(DataChunkFftMag)]); ylim([0 1.2]);

set(gca,‘xticklabel’,[]);set(gca,‘yticklabel’,[]);

set(gca,‘xtick’,[]);set(gca,‘ytick’,[]);

% This is to plot the FFT result in complex domain (I and Q axis)

% The result of this block is shown in track (B) of the figure at the beginning of the page

subplot(7,5,4);

plot(real(DataChunkFFT),imag(DataChunkFFT),‘ro’,‘MarkerFaceColor’,[1 0 0],‘MarkerSize’,2);

xlim([-1 1]);ylim([-1 1]);

% This is to plot the FFT result rotated by the angle specified by the variable PhaseOffset

% The result of this block is shown in track (C) of the figure at the beginning of the page

subplot(7,5,5);

DataChunkFFT_Comp = DataChunkFFT .* PhaseOffset;

plot(real(DataChunkFFT_Comp),imag(DataChunkFFT_Comp),‘ro’,‘MarkerFaceColor’,[1 0 0],‘MarkerSize’,2);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 1 within the slot 0 of Subframe 0. Everything is same

% as in the symbol 0 analysis except the ‘ChunkStart. So I would not explain any further.

  • CP_LengthList(1) + Symbol_LengthList(1) …

  • CP_LengthList(2) ;

ChunkLength = Symbol_LengthList(2);

subplot(7,5,[6 8]);

subplot(7,5,9);

subplot(7,5,10);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 2 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(2) + Symbol_LengthList(2) …

  • CP_LengthList(3);

ChunkLength = Symbol_LengthList(3);

DataChunkFftdB = abs(DataChunkFFT);

subplot(7,5,[11 13]);

plot(DataChunkFftdB);xlim([1, length(DataChunkFftdB)]); ylim([0 1.2]);

subplot(7,5,14);

subplot(7,5,15);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 3 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(3) + Symbol_LengthList(3) …

  • CP_LengthList(4);

ChunkLength = Symbol_LengthList(4);

subplot(7,5,[16 18]);

subplot(7,5,19);

subplot(7,5,20);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 4 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(4) + Symbol_LengthList(4) …

  • CP_LengthList(5);

ChunkLength = Symbol_LengthList(5);

subplot(7,5,[21 23]);

subplot(7,5,24);

subplot(7,5,25);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 5 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(5) + Symbol_LengthList(5) …

  • CP_LengthList(6);

ChunkLength = Symbol_LengthList(6);

subplot(7,5,[26 28]);

subplot(7,5,29);

subplot(7,5,30);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 6 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(6) + Symbol_LengthList(6) …

  • CP_LengthList(7);

ChunkLength = Symbol_LengthList(7);

subplot(7,5,[31 33]);

subplot(7,5,34);

subplot(7,5,35);

缩放的计算方式如下。SamplingScale 为 512/2048 = 0.25。因此时隙第一个符号的循环前缀为 160 × 0.25 = 40 个采样,其余符号为 144 × 0.25 = 36 个采样。每个符号在循环前缀之后有 512 个采样。符号 n 的 ChunkStart 把此前所有循环前缀和符号加起来,再加上符号 n 自身的循环前缀。

Offset 是代码中唯一没有推导出来的数。《循环前缀相关》页面使用了同一数据文件,展示了如何通过将每个循环前缀与其符号末尾做相关来找到符号边界。Offset 错误不会让解调停止,但会在结果中体现出来。d 个采样的定时误差会使子载波 k 旋转 2πkd/512。在载波边缘(距直流 150 个子载波处),仅一个采样的误差就会使相位转过约 1.8 弧度,于是四个 QPSK 簇会模糊成圆环。

复用这段代码时,有两个小细节值得检查。DataChunk 的索引范围读取了 513 个采样,比符号多一个,而 fft(DataChunkComplex,Nfft) 会丢掉最后一个。符号 2 至 6 的列 (A) 图使用了变量名 DataChunkFftdB,但其中的值是线性幅度,而非 dB。

  • 循环前缀为 40 和 36 个采样:160 和 144 个 Ts 乘以 0.25。
  • Offset 来自代码外部:循环前缀相关在同一文件中找到符号边界。
  • 定时误差表现为相位斜率:在载波边缘约为每采样 1.8 弧度。
  • DataChunkFftdB 是线性的:名字暗示 dB,但代码从未取对数。 3GPP TS 36.211 v19.3.0 —— PSS 和 SSS 的条款 6.11,以及 OFDM 基带信号生成的条款 6.12

物理层参数 —— FDD,下行

LTE 定时同步:循环前缀相关

图示资源


同族文档