Created
July 21, 2020 19:10
-
-
Save tfcollins/1a2652d14a52aa90609641e9ceebfc5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
TMN = '3.1'; | |
countTx = 1; | |
BW = '20 MHz'; | |
BW = BW(~isspace(BW)); | |
[eNodeBOutput, etm] = LTEAppInternals.Tx(TMN, BW); | |
% app.LTEAppInternalsProp.CyclicPrefix = etm.CyclicPrefix; | |
% app.LTEAppInternalsProp.NCellID = etm.NCellID; | |
% app.LTEAppInternalsProp.SamplingRate = etm.SamplingRate; | |
% scale the signal and cast to int16 | |
backoff = -3; % dB | |
RadioRate = 122.88e6*2; | |
%% transmit waveform using ADALM-PLUTO over a loopback cable and | |
% receive waveform | |
% dataRx = obj.PlutoRadio(app, eNodeBOutput, countTx); | |
% eNodeBOutput = resample(eNodeBOutput,RadioRate,etm.SamplingRate); | |
Output_max = max([max(abs(real(eNodeBOutput))) max(abs(imag(eNodeBOutput)))]); | |
eNodeBOutput = eNodeBOutput.*(10^(backoff/20))/Output_max; | |
eNodeBOutput = int16(eNodeBOutput*2^15); | |
tx = adi.ADRV9009.Tx(); | |
tx.uri = 'ip:10.48.65.139'; | |
tx.EnabledChannels = [2]; | |
tx.EnableCyclicBuffers = true; | |
tx(eNodeBOutput); | |
rx = adi.ADRV9009.Rx(); | |
rx.uri = 'ip:10.48.65.139'; | |
rx.SamplesPerFrame = 2^22; | |
rx.CenterFrequency = 4e9; | |
rx.EnabledChannels = [2]; | |
eNodeBOutput = rx(); | |
dataRx = double(eNodeBOutput); | |
countTx = countTx+1; | |
%% Resample data to expected rate | |
% dataRx = resample(dataRx,etm.SamplingRate,RadioRate); | |
%% demodulate received waveform and compute metrics | |
[dataRx, frameOffset] = LTEAppInternals.CorrectFreqFrameOffset(dataRx, etm); | |
% app.LTEAppInternalsProp.FrameOffset = frameOffset/etm.SamplingRate; | |
% compute freq offset and IQ offset | |
cec.PilotAverage = 'TestEVM'; | |
[FreqOffset_temp, IQOffset_temp, refGrid, rxGridLow, rxGridHigh, ... | |
rxWaveform, nSubframes, nFrames, alg, frameEVM] = ... | |
LTEAppInternals.Sync(etm, cec, dataRx); | |
app.LTEAppInternalsProp.FreqOffset = FreqOffset_temp; | |
app.LTEAppInternalsProp.IQOffset = IQOffset_temp; | |
% stop test if needed | |
% if obj.stopTest(app) | |
% return; | |
% end | |
% estimate channel | |
[psd_frame, f, HestLow, HestHigh, allPRBSet] = ... | |
LTEAppInternals.EstimateChannel(etm, ... | |
rxWaveform, nSubframes, cec, rxGridLow, rxGridHigh); | |
app.LTEAppInternalsProp.PSD_x = f; | |
app.LTEAppInternalsProp.PSD_y = psd_frame; | |
% compute EVM measurements | |
gridDims = lteResourceGridSize(etm); | |
L = gridDims(2); | |
% evmSymbolPlot = app.evmSymsAxes; | |
% evmSymbolPlot.XLim = [0 (L*nSubframes)-1]; | |
app.LTEAppInternalsProp.count = 1; | |
for i=0:nSubframes-1 | |
% app.SummaryTable1_Data{1} = app.LTEAppInternalsProp.CyclicPrefix; | |
% app.SummaryTable1_Data{2} = app.LTEAppInternalsProp.NCellID; | |
% stop test if needed | |
% if obj.stopTest(app) | |
% return; | |
% end | |
% msg = sprintf('Processing Subframe #%d\n', i); | |
% app.Label.Text = {msg}; | |
% drawnow; | |
app.LTEAppInternalsProp.SubFrameIndex = i; | |
[EqGridStruct, EVMStruct, evm, allocatedSymbols, rxSymbols, ... | |
refSymbols, pdsch_ind, etm] = ... | |
LTEAppInternals.EVMSubframe(i, nSubframes, etm, allPRBSet, ... | |
refGrid, rxGridLow, rxGridHigh, HestLow, HestHigh); | |
app.LTEAppInternalsProp.EqGridStruct = EqGridStruct; | |
app.LTEAppInternalsProp.DemodSyms = ... | |
struct('Rec', rxSymbols, 'Ref', refSymbols); | |
if isfield(EVMStruct, 'PBCH') | |
app.LTEAppInternalsProp.evm_pbch_RMS = 100*EVMStruct.PBCH; | |
end | |
if isfield(EVMStruct, 'PCFICH') | |
app.LTEAppInternalsProp.evm_pcfich_RMS = 100*EVMStruct.PCFICH; | |
end | |
if isfield(EVMStruct, 'PHICH') | |
app.LTEAppInternalsProp.evm_phich_RMS = 100*EVMStruct.PHICH; | |
end | |
if isfield(EVMStruct, 'PDCCH') | |
app.LTEAppInternalsProp.evm_pdcch_RMS = 100*EVMStruct.PDCCH; | |
end | |
if isfield(EVMStruct, 'RS') | |
app.LTEAppInternalsProp.evm_rs_RMS = 100*EVMStruct.RS; | |
end | |
if isfield(EVMStruct, 'PSS') | |
app.LTEAppInternalsProp.evm_pss_RMS = 100*EVMStruct.PSS; | |
end | |
if isfield(EVMStruct, 'SSS') | |
app.LTEAppInternalsProp.evm_sss_RMS = 100*EVMStruct.SSS; | |
end | |
[SymbEVM, ScEVM, RbEVM, frameLowEVM, frameHighEVM, frameEVM, etm,... | |
app.LTEAppInternalsProp.count, app.LTEAppInternalsProp.nFrame] = ... | |
LTEAppInternals.DemodSymbs(i, pdsch_ind, nFrames, ... | |
app.LTEAppInternalsProp.count, alg, etm, evm, ... | |
allocatedSymbols, frameEVM, nSubframes); | |
SymbEVM.evmSymbolRMS(1) = SymbEVM.evmSymbolRMS(2); | |
SymbEVM.evmSymbolPeak(1) = SymbEVM.evmSymbolPeak(2); | |
app.LTEAppInternalsProp.evmSC = ... | |
struct('RMS', ScEVM.evmSubcarrierRMS, 'Peak', ScEVM.evmSubcarrierPeak, ... | |
'EVMGrid', ScEVM.evmGrid); | |
PDSCHevm_temp = ScEVM.evmGrid(:); | |
app.LTEAppInternalsProp.PDSCHevm = mean(PDSCHevm_temp(PDSCHevm_temp~=0)); | |
app.LTEAppInternalsProp.evmRB = ... | |
struct('RMS', RbEVM.evmRBRMS, 'Peak', RbEVM.evmRBPeak); | |
app.LTEAppInternalsProp.evmSymbol = ... | |
struct('RMS', SymbEVM.evmSymbolRMS, 'Peak', SymbEVM.evmSymbolPeak); | |
gg = inline('20*log10(x/100)','x'); | |
if (mod(i, 10)==9 || (nFrames==0 && i==nSubframes-1)) | |
app.LTEAppInternalsProp.FrameEVM = ... | |
struct('Low', frameLowEVM, ... | |
'High', frameHighEVM, 'Overall', frameEVM); | |
fprintf("frameLowEVM %f\nframeHighEVM %f\nOverall %f\n",frameLowEVM.RMS,frameHighEVM.RMS,frameEVM.RMS); | |
fprintf("frameLowEVM %f\nframeHighEVM %f\nOverall %f\n",gg(frameLowEVM.RMS),gg(frameHighEVM.RMS),gg(frameEVM.RMS)); | |
end | |
% if (i == 0) | |
% app.SummaryTable1.Data(:, 2) = app.SummaryTable1_Data; | |
% end | |
% app.SummaryTable2.Data(:, 3) = app.SummaryTable2_Data; | |
% if (i == nSubframes-1) | |
% temp_SummaryTable3 = cell(8, 1); | |
% for ii = 1:8 | |
% app.SummaryTable3_Data(ii, 3) = ... | |
% app.SummaryTable3_Data(ii, 1)/app.SummaryTable3_Data(ii, 2); | |
% if strcmp(app.dBPercentDropDown.Value, 'dB') | |
% temp_SummaryTable3{ii} = ... | |
% sprintf('%2.3f', 20*log10(0.01*app.SummaryTable3_Data(ii, 3))); | |
% else | |
% temp_SummaryTable3{ii} = sprintf('%2.3f', app.SummaryTable3_Data(ii, 3)); | |
% end | |
% end | |
% app.SummaryTable3.Data(:, 2) = temp_SummaryTable3; | |
% app.SummaryTable1.Data{end, 2} = temp_SummaryTable3{end}; | |
% end | |
% if (strcmp(app.StepOrPlayButton, 'step') && (i == nSubframes-1)) | |
% app.Label.Text = {'Test stopped.'}; | |
% app.PlayStopButton.Enable = 'on'; | |
% app.StepButton.Enable = 'on'; | |
% app.DocButton.Enable = 'on'; | |
% app.GridButton.Enable = 'on'; | |
% app.dBPercentDropDown.Enable = 'on'; | |
% app.TMNDropDown.Enable = 'on'; | |
% app.BWDropDown.Enable = 'on'; | |
% app.LOEditField.Enable = 'on'; | |
% | |
% app.PBCHCheckBox.Enable = 'on'; | |
% app.PCFICHCheckBox.Enable = 'on'; | |
% app.PHICHCheckBox.Enable = 'on'; | |
% app.PDCCHCheckBox.Enable = 'on'; | |
% app.RSCheckBox.Enable = 'on'; | |
% app.PSSCheckBox.Enable = 'on'; | |
% app.SSSCheckBox.Enable = 'on'; | |
% app.PDSCHCheckBox.Enable = 'on'; | |
% app.EVMScCheckBox.Enable = 'on'; | |
% app.EVMRbCheckBox.Enable = 'on'; | |
% app.EVMSymsCheckBox.Enable = 'on'; | |
% app.ConstCheckBox.Enable = 'on'; | |
% app.PSDCheckBox.Enable = 'on'; | |
% | |
% drawnow; | |
% return; | |
% end | |
end | |
% Final Mean EVM across all frames | |
app.LTEAppInternalsProp.FinalEVM = lteEVM(cat(1, frameEVM(:).EV)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment