finish pa phase calibration, add sample data

测试了三台对飞节点的相对幅相,测试了一台814节点的相对幅相
This commit is contained in:
2023-05-16 09:14:53 +08:00
parent c32d684223
commit 986a2ea1e1
256 changed files with 1273 additions and 43 deletions
@@ -0,0 +1,207 @@
%% File Header/文件说明
%
% Beamforming with phased array derives signal characteristics from phase
% differences between sensors. Therefore the amplitude-phase consistence is
% vital to phased systems.
%
% The script analyzes the amp-phase relations of ILA captured data, the format
% of which is square-shaped pseudorandorm bit sequence. Each channel is
% processed seperately with different frequency shifts and different optimum
% sampling points. The estimation of amplitude and phase are based on
% acculumated correlation peaks.
%
clc; clear;
%% initial parameters/初始参数
interp = 8; % interpolation factor
channelNum = 4;
symNum = 8;
fs = 48e6;
freqRange = 25000:1000:30000;
% dataFile = [ ...
% "iladata_rx_data_26G_20230511_1615_SWGnd_A-1.csv", ...
% "iladata_rx_data_26G_20230511_1619_SWGnd_Ant01_A-1.csv", ...
% "iladata_rx_data_26G_20230511_1620_SWGnd_Ant02_A-1.csv", ...
% "iladata_rx_data_26G_20230511_1624_SWGnd_Ant03_A-1.csv", ...
% "iladata_rx_data_26G_20230511_1626_SWGnd_B-1.csv", ...
% "iladata_rx_data_26G_20230511_1628_SWGnd_Ant01_B-1.csv", ...
% "iladata_rx_data_26G_20230511_1630_SWGnd_Ant02_B-1.csv", ...
% "iladata_rx_data_26G_20230511_1631_SWGnd_Ant03_B-1.csv", ...
% ];
dataFile = [ ...
"iladata_814_rx_26G_20230512_1650_A-1.csv", ...
"iladata_814_rx_26G_20230512_1650_A-2.csv", ...
"iladata_814_rx_26G_20230512_1650_A-3.csv", ...
"iladata_814_rx_26G_20230512_1700_A-1.csv", ...
"iladata_814_rx_26G_20230512_1700_A-2.csv", ...
"iladata_814_rx_26G_20230512_1700_A-3.csv", ...
"iladata_814_rx_26G_20230512_1730_B-1.csv", ...
"iladata_814_rx_26G_20230512_1730_B-2.csv", ...
"iladata_814_rx_26G_20230512_1730_B-3.csv", ...
];
dataFileNum = length(dataFile);
% standard pn sequence
pnSequence = comm.PNSequence('Polynomial','x^7+x^6+1', ...
'InitialConditions',[zeros(1,6),1],'SamplesPerFrame',2^7-1);
PRBS7 = pnSequence();
PRBS7_polar = 1-2*[PRBS7;0];
pnSequence = comm.PNSequence('Polynomial','x^10+x^7+1', ...
'InitialConditions',[zeros(1,9),1],'SamplesPerFrame',2^10-1);
PRBS10 = pnSequence();
PRBS10_polar = 1-2*[PRBS10;0];
%% data analysis
% search for frequency shift
freqDmfPeak = zeros(dataFileNum,length(freqRange));
freqTarget = zeros(dataFileNum,channelNum);
% phase amplitude analysis
desiredPnt = zeros(dataFileNum,symNum-1,channelNum);
desiredPntIndex = zeros(dataFileNum,symNum-1,channelNum);
ampEstSymRaw = zeros(dataFileNum,symNum-1,channelNum);
ampEstSymMin = zeros(dataFileNum,channelNum);
ampEstSymMax = zeros(dataFileNum,channelNum);
ampEstSymAvg = zeros(dataFileNum,channelNum);
angEstSymRaw = zeros(dataFileNum,symNum-1,channelNum);
angEstSymMin = zeros(dataFileNum,channelNum);
angEstSymMax = zeros(dataFileNum,channelNum);
angEstSymAvg = zeros(dataFileNum,channelNum);
ampEstSymRawList = strings(dataFileNum*(symNum-1)+1,channelNum+1);
ampEstSymRawList(1,:) = ["Amp Raw Value", "ch1", "ch2", "ch3", "ch4"];
angEstSymRawList = strings(dataFileNum*(symNum-1)+1,channelNum+1);
angEstSymRawList(1,:) = ["Angle Raw Value", "ch1", "ch2", "ch3", "ch4"];
desiredPntIndexList = strings(dataFileNum*(symNum-1)+1,channelNum+1);
desiredPntIndexList(1,:) = ["Chip Index", "ch1", "ch2", "ch3", "ch4"];
for data_num = 1:dataFileNum
% read data
rawData = readmatrix(dataFile(data_num));
disp(dataFile(data_num));
seqRx = [];
seqRx(:,1) = (rawData(:, 4) + 1i*rawData(:, 5)).';
seqRx(:,2) = (rawData(:, 6) + 1i*rawData(:, 7)).';
seqRx(:,3) = (rawData(:, 8) + 1i*rawData(:, 9)).';
seqRx(:,4) = (rawData(:,10) + 1i*rawData(:,11)).';
if (dataFile(data_num).contains(["0509","0510","0511"]))
PRBS = PRBS7_polar;
else
PRBS = PRBS10_polar;
end
dataLen = length(seqRx(:,1));
chipLen = length(PRBS); % pn chip length
PRBS_up_flip = kron(flip(PRBS),ones(interp,1));
% search for frequency shift
for ch_num = 1:channelNum
for freq_num = 1:length(freqRange)
% multiply two symbols with carrier
data_cxr = seqRx(1:2*chipLen*interp,ch_num).*exp(1i*2*pi* ...
freqRange(freq_num)/fs*(0:2*chipLen*interp-1)');
% convolve multiplied data with pn sequence, without zero-padded results
data_dmf = conv(data_cxr, PRBS_up_flip,'valid');
% peak search
freqDmfPeak(data_num,freq_num) = max(abs(data_dmf(1:end-1)));
end
freqTarget(data_num,ch_num) = freqRange(freqDmfPeak(data_num,:) == ...
max(freqDmfPeak(data_num,:)));
end
% phase amplitude analysis
for ch_num = 1:channelNum
seqRxCxr = seqRx(:,ch_num).*exp(1i*2*pi*freqTarget(1)/fs*(0:dataLen-1)');
seqRxCxrCorr = conv(seqRxCxr,PRBS_up_flip,'valid');
seqRxCxrCorrSplit = reshape(seqRxCxrCorr(1:end-1),chipLen*interp, ...
symNum-1);
desiredPntIndex(data_num,:,ch_num) = find(abs(seqRxCxrCorrSplit) == ...
max(abs(seqRxCxrCorrSplit))) - 1024*(0:symNum-2)';
desiredPnt(data_num,:,ch_num) = seqRxCxrCorrSplit(abs(seqRxCxrCorrSplit) == ...
max(abs(seqRxCxrCorrSplit)));
ampEstSymRaw(data_num,:,ch_num) = abs(desiredPnt(data_num,:,ch_num))./abs(desiredPnt(data_num,:,1));
angEstSymRaw(data_num,:,ch_num) = mod((angle(desiredPnt(data_num,:,ch_num))-angle(desiredPnt(data_num,:,1)))/pi*180,360);
ampEstSymMin(data_num,ch_num) = min(ampEstSymRaw(data_num,:,ch_num));
ampEstSymMax(data_num,ch_num) = max(ampEstSymRaw(data_num,:,ch_num));
ampEstSymAvg(data_num,ch_num) = mean(ampEstSymRaw(data_num,:,ch_num));
angEstSymMin(data_num,ch_num) = min(angEstSymRaw(data_num,:,ch_num));
angEstSymMax(data_num,ch_num) = max(angEstSymRaw(data_num,:,ch_num));
angEstSymAvg(data_num,ch_num) = mean(angEstSymRaw(data_num,:,ch_num));
end
desiredPntIndexList((data_num-1)*(symNum-1)+1+(1:symNum-1),1) = dataFile(data_num);
desiredPntIndexList((data_num-1)*(symNum-1)+1+(1:symNum-1),2:end) = string(desiredPntIndex(data_num,:,:));
ampEstSymRawList((data_num-1)*(symNum-1)+1+(1:symNum-1),1) = dataFile(data_num);
ampEstSymRawList((data_num-1)*(symNum-1)+1+(1:symNum-1),2:end) = string(ampEstSymRaw(data_num,:,:));
angEstSymRawList((data_num-1)*(symNum-1)+1+(1:symNum-1),1) = dataFile(data_num);
angEstSymRawList((data_num-1)*(symNum-1)+1+(1:symNum-1),2:end) = string(angEstSymRaw(data_num,:,:));
end
%% data analysis
freqTargetRelative = freqTarget - freqTarget(:,1);
freqTargetMax = max(freqTarget,[],'all');
freqTargetMIn = min(freqTarget,[],'all');
maxDesiredPointIndexDiff = max(abs(desiredPntIndex-(desiredPntIndex(:,:,1))),[],"all");
ampEstSymMaxList = strings(dataFileNum+1,channelNum+1);
ampEstSymMinList = strings(dataFileNum+1,channelNum+1);
ampEstSymAvgList = strings(dataFileNum+1,channelNum+1);
ampEstSymMaxList(1,:) = ["Amp Max Value", "ch1", "ch2", "ch3", "ch4"];
ampEstSymMinList(1,:) = ["Amp Min Value", "ch1", "ch2", "ch3", "ch4"];
ampEstSymAvgList(1,:) = ["Amp Avg Value", "ch1", "ch2", "ch3", "ch4"];
ampEstSymMaxList(2:end,1) = dataFile;
ampEstSymMinList(2:end,1) = dataFile;
ampEstSymAvgList(2:end,1) = dataFile;
ampEstSymMaxList(2:end,2:end) = string(ampEstSymMin);
ampEstSymMinList(2:end,2:end) = string(ampEstSymMax);
ampEstSymAvgList(2:end,2:end) = string(ampEstSymAvg);
angEstSymMaxList = strings(dataFileNum+1,channelNum+1);
angEstSymMinList = strings(dataFileNum+1,channelNum+1);
angEstSymAvgList = strings(dataFileNum+1,channelNum+1);
angEstSymMaxList(1,:) = ["Angle Max Value", "ch1", "ch2", "ch3", "ch4"];
angEstSymMinList(1,:) = ["Angle Min Value", "ch1", "ch2", "ch3", "ch4"];
angEstSymAvgList(1,:) = ["Angle Avg Value", "ch1", "ch2", "ch3", "ch4"];
angEstSymMaxList(2:end,1) = dataFile;
angEstSymMinList(2:end,1) = dataFile;
angEstSymAvgList(2:end,1) = dataFile;
angEstSymMaxList(2:end,2:end) = string(angEstSymMin);
angEstSymMinList(2:end,2:end) = string(angEstSymMax);
angEstSymAvgList(2:end,2:end) = string(angEstSymAvg);
%% figures
figure(1);
subplot(121);
plot(ampEstSymAvg);
legend(["ch1","ch2","ch3","ch4"]);
title("Amplitude Estimation");
ylim([min(ampEstSymAvg,[],'all')-0.2,max(ampEstSymAvg,[],'all')+0.2]);
grid on; grid minor;
subplot(122);
plot(angEstSymAvg);
legend(["ch1","ch2","ch3","ch4"]);
title("Angle Estimation");
ylim([-10,370]);
grid on; grid minor;
% xticks([1 5 10 20])
% xticklabels(dataFile)
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:45f946e9ba49485396a79521bce99ee1999def4928b60a401a0c9a1bdd241d90
3 size 4124736
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:60c82502c83998cfe528eb9d267305c628d6b27fe67416c51ab144fff949d22b
3 size 4124715
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:c986a24af2ef089274ecfe0b44968b7323ebfb1f6e11d25892b86070ee420bb4
3 size 4124324
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:4194261c08f91f936aadf9d919bfb9a14dade1e7db0d92230e0f1593baedc62a
3 size 4122879
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:7d6db01322986db304dedebd35f8a1e375d29ffcf69cbcae12687a038e3a1d8f
3 size 4123864
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:703b9f39bd793c00926419ef6fee3b2af3152565a63f5b6227a624c95f167a8e
3 size 4125526
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:b904fcf34fc2573aeb28fc31479af0902e3d67028fdfcd127693dfe953e6789f
3 size 4115729
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:2ad2bef7b3f7404f7de722084dadc6865efc57c186aaf8ace29d5c90de4afe3d
3 size 4114968
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:0df07262102198cec4f58483ff0ae7c483ed4ac689e64488ade44f74b2f0bfb9
3 size 4117607
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:7f5d77913a78e5091991442e630d511d473252588de1332db77cd9c5906ebfd1
3 size 196859
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:cff39dfeb1f899c2cd81e2bacde5aabea7e276e47d69ff667e2e607845ce4fa1
3 size 197094
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:07654e05725ee6ff64cb32f4f1632a21a261b31046395247551f521201b85335
3 size 196524
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:17a2e298b332a8941d243dab25ec594b3a5785cfeca690c7cf43a9d859aed8f1
3 size 196437
@@ -0,0 +1,31 @@
% clear;
dataFile = [ ...
"iladata_814_sweep_20230512_1722_A.csv", ...
"iladata_814_sweep_20230512_1725_B.csv", ...
"iladata_814_sweep_20230512_1727_B.csv", ...
"iladata_814_sweep_20230512_1734_B.csv", ...
];
dataFileNum = length(dataFile);
for data_num = 1:dataFileNum
data = readmatrix(dataFile(data_num));
valid_index = find(data(:,4)==1);
peak = [ ...
data(valid_index,5) + 1i*data(valid_index,6), ...
data(valid_index,7) + 1i*data(valid_index,8), ...
data(valid_index,9) + 1i*data(valid_index,10), ...
data(valid_index,11) + 1i*data(valid_index,12)];
peak_amp = [abs(peak)./abs(peak(:,1)),abs(peak(:,1)), ...
round(data(valid_index,end-1)/2^32*192e6),data(valid_index,end)];
angleNormal = (angle(peak) - angle(peak(:,1)))/pi*180;
angleNormal(abs(angleNormal) > 5) = mod(angleNormal(abs(angleNormal) > 5),360);
peak_ang = [angleNormal, ...
abs(peak(:,1)),round(data(valid_index,end-1)/2^32*192e6),data(valid_index,end)];
scatter(peak_ang(:,7),peak_ang(:,2:4),'filled');hold on;
end
@@ -13,42 +13,26 @@
clc; clear;
%% initial parameters/初始参数
interp = 8; % interpolation factor
process_interp = 8;
channelNum = 4;
dataLen = 8192;
symNum = 8;
fs = 48e6;
freqRange = 10000:1000:28000;
dataFile = [ ...
% "iladata_rx_data_26G_20230509_1445.csv", ...
% "iladata_rx_data_26G_20230509_1715.csv", ...
"iladata_rx_data_26G_20230510_1030.csv", ...
"iladata_rx_data_26G_20230510_1100.csv", ...
"iladata_rx_data_26G_20230510_1115.csv", ...
"iladata_rx_data_26G_20230510_1415_A-1.csv", ...
"iladata_rx_data_26G_20230510_1415_A-2.csv", ...
"iladata_rx_data_26G_20230510_1415_A-3.csv", ...
"iladata_rx_data_26G_20230510_1455_B-1.csv", ...
"iladata_rx_data_26G_20230510_1455_B-2.csv", ...
"iladata_rx_data_26G_20230510_1455_B-3.csv", ...
"iladata_rx_data_26G_20230510_1500_A-1.csv", ...
"iladata_rx_data_26G_20230510_1500_A-2.csv", ...
"iladata_rx_data_26G_20230510_1500_A-3.csv", ...
"iladata_rx_data_26G_20230510_1530_B-1.csv", ...
"iladata_rx_data_26G_20230510_1530_B-2.csv", ...
"iladata_rx_data_26G_20230510_1530_B-3.csv", ...
"iladata_rx_data_26G_20230510_1600_B-1.csv", ...
"iladata_rx_data_26G_20230510_1600_B-2.csv", ...
"iladata_rx_data_26G_20230510_1630_B-1.csv", ...
"iladata_rx_data_26G_20230510_1630_B-2.csv", ...
"iladata_rx_data_26G_20230510_1630_B-3.csv", ...
"iladata_rx_data_26G_20230510_1725_B-1.csv", ...
"iladata_rx_data_26G_20230510_1725_B-2.csv", ...
"iladata_rx_data_26G_20230510_1725_B-3.csv", ...
"iladata_rx_data_26G_20230510_1730_A-1.csv", ...
"iladata_rx_data_26G_20230510_1730_A-2.csv", ...
"iladata_rx_data_26G_20230510_1730_A-3.csv", ...
"iladata_rx_data_26G_20230510_1740_B-1.csv", ...
"iladata_rx_data_26G_20230510_1740_B-2.csv", ...
"iladata_rx_data_26G_20230510_1740_B-3.csv", ...
];
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1400_A-1.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1400_A-2.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1400_A-3.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1430_B-1.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1430_B-2.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1430_B-3.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1510_A-1.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1510_A-2.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1510_A-3.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1535_B-1.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1535_B-2.csv", ...
"./基带2201005,天线2202004/iladata_rx_data_26G_20230515_1535_B-3.csv", ...
];
dataFileNum = length(dataFile);
@@ -58,13 +42,14 @@ pnSequence = comm.PNSequence('Polynomial','x^7+x^6+1', ...
PRBS7 = pnSequence();
PRBS7_polar = 1-2*[PRBS7;0];
chipLen = length(PRBS7_polar); % pn chip length
symNum = dataLen/chipLen/interp; % total symbol number
pnSequence = comm.PNSequence('Polynomial','x^10+x^7+1', ...
'InitialConditions',[zeros(1,9),1],'SamplesPerFrame',2^10-1);
PRBS10 = pnSequence();
PRBS10_polar = 1-2*[PRBS10;0];
%% data analysis
% search for frequency shift
freqRange = 22000:10:28000;
freqDmfPeak = zeros(dataFileNum,length(freqRange));
freqTarget = zeros(dataFileNum,channelNum);
@@ -92,14 +77,26 @@ desiredPntIndexList = strings(dataFileNum*(symNum-1)+1,channelNum+1);
desiredPntIndexList(1,:) = ["Chip Index", "ch1", "ch2", "ch3", "ch4"];
for data_num = 1:dataFileNum
% read data
rawData = readmatrix(dataFile(data_num));
disp(dataFile(data_num));
seqRx = [];
seqRx(:,1) = (rawData(:, 4) + 1i*rawData(:, 5)).';
seqRx(:,2) = (rawData(:, 6) + 1i*rawData(:, 7)).';
seqRx(:,3) = (rawData(:, 8) + 1i*rawData(:, 9)).';
seqRx(:,4) = (rawData(:,10) + 1i*rawData(:,11)).';
if (dataFile(data_num).contains(["0509","0510","0511"]))
PRBS = PRBS7_polar;
else
PRBS = PRBS10_polar;
end
dataLen = length(seqRx(:,1));
chipLen = length(PRBS); % pn chip length
PRBS_up_flip = kron(flip(PRBS),ones(process_interp,1));
% search for frequency shift
for ch_num = 1:channelNum
for freq_num = 1:length(freqRange)
@@ -107,7 +104,7 @@ for data_num = 1:dataFileNum
data_cxr = seqRx(1:2*chipLen*interp,ch_num).*exp(1i*2*pi* ...
freqRange(freq_num)/fs*(0:2*chipLen*interp-1)');
% convolve multiplied data with pn sequence, without zero-padded results
data_dmf = conv(data_cxr, kron(flip(PRBS7_polar),ones(interp,1)),'valid');
data_dmf = conv(downsample(data_cxr,interp/process_interp), PRBS_up_flip,'valid');
% peak search
freqDmfPeak(data_num,freq_num) = max(abs(data_dmf(1:end-1)));
end
@@ -117,9 +114,9 @@ for data_num = 1:dataFileNum
% phase amplitude analysis
for ch_num = 1:channelNum
seqRxCxr = seqRx(:,ch_num).*exp(1i*2*pi*freqTarget(1)/fs*(0:dataLen-1)');
seqRxCxrCorr = conv(seqRxCxr,kron(flip(PRBS7_polar),ones(interp,1)),'valid');
seqRxCxrCorrSplit = reshape(seqRxCxrCorr(1:end-1),chipLen*interp, ...
seqRxCxr = seqRx(:,ch_num).*exp(1i*2*pi*freqTarget(1,ch_num)/fs*(0:dataLen-1)');
seqRxCxrCorr = conv(downsample(seqRxCxr,interp/process_interp),PRBS_up_flip,'valid');
seqRxCxrCorrSplit = reshape(seqRxCxrCorr(1:end-1),chipLen*process_interp, ...
symNum-1);
desiredPntIndex(data_num,:,ch_num) = find(abs(seqRxCxrCorrSplit) == ...
@@ -149,7 +146,12 @@ for data_num = 1:dataFileNum
angEstSymRawList((data_num-1)*(symNum-1)+1+(1:symNum-1),2:end) = string(angEstSymRaw(data_num,:,:));
end
%% data analysis
freqTargetRelative = freqTarget - freqTarget(:,1);
freqTargetMax = max(freqTarget,[],'all');
freqTargetMIn = min(freqTarget,[],'all');
maxDesiredPointIndexDiff = max(abs(desiredPntIndex-(desiredPntIndex(:,:,1))),[],"all");
ampEstSymMaxList = strings(dataFileNum+1,channelNum+1);
@@ -183,14 +185,16 @@ figure(1);
subplot(121);
plot(ampEstSymAvg);
legend({"ch1","ch2","ch3","ch4"});
legend(["ch1","ch2","ch3","ch4"]);
title("Amplitude Estimation");
ylim([min(ampEstSymAvg,[],'all')-0.2,max(ampEstSymAvg,[],'all')+0.2]);
grid on; grid minor;
subplot(122);
plot(angEstSymAvg);
legend({"ch1","ch2","ch3","ch4"});
legend(["ch1","ch2","ch3","ch4"]);
title("Angle Estimation");
ylim([-10,370]);
grid on; grid minor;
% xticks([1 5 10 20])
% xticklabels(dataFile)
@@ -0,0 +1,43 @@
% clear;
dataFile = [ ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1434_A.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1436_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1437_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1439_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1441_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1502_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1503_B.csv", ...
"./基带2201005,天线2202004/iladata_duifei_sweep_20230515_1506_B.csv", ...
];
dataFileNum = length(dataFile);
for data_num = 1:dataFileNum
data = readmatrix(dataFile(data_num));
valid_index = find(data(:,4)==1);
peak_index = data(valid_index,13:16);
peak = [ ...
data(valid_index,5) + 1i*data(valid_index,6), ...
data(valid_index,7) + 1i*data(valid_index,8), ...
data(valid_index,9) + 1i*data(valid_index,10), ...
data(valid_index,11) + 1i*data(valid_index,12)];
peak_amp = [abs(peak)./abs(peak(:,1)),abs(peak(:,1)), ...
round(data(valid_index,end-1)/2^32*192e6),data(valid_index,end)];
angleNormal = (angle(peak) - angle(peak(:,1)))/pi*180;
angleNormal(abs(angleNormal) > -1) = mod(angleNormal(abs(angleNormal) > -1),360);
peak_ang = [angleNormal, ...
abs(peak(:,1)),round(data(valid_index,end-1)/2^32*192e6),data(valid_index,end)];
subplot(1,3,1);grid on; grid minor;
scatter(peak_ang(:,7),peak_ang(:,2),'filled');hold on;
subplot(1,3,2);grid on; grid minor;
scatter(peak_ang(:,7),peak_ang(:,3),'filled');hold on;
subplot(1,3,3);grid on; grid minor;
scatter(peak_ang(:,7),peak_ang(:,4),'filled');hold on;
end
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:758f8b7f400b82db3b865957e3d4df334ff814409360db8e4e6fe75b620aa71b
3 size 197836
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:af2b854fc22cef635faaba91e39278c13a7e2b0e730c7e60e5501d7c6fb29cf8
3 size 197874
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:9cee51010bfb1b1be3d4432947fa47b04361da4c43b9f24b5b16821c1d00909c
3 size 198334
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:309b825c90af469e809a921bca35f80e8fbdb596ed64eff12bfe0037c6361549
3 size 197534
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:8dd317b332f6e5894300d75abc187d40ef7d0b276d82739d4e95f6e813098226
3 size 197561
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:278b2083ac6e1807740de00b805e21da2b6bc7fff2131a9a400fae4cb142f8d4
3 size 197746
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:fab5b246e7a21e9e0f31680745e3df88d153b2abb8efaa3685b4a6e0966ec111
3 size 197203
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:238d2908540a2ae3360065d8685c6e2497a621c11c286309fdf991e544749af3
3 size 197247
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:4f307c88ab87b172ef0f1387fe8a9a8da2ae3d3c7d07da10f9773d398ade09fc
3 size 197312
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:e80eb8ff14c98b224a74f3753d19e42b8817eee881264bed747aea0e7373b624
3 size 196618
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:a5f7bac79b72784e096baa8e7723cf184126976a080d8ac08890d91cbaf6cf3d
3 size 197952
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:47d9cbffb0dcc644749c42dfdcc5b44b147af7d3d8a09e12289b347873cb912e
3 size 196436
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:1056adb08736e6513afa228f53e578a70ec176e4e4fbd3b279679217d48a8c66
3 size 197109
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:820327513706d95ab2217839b88b2100d00cdcedf22c1f836cba829f1fabbfb9
3 size 196917
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:48b871d92d243e0aa5a663ad01be63c5805dbc771a448c4b29449ee761b5e359
3 size 4113817
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:9bd7295e606710adb6b97446aa5769e67ae331dcf5cfa1155b6bb5381b606515
3 size 4116658
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:2654ebc6ca4ef2d5e6895d09972021dcd6aecedb4003fcd9636b95edc192fe2d
3 size 4122912
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:56da511be1ce30989433c2e9be3772fa5cbae170763edac6c638b28093a3be36
3 size 4117588
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:07c3699b018ba2a6ca2c4cc1262c2baf63a8a908e090edf2017893e02d931dac
3 size 4122646
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:1010e68dff95032038f060eb8243e627748a159be4433516b4a9333c3d03b9c9
3 size 4118766
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:c28c821741590b04ef9cd9f5286a17a79882f3aef5d83c776f44443ecba8a534
3 size 4118539
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:c7e747a74b72d5ec8a3dcb38e0d2c57f9371a483b1771a40010b53b66d47b2e8
3 size 4118817
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:12eae949a174393566cecf75a26b2aa6e301a695d760cd8956964f9384e5aa4c
3 size 4118673
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:939b7ba42208f27286a9aaed03d3a63dd01021ee4ac3f9443b59e293a29246bb
3 size 4121196
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:e72a3a748abe0e5d9ae2c87ca4a3b6fb891569fddfb2a379fb888d9bf96525ba
3 size 4112020
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:f99917041931d608719f95e127332d79388250d15fab08a64d4dcf7a3d882735
3 size 4114755
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:755c77a82f817dd88a8991b8eee8440ac745f952e928e8c1a1268eb3ae3642eb
3 size 197107
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:df9124d56f7078e9a23d5789a9a938a173af880ec5e89e0dd7e9b93518538adb
3 size 196327
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:0e788eb20b50c5d2dd2542874b27cb1c6b5309bd042815883efb0f216ad66928
3 size 197144
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:843505a4d1a31ac63779e5f0a0de2f3785852e53678f0d8c38eb1fec35d66652
3 size 196131
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:eb6833264f1ca0d609fa9b08d577a3d218271cad9812d20058928b0fbbf39420
3 size 196993
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:9528a64720c1f1174b4d60442a57e816933b96be05afc9ce936a4858e7d0b5f8
3 size 196195
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:1fdba1c15c391a5af0d4df3bdb3d699f845e47914e80dc405c95f120561743d5
3 size 195929
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:037fe648964efb54b1c6ca528f3cdd1e31c50b3e610a2bcd81739857e7f1a5de
3 size 196251
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:3a1942edd07ba014528a60dcedc0de73a5243989bb708c52d1c71702aada82ec
3 size 196196
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:bbcb0fe6a998ccbececeec70d97d288591e2e4f2a461d9911a199a26e05c784a
3 size 4058996
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:f94bc26fbfced2bd2f9ffe73b5cc3f911e53422ec6ba70f5a7279b668673c314
3 size 4059307
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:61875c6285060bc448fb3caa5d6220b7836be4b8a3a903268473212712eff104
3 size 4059233
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:8df996767b08c48319557df34c5ac38f3dfbfa73282fe0fbc1ce053679336c52
3 size 4053757
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:425bb8ada3a223fc2b9c4c7cd0f4b5586fab6eceaa541ff715d887c4e5d70828
3 size 4052901
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:6c08cbdcfc9a54113a810fd9b1000d0a0c4c3feb2f0432f942b37a15ceeaca57
3 size 4052587
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:28e36833868fdfe54cf264731fb7f7351f9363b8c8ff0bf88da7ecf357775938
3 size 4055999
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:1d24d06c592ffeea1fde32a669869fe729a76264086fa2af6a842769065594c2
3 size 4057265
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:6062b7f52bdafc1ebf5f76c2ef8e0849be79247dbda5b5df59efda1b421b5a99
3 size 4055922
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:29250aca12129aa76d057db0252afec4376a6f057e15180f4b29984148bfea8b
3 size 4052882
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:b5f90922e0bb49d40c63bb3060de800d52471eefd3e6ff39870e09e877751b9d
3 size 4055455
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:7b5b38c253ffb58c96e940e20424b120fec3d76e15feb8ae4a1ff8df75722483
3 size 4054625
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:d8562a9b4a0550f1269f9a85552c46a49c4173b379f55b1b07b1daf6351bb542
3 size 197418
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:80637baae8780a3f017a76dbd3f8f9669165378b2a8bd7ec8a01cc87a3ad58b4
3 size 197459
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:942d3d458a2da34f122ead5d352a804bdf24ed25fabb4ef36f62cbd6e9256a2a
3 size 197786
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:59b5303d199ad58e6eb3a3866b47f929736a66ba0a74adce54c3ecbc2b235965
3 size 197444
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:3f165540b8c8ac9d530853d36a6122f75e1e5cb8d4831f92e7d4d781c8ddf6ce
3 size 197654
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:896674e53f6acac5ec0483bda7e57bfa1174f2b2a22c996dabfde406241095c2
3 size 198127
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:27b477d7b6dfe223f711abbe457e31df9ff2e69e491f39bdc74bea8b9864a9f9
3 size 4129390
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:d7d3faceae5257c54c0a0f6464a79dc5b34e37534ad50d8b37f5e790fe9fad06
3 size 4130427
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:344ae7714b8e39acf1d4a61f18d7a351483777c00ab8554187d3087eedd1b11d
3 size 4128348
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:1a787f0a436f96af4f05fc5e5c1618028e1a49f55cb9b2b7a76546abda3c0d79
3 size 4132189
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:86f4fa9e8bba4819deeef8446a696723235f821afd3e6d1e40cc4a1f87bcf320
3 size 4130991
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:686069394a439d1040e8b3740947ea133a3e25a9b037eea4e3eebe6c5ae351a7
3 size 4128788
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:934b2f921c0bb26a9c01de613a786af12d7a0a2ebad6c435975f68354d853864
3 size 4130897
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:d23bac7b17dc5a71088411e169ec8e253beba8a2ec10b47bfe98fa57aef184fb
3 size 4128863
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:cbc701698146136ada073b62f4d3a6fbc771ecbf7499692cf871b3a05d68bb67
3 size 4128473
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:d87392f31a43883ec3622b3e8a5b1188c605f67e9e5bd3eb54415e196156f732
3 size 4130379
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:7f5bc444d4f845f48ac514e874186f57f49be2bed3fdd6e5fcca97feb1ea1352
3 size 4130609
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:0168b55b588579d298e53c853360445c188330da444f2881c4fd731caea93ae4
3 size 4129838
@@ -0,0 +1,123 @@
%% 幅相测试结果离线导出
clc; clear;
%% 初始参数
captureNum = 2; % 同一频点捕获数
channelNum = 4;
% freqnum = 90; % 频点
% dataLen = captureNum*freqnum;
dataFile = "0508/iladata_freq_comp_3.csv";
sys_clk = 48e6; % 系统时钟
phase_width = 32; % 频率控制字总长度
%% data analysis
rx_string = readmatrix(dataFile,'OutputType','string'); % 含有字符串的矩阵,便于根据STATE确定数据位置
rxdata = readmatrix(dataFile);
ch1_dmf = [];
ch2_dmf = [];
ch3_dmf = [];
ch4_dmf = [];
ch1_begin = [];
ch2_begin = [];
ch3_begin = [];
ch4_begin = [];
pinc = [];
% 找出ch1~ch4进行captureNum次DMF输出的相关峰序列、每次DMF开始时对应的采样序号
% 和每次DMF补偿频偏的频率控制字
for k = 1 : length(rx_string(:,1))
if (rx_string(k,13) == 'STATE_CH1')
ch1_dmf = [ch1_dmf rxdata(k,12)];
if(rx_string(k-1,13) == 'STATE_CH_SW')
ch1_begin = [ch1_begin;k];
pinc = [pinc;rxdata(k+1,17)];
end
elseif (rx_string(k,13) == 'STATE_CH2')
ch2_dmf = [ch2_dmf rxdata(k,12)];
if(rx_string(k-1,13) == 'STATE_CH_SW')
ch2_begin = [ch2_begin;k];
end
elseif (rx_string(k,13) == 'STATE_CH3')
ch3_dmf = [ch3_dmf rxdata(k,12)];
if(rx_string(k-1,13) == 'STATE_CH_SW')
ch3_begin = [ch3_begin;k];
end
elseif (rx_string(k,13) == 'STATE_CH4')
ch4_dmf = [ch4_dmf rxdata(k,12)];
if(rx_string(k-1,13) == 'STATE_CH_SW')
ch4_begin = [ch4_begin;k];
end
end
end
% 对DMF序列以捕获次数分行
ch1_dmf = (reshape(ch1_dmf,[length(ch1_dmf)/captureNum,captureNum])).';
ch2_dmf = (reshape(ch2_dmf,[length(ch2_dmf)/captureNum,captureNum])).';
ch3_dmf = (reshape(ch3_dmf,[length(ch3_dmf)/captureNum,captureNum])).';
ch4_dmf = (reshape(ch4_dmf,[length(ch4_dmf)/captureNum,captureNum])).';
ch1_max = zeros(captureNum,1);
ch2_max = zeros(captureNum,1);
ch3_max = zeros(captureNum,1);
ch4_max = zeros(captureNum,1);
ch1_pos = zeros(captureNum,1);
ch2_pos = zeros(captureNum,1);
ch3_pos = zeros(captureNum,1);
ch4_pos = zeros(captureNum,1);
% 找出DMF输出相关峰后半段序列中最大峰对应序号
for kk = 1:captureNum
[ch1_max(kk),ch1_pos(kk)] = max(ch1_dmf(kk,ceil(length(ch1_dmf(kk,:))/2):end));
[ch2_max(kk),ch2_pos(kk)] = max(ch2_dmf(kk,ceil(length(ch2_dmf(kk,:))/2):end));
[ch3_max(kk),ch3_pos(kk)] = max(ch3_dmf(kk,ceil(length(ch3_dmf(kk,:))/2):end));
[ch4_max(kk),ch4_pos(kk)] = max(ch4_dmf(kk,ceil(length(ch4_dmf(kk,:))/2):end));
ch1_pos(kk) = ch1_pos(kk) + ceil(length(ch1_dmf(kk,:))/2) - 1;
ch2_pos(kk) = ch2_pos(kk) + ceil(length(ch2_dmf(kk,:))/2) - 1;
ch3_pos(kk) = ch3_pos(kk) + ceil(length(ch3_dmf(kk,:))/2) - 1;
ch4_pos(kk) = ch4_pos(kk) + ceil(length(ch4_dmf(kk,:))/2) - 1;
end
% 计算ch2~ch4相关峰相对于ch1偏移的位置。ch_begin为DMF序列在ila中的开始位置,
% pos为DMF序列中最大值的位置,相加为最大值在整个ila中的决定位置。插值为载波偏移的采样点数
ch2_pos_shift = (ch2_pos + ch2_begin) - (ch1_pos + ch1_begin);
ch3_pos_shift = (ch3_pos + ch3_begin) - (ch1_pos + ch1_begin);
ch4_pos_shift = (ch4_pos + ch4_begin) - (ch1_pos + ch1_begin);
% 计算频偏补偿载波的(频率/fs)
f_out = 2 * pi * pinc / (2^phase_width);
% 计算串行捕获带来的相位偏移
ch2_phase_comp = ch2_pos_shift .* f_out;
ch3_phase_comp = ch3_pos_shift .* f_out;
ch4_phase_comp = ch4_pos_shift .* f_out;
PeakValue_ch1 = [];
PeakValue_ch2 = [];
PeakValue_ch3 = [];
PeakValue_ch4 = [];
% 根据ch_peak_valid信号找到硬件捕获点的信号
for kkk = 1:length(rx_string(:,1))
if(rxdata(kkk,16) == 1)
PeakValue_ch1 = [PeakValue_ch1 (rxdata(kkk+1, 4) + 1i*rxdata(kkk+1, 5))]; % 用rxdata(kkk, 4)+1i*rxdata(kkk, 5)也可以
PeakValue_ch2 = [PeakValue_ch2 (rxdata(kkk+1, 6) + 1i*rxdata(kkk+1, 7))];
PeakValue_ch3 = [PeakValue_ch3 (rxdata(kkk+1, 8) + 1i*rxdata(kkk+1, 9))];
PeakValue_ch4 = [PeakValue_ch4 (rxdata(kkk+1, 10) + 1i*rxdata(kkk+1, 11))];
end
end
% 计算相对ch1偏移的相位(考虑串行捕获导致的频偏校准载波相位偏移)
for kkkk = 1:captureNum
angleEstSym(kkkk,1) = mod((angle(PeakValue_ch2(kkkk))-angle(PeakValue_ch1(kkkk))-ch2_phase_comp(kkkk))/pi*180,360);
angleEstSym(kkkk,2) = mod((angle(PeakValue_ch3(kkkk))-angle(PeakValue_ch1(kkkk))-ch3_phase_comp(kkkk))/pi*180,360);
angleEstSym(kkkk,3) = mod((angle(PeakValue_ch4(kkkk))-angle(PeakValue_ch1(kkkk))-ch4_phase_comp(kkkk))/pi*180,360);
end
disp("考虑串行捕获导致的频偏校准载波相位偏移时")
angleEstSym
% 计算相对ch1偏移的相位(不考虑串行捕获导致的频偏校准载波相位偏移)
for kkkk = 1:captureNum
angleEstSym(kkkk,1) = mod((angle(PeakValue_ch2(kkkk))-angle(PeakValue_ch1(kkkk)))/pi*180,360);
angleEstSym(kkkk,2) = mod((angle(PeakValue_ch3(kkkk))-angle(PeakValue_ch1(kkkk)))/pi*180,360);
angleEstSym(kkkk,3) = mod((angle(PeakValue_ch4(kkkk))-angle(PeakValue_ch1(kkkk)))/pi*180,360);
end
disp("不考虑串行捕获导致的频偏校准载波相位偏移时")
angleEstSym
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:e3bea3832fcafad6d5a8e8301edca50766255d5b3e23a48f5ec7eeb79f2ad5e7
3 size 8167635
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:2271b48373846a592036898a6153298fd6c0cf6ef8da8229cc352ddfeb7a4d2a
3 size 8298707
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:b71e2bbc234f12b8ee84d79dc6897484ab8bb621545e34e73a200585de3cd566
3 size 8432030
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:0d987515d60dc246850be1ef35b1da40da286d9ce932010f45c7d0eb15d8f140
3 size 8624509
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:d267036b58987df25df089bc2f094064bbf5f9912845947ec47a987693f42563
3 size 417917
@@ -0,0 +1,108 @@
%% File Header/文件说明
%
% Beamforming with phased array derives signal characteristics from phase
% differences between sensors. Therefore the amplitude-phase consistence is
% vital to phased systems.
%
% The script analyzes the amp-phase relations of ILA captured data, the format
% of which is square-shaped pseudorandorm bit sequence. Each channel is
% processed seperately with different frequency shifts and different optimum
% sampling points. The estimation of amplitude and phase are based on
% acculumated correlation peaks.
%
clc; clear;
%% initial parameters/初始参数
interp = 8; % interpolation factor
channelNum = 4;
dataLen = 8192;
fs = 48e6;
dataFile = "0508/iladata_rx_data.csv";
% standard pn sequence
pnSequence = comm.PNSequence('Polynomial','x^7+x^6+1', ...
'InitialConditions',[zeros(1,6),1],'SamplesPerFrame',2^7-1);
PRBS7 = pnSequence();
PRBS7_polar = 1-2*[PRBS7;0];
chipLen = length(PRBS7_polar); % pn chip length
symNum = dataLen/chipLen/interp; % total symbol number
symNumPerAccum = 1; % symbol nbumber of each accumulation
accNum = symNum/symNumPerAccum; % total accumulation numbers, i.e. peak numbers
%% data analysis
% read data, and swap ch1 and ch2, because loop data locate at ch2 and ch4
rxdata = readmatrix(dataFile);
seqRx(:,1) = (rxdata(:, 4) + 1i*rxdata(:, 5)).';
seqRx(:,2) = (rxdata(:, 6) + 1i*rxdata(:, 7)).';
seqRx(:,3) = (rxdata(:, 8) + 1i*rxdata(:, 9)).';
seqRx(:,4) = (rxdata(:,10) + 1i*rxdata(:,11)).';
% compensate frequecny deviation and downsample at optimum sample position based
% on the varience of constellation
if dataFile.contains("loop")
[seqRxDown,fd,samplePos] = suqareShapeFreqEst(seqRx,interp,fs,-50,50,5);
else
[seqRxDown,fd,samplePos] = suqareShapeFreqEst(seqRx,interp,fs,-30000,30000,100);
end
% split [seqRxDown] into multiple groups, each group contains several symbols to
% be correlated with PRBS7 and accumulated
seqRxDownSplit = reshape(seqRxDown(1:dataLen/interp,:),chipLen*symNumPerAccum,accNum,channelNum);
seqRxAcc = zeros(chipLen,accNum,channelNum);
desiredPnt = zeros(accNum,channelNum);
ampEstSym = zeros(accNum,channelNum);
angleEstSym = zeros(accNum,channelNum);
for i = 1:accNum
for j = 1:channelNum
% correlation & multi-symbol accumulation
groupCorrAcc = sum(reshape(conv(flip(seqRxDownSplit(:,i,j)), ...
PRBS7_polar,'same'),chipLen,symNumPerAccum),2)';
seqRxAcc(:,i,j) = groupCorrAcc;
% peak position
desiredPnt(i,j) = groupCorrAcc(abs(groupCorrAcc)==max(abs(groupCorrAcc)));
end
end
for i = 1:channelNum
ampEstSym(:,i) = abs(desiredPnt(:,i))./abs(desiredPnt(:,1));
angleEstSym(:,i) = mod((angle(desiredPnt(:,i))-angle(desiredPnt(:,1)))/pi*180,360);
end
%% figures
figure(1);
if dataFile.contains("loop")
subplot(121);
plot(ampEstSym(:,[1,4]));
legend({"ch1","ch4"});
title("Amplitude Estimation");
ylim([min(ampEstSym(:,[1,4]),[],'all')-0.1,max(ampEstSym(:,[1,4]),[],'all')+0.1])
subplot(122);
plot(angleEstSym(:,[1,4]));
legend({"ch1","ch4"});
title("Angle Estimation");
ylim([min(angleEstSym(:,[1,4]),[],'all')-10,max(angleEstSym(:,[1,4]),[],'all')+10])
else
subplot(121);
plot(ampEstSym);
legend({"ch1","ch2","ch3","ch4"});
title("Amplitude Estimation");
ylim([min(ampEstSym,[],'all')-0.2,max(ampEstSym,[],'all')+0.2])
subplot(122);
plot(angleEstSym);
legend({"ch1","ch2","ch3","ch4"});
title("Angle Estimation");
ylim([min(angleEstSym,[],'all')-10,max(angleEstSym,[],'all')+10])
end
phase_sym = (360 - mean(angleEstSym))/180;
phase = fix(phase_sym * (2^9));
angleEstSym
@@ -0,0 +1,50 @@
function [dataOut, fdTarget, samplePosTarget] = suqareShapeFreqEst(dataIn, interp, fs, fmin, fmax, fd)
%suqareShapeFreqEst - 利用星座图的集中程度在一定频率范围内使用频率步进估计方波成形信号的频偏
%
% data - input complex data, row vector
% dataLen - data length
% interp - interpolation rate
% fs - sampling rate, in Herts
% fmin - minimum estimation frequency, in Herts
% fmax - maximum estimation frequency, in Herts
% fd - estimation frequency step, in Herts
% dimension
[dataLen,channelNum] = size(dataIn);
freqList = fmin:fd:fmax;
freqNum = length(freqList);
varRecord = zeros(freqNum,interp);
dataOut = zeros(dataLen/interp,channelNum);
fdTarget = zeros(channelNum,1);
samplePosTarget = zeros(channelNum,1);
for channel = 1:channelNum
for freq = 1:freqNum
% carrier
cxr = exp(-1i*2*pi*freqList(freq)/fs*(0:dataLen-1)');
% apply frequency shift onto input data
seqRx = dataIn(:,channel).*cxr;
for samplePos = 0:interp-1
seqRxDown = downsample(seqRx,interp,samplePos); % 下采样
seqRxDownQuaterOne = abs(real(seqRxDown)) + 1i*abs(imag(seqRxDown)); % 集中到第一象限
varRecord(freq,samplePos+1) = var(seqRxDownQuaterOne);
end
end
[fdIndex, samplePosIndex] = find(varRecord==min(min(varRecord)));
fdTarget(channel) = freqList(fdIndex);
samplePosTarget(channel) = samplePosIndex-1;
cxrTarget = exp(-1i*2*pi*fdTarget(channel)/fs*(0:dataLen-1)');
seqRxTarget = dataIn(:,channel).*cxrTarget;
dataOut(:,channel) = downsample(seqRxTarget,interp,samplePosTarget(channel));
end
end
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:8a74c0a5147602c4f8369423abe68648696c486b74d16fce636882436e5777de
3 size 7871347
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:810fd6c47e59d084dca2690b69bde4ca14866501ace1f952ea419ec6282f2ed8
3 size 3193
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:ee80b2aa846060b37ba0a481e1adb1216e877abd029023f398d3d2db5e9bb271
3 size 2070131
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:9300925b681203acb43b82f6a3255039d7e59ea51f8f1c7a3a819335a78f7a76
3 size 2088788
Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:98c4e8fa9faeb1ca46f960652d4c5abdde8057f2504d30b7642b8a288747d409
3 size 2135399

Some files were not shown because too many files have changed in this diff Show More