利用matlab和SDR实现LTE信号的采集以及帧同步,MIB解码

利⽤matlab和SDR实现LTE信号采集以及帧同步,MIB解码        到这篇⽂章的同志们,⼀定正在LTE⽣死线上苦苦挣扎,⼤家都知道对LTE信号进⾏采集的时候,是采⽤30.72M(15K✖2048)的时钟频率,然后呢,LTE频带的带宽是18M(15K✖1200)为了避免⼤家少⾛弯路,我将代码附在⽂章末尾。我们可以采集到的信号如下图所⽰。
⼤家可以看到这与事实是相符合的,在中⼼频率的左右各是±9MHz,因此我们可以通过查移动,联通,电信对应的下⾏频段信息,然后就可以采集到信息了。
帧同步如下所⽰。
频偏估计以及MIB就不⼀⼀展⽰了,⼤家可以运⾏程序调参。
%% Connect to Radio
radioFound = false;
radiolist = findsdru;
for i = 1:length(radiolist)
if strcmp(radiolist(i).Status, 'Success')
if strcmp(radiolist(i).Platform, 'B210')
radio = comm.SDRuReceiver('Platform','B210', ...
'SerialNum', radiolist(i).SerialNum);
radio.MasterClockRate = 1.92e6 * 4; % Need to exceed 5 MHz minimum
radio.DecimationFactor = 4;        % Sampling rate is 1.92e6
radioFound = true;
break;
end
if (strcmp(radiolist(i).Platform, 'X300') || ...
strcmp(radiolist(i).Platform, 'X310'))
radio = comm.SDRuReceiver('Platform',radiolist(i).Platform, ...
'IPAddress', radiolist(i).IPAddress);
radio.MasterClockRate = 184.32e6;
radio.DecimationFactor = 96;        % Sampling rate is 1.92e6
radioFound = true;
end
市区工况油耗if (strcmp(radiolist(i).Platform, 'N300') || ...
strcmp(radiolist(i).Platform, 'N310'))
radio = comm.SDRuReceiver('Platform',radiolist(i).Platform, ...
'IPAddress', radiolist(i).IPAddress);
radio.MasterClockRate = 122.88e6;
radio.DecimationFactor = 64;        % Sampling rate is 1.92e6
radioFound = true;
end
if (strcmp(radiolist(i).Platform, 'N320/N321'))
radio = comm.SDRuReceiver('Platform',radiolist(i).Platform, ...
'IPAddress', radiolist(i).IPAddress);
radio.MasterClockRate = 245.76e6;
radio.DecimationFactor = 128;        % Sampling rate is 1.92e6
radioFound = true;
end
end
end
if ~radioFound
error(message('sdru:examples:NeedMIMORadio'));
end
radio.ChannelMapping = [1 2];    % Receive signals from both channels
radio.CenterFrequency = 900e6;
radio.Gain = 30;
radio.SamplesPerFrame = 19200; % Sampling rate is 1.92 MHz. LTE frames are 10 ms long radio.OutputDataType = 'double';
radio.EnableBurstMode = true;
radio.NumFramesInBurst = 4;
radio.OverrunOutputPort = true;
radio
%% Capture Signal
burstCaptures = zeros(19200,4,2);
len = 0;
地中海果蝇for frame = 1:4
while len == 0
[data,len,lostSamples] = step(radio);
[data,len,lostSamples] = step(radio);
burstCaptures(:,frame,:) = data;
end
len = 0;
end
release(radio);
eNodeBOutput = reshape(burstCaptures,[],2);
sr = 1.92e6 ; % LTE sampling rate
% Check for presence of LTE Toolbox
if isempty(ver('lte'))
error(message('sdru:examples:NeedLST'));
end
separator = repmat('-',1,50);
% plots
if (~exist('channelFigure','var') || ~isvalid(channelFigure))
channelFigure = figure('Visible','off');
end
[spectrumAnalyzer,synchCorrPlot,pdcchConstDiagram] = ...
hSIB1RecoveryExamplePlots(channelFigure,sr);
% PDSCH EVM
pdschEVM = comm.EVM();
pdschEVM.MaximumEVMOutputPort = true;
% Set eNodeB basic parameters
enb = struct;                  % eNodeB config structure
enb.DuplexMode = 'FDD';        % assume FDD duxplexing mode
enb.CyclicPrefix = 'Normal';    % assume normal cyclic prefix
enb.NDLRB = 6;                  % Number of resource blocks
ofdmInfo = lteOFDMInfo(enb);    % Needed to get the sampling rate
if (isempty(eNodeBOutput))
fprintf('\nReceived signal must not be empty.\n');
return;
end
% Display received signal spectrum
fprintf('\nPlotting received \n');
step(spectrumAnalyzer, awgn(eNodeBOutput, 100.0));
if (sr~=ofdmInfo.SamplingRate)
fprintf('\nResampling from %0.3fMs/s to %0.3fMs/s for cell search / \n',sr/1e6,ofdmInfo.SamplingRate/1e6);
else
fprintf('\nResampling not required; received signal is at desired sampling rate for cell search / MIB decoding (%0.3fMs/s).\n',sr/1e6); end
% Downsample received signal
nSamples = ceil(ofdmInfo.SamplingRate/round(sr)*size(eNodeBOutput,1));
nRxAnts = size(eNodeBOutput, 2);
downsampled = zeros(nSamples, nRxAnts);
for i=1:nRxAnts
downsampled(:,i) = resample(eNodeBOutput(:,i), ofdmInfo.SamplingRate, round(sr));
end
%% Frequency offset estimation and correction
fprintf('\nPerforming frequency \n');
delta_f = lteFrequencyOffset(setfield(enb,'DuplexMode','FDD'), downsampled); %#ok<SFLD>
fprintf('Frequency offset: %0.3fHz\n',delta_f);
downsampled = lteFrequencyCorrect(enb, downsampled, delta_f);
%% Cell Search and Synchronization
% Cell search to find cell identity and timing offset
fprintf('\nPerforming \n');
[cellID, offset] = lteCellSearch(enb, downsampled);
corr = cell(1,3);
for i = 0:2
enb.NCellID = mod(cellID + i,504);
[~,corr{i+1}] = lteDLFrameOffset(enb, downsampled);
corr{i+1} = sum(corr{i+1},2);
end
threshold = 1.3 * max([corr{2}; corr{3}]); % multiplier of 1.3 empirically obtained
if (max(corr{1})<threshold)
warning('sdru:examples:WeakSignal','Synchronization signal correlation was weak; detected cell identity may be incorrect.'); end
enb.NCellID = cellID;
% plot PSS/SSS
synchCorrPlot.YLimits = [0 max([corr{1}; threshold])*1.1];
step(synchCorrPlot, [corr{1} threshold*ones(size(corr{1}))]);
% perform timing synchronisation
fprintf('Timing offset to frame start: %d samples\n',offset);
downsampled = downsampled(1+offset:end,:);
enb.NSubframe = 0;
% show cell-wide settings
fprintf('Cell-wide settings after cell search:\n');
disp(enb);
%% OFDM Demodulation and Channel Estimation
% Channel estimator configuration
cec.PilotAverage = 'UserDefined';    % Type of pilot averaging
cec.FreqWindow = 9;                  % Frequency window size
cec.TimeWindow = 9;                  % Time window size
cec.InterpType = 'cubic';            % 2D interpolation type
cec.InterpWindow = 'Centered';        % Interpolation window type
cec.InterpWinSize = 1;                % Interpolation window size
% Assume 4 cell-specific reference signals for initial decoding attempt;
% ensures channel estimates are available for all cell-specific reference
% signals
enb.CellRefP = 4;
fprintf('Performing \n\n');
griddims = lteResourceGridSize(enb); % Resource grid dimensions
L = griddims(2);                    % Number of OFDM symbols in a subframe
% OFDM demodulate signal
rxgrid = lteOFDMDemodulate(enb, downsampled);
if (isempty(rxgrid))反猫眼窥镜
fprintf('After timing synchronization, signal is shorter than one subframe so no further demodulation will be performed.\n');    return;
end
% Perform channel estimation
if (strcmpi(enb.DuplexMode,'TDD'))
enb.TDDConfig = 0;
enb.SSC = 0;
end
[hest, nest] = lteDLChannelEstimate(enb, cec, rxgrid(:,1:L,:));
%% PBCH Demodulation, BCH Decoding, MIB parsing
fprintf('Performing \n');
pbchIndices = ltePBCHIndices(enb);
[pbchRx, pbchHest] = lteExtractResources( ...
pbchIndices, rxgrid(:,1:L,:), hest(:,1:L,:,:));
% Decode PBCH
% Decode PBCH
[bchBits, pbchSymbols, nfmod4, mib, enb.CellRefP] = ltePBCHDecode( ...
enb, pbchRx, pbchHest, nest);负压脉动式清肺仪
% Parse MIB bits
enb = lteMIB(mib, enb);展示架制作
enb.NFrame = enb.NFrame+nfmod4;
% Display cell wide settings after MIB decoding
fprintf('Cell-wide settings after MIB decoding:\n');
disp(enb);
if (enb.CellRefP==0)
fprintf('MIB decoding failed (enb.CellRefP=0).\n\n');
return;
end
if (enb.NDLRB==0)
fprintf('MIB decoding failed (enb.NDLRB=0).\n\n');
return;
end
%% OFDM Demodulation on Full Bandwidth
fprintf('Restarting reception now that bandwidth (NDLRB=%d) \n',enb.NDLRB);
% Resample now we know the true bandwidth
ofdmInfo = lteOFDMInfo(enb);
if (sr~=ofdmInfo.SamplingRate)
fprintf('\nResampling from %0.3fMs/s to %0.\n',sr/1e6,ofdmInfo.SamplingRate/1e6);
else
fprintf('\nResampling not required; received signal is at desired sampling rate for NDLRB=%d (%0.3fMs/s).\n',enb.NDLRB,sr/1e6); end
nSamples = ceil(ofdmInfo.SamplingRate/round(sr)*size(eNodeBOutput,1));
resampled = zeros(nSamples, nRxAnts);
for i = 1:nRxAnts
resampled(:,i) = resample(eNodeBOutput(:,i), ofdmInfo.SamplingRate, round(sr));
end
% Perform frequency offset estimation and correction
fprintf('\nPerforming frequency \n');
delta_f = lteFrequencyOffset(setfield(enb,'DuplexMode','FDD'), resampled); %#ok<SFLD>
fprintf('Frequency offset: %0.3fHz\n',delta_f);
resampled = lteFrequencyCorrect(enb, resampled, delta_f);
% Find beginning of frame
fprintf('\nPerforming timing \n');
offset = lteDLFrameOffset(enb, resampled);
fprintf('Timing offset to frame start: %d samples\n',offset);
resampled = resampled(1+offset:end,:);
% OFDM demodulation
fprintf('\nPerforming \n\n');
rxgrid = lteOFDMDemodulate(enb, resampled);
%% SIB1 Decoding
% Check this frame contains SIB1, if not advance by 1 frame provided we
正弦波信号发生器
% have enough data, terminate otherwise.
if (mod(enb.NFrame,2)~=0)
if (size(rxgrid,2)>=(L*10))
rxgrid(:,1:(L*10),:) = [];
fprintf('Skipping frame %d (odd frame number does not contain SIB1).\n\n',enb.NFrame);
else

本文发布于:2024-09-24 11:25:40,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/206843.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:信号   采集   移动
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议