From 637dd7bc86ac1a891a5a4d82ea301b57818b861f Mon Sep 17 00:00:00 2001 From: sioe Date: Wed, 16 Oct 2024 11:14:15 +0200 Subject: [PATCH] start ofc analysis --- Classes/01_transmit/ChannelFreqResp.m | 18 +-- projects/Lab_2024/bias_sweep_evaluation.m | 4 +- projects/Lab_2024/bias_sweep_evaluation_2.m | 12 +- .../offline_dsp_analysis/load_n_dsp.m | 117 ++++++++++++++++++ 4 files changed, 136 insertions(+), 15 deletions(-) create mode 100644 projects/Lab_2024/offline_dsp_analysis/load_n_dsp.m diff --git a/Classes/01_transmit/ChannelFreqResp.m b/Classes/01_transmit/ChannelFreqResp.m index 75960f3..fe644a6 100644 --- a/Classes/01_transmit/ChannelFreqResp.m +++ b/Classes/01_transmit/ChannelFreqResp.m @@ -207,24 +207,28 @@ classdef ChannelFreqResp < handle Havg = obj.H; %1) - subplot(4,1,1);hold all;box on;title('Magnitude Freq. Response'); + subplot(2,1,1);hold all;box on;title('Magnitude Freq. Response'); plot(obj.faxis/1e9, 20*log10(abs(obj.H_all)),'linewidth',0.1,'LineStyle','-','Color','#808080') ; xlim([0.2 .5*max(obj.faxis)*1e-9]); plot(obj.faxis/1e9, 20*log10(abs(Havg)),'LineWidth',2); grid on; %2) - subplot(4,1,2); hold all; box on; title('Phase Freq. Response'); - plot(obj.faxis/1e9, (angle(obj.H_all)),'linewidth',0.1,'LineStyle','-','Color','#808080') ; - plot(obj.faxis/1e9, (angle(Havg)),'LineWidth',2) ; + subplot(2,1,2); hold all; box on; title('Phase Freq. Response'); + plot(obj.faxis/1e9, angle(obj.H_all),'linewidth',0.1,'LineStyle','-','Color','#808080') ; + plot(obj.faxis/1e9, unwrap(angle(Havg)),'LineWidth',2) ; xlim([0.2 .5*max(obj.faxis)*1e-9]); grid on; + figure(56); + clf; + + %normalize / remove attenuation Havg = Havg./mean(Havg(2:10)); %3) - subplot(4,1,3); hold all; box on; title('Inverse Magnitude Freq. Response'); + subplot(2,1,1); hold all; box on; title('Inverse Magnitude Freq. Response'); plot(obj.faxis/1e9, 20*log10(abs(1./Havg)),"LineWidth",2,"Color",[0.3467 0.5360 0.6907]) ; xlim([0.2 .5*max(obj.faxis)*1e-9]); grid on; ylim([-1 15]); @@ -232,8 +236,8 @@ classdef ChannelFreqResp < handle yline(3,'LineWidth',2,'LineStyle','--'); %4) - subplot(4,1,4); hold all; box on; title('Inverse Phase Freq. Response'); - plot(obj.faxis/1e9, (angle(1./Havg)),"LineWidth",2,"Color",[0.3467 0.5360 0.6907]) ; + subplot(2,1,2); hold all; box on; title('Inverse Phase Freq. Response'); + plot(obj.faxis/1e9, unwrap(angle(1./Havg)),"LineWidth",2,"Color",[0.3467 0.5360 0.6907]) ; xlim([0.2 .5*max(obj.faxis)*1e-9]); grid on; diff --git a/projects/Lab_2024/bias_sweep_evaluation.m b/projects/Lab_2024/bias_sweep_evaluation.m index 08ffcac..46ebf62 100644 --- a/projects/Lab_2024/bias_sweep_evaluation.m +++ b/projects/Lab_2024/bias_sweep_evaluation.m @@ -1,6 +1,6 @@ -filename = "C:\Users\sioe\Nextcloud\Dokumente\02_Ablage_Office\Lab_Data_24\bias_sweep\PAM6_10km_ffe__wh.mat"; +filename = "C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\Lab_Data_24\bias_sweep\PAM4_10km_ffe__wh.mat"; a = load(filename); wh2 = a.obj; @@ -80,7 +80,7 @@ scatter(bestvbias,bestawgvpp,100,"red",'Marker','x','LineWidth',2); subplot2 = subplot(1,2,2); % Plot the filled contour plot -contourf_handle = contourf(v_bias_vals, awg_vpp_vals, rop_measured, 'Parent', subplot2); +contourf_handle = contourf(v_bias_vals, awg_vpp_vals, rop_measured, 'Parent', subplot2,"ShowText",true); % Set x and y labels xlabel('V_{bias}'); diff --git a/projects/Lab_2024/bias_sweep_evaluation_2.m b/projects/Lab_2024/bias_sweep_evaluation_2.m index c310afd..31f8d07 100644 --- a/projects/Lab_2024/bias_sweep_evaluation_2.m +++ b/projects/Lab_2024/bias_sweep_evaluation_2.m @@ -1,6 +1,6 @@ -filename = "C:\Users\sioe\Nextcloud\Dokumente\02_Ablage_Office\Lab_Data_24\bias_sweep_gigantisch\wh_pam4.mat"; +filename = "C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\Lab_Data_24\bias_sweep_gigantisch\wh_pam6.mat"; a = load(filename); wh2 = a.wh; @@ -8,7 +8,7 @@ wh2 = a.wh; v_bias_vals = wh2.parameter.vbias.values; awg_vpp_vals = wh2.parameter.awg_vpp.values; eq_mode_vals = wh2.parameter.eq_mode.values; -eq_mode_show = eq_mode_vals(2); +eq_mode_show = eq_mode_vals(3); eq_modes = ["FFE","FFE+MLSE","DB precoded","DB encoded"]; precomp_amp_max_vals = wh2.parameter.precomp_amp_max.values; @@ -22,7 +22,7 @@ sgtitle(['PAM ', num2str(m),' | EQ: ', char(eq_modes(eq_mode_show))]) for p = 1:numel(precomp_amp_max_vals) precomp_amp_max_show = precomp_amp_max_vals(p); - subplot1 = subplot(2,3,p); + subplot1 = subplot(1,3,p); bers = []; rop_measured = []; @@ -38,7 +38,7 @@ for p = 1:numel(precomp_amp_max_vals) bestawgvpp=awg_vpp_vals(awg_pos); bestvbias=v_bias_vals(v_bias_pos); - disp(['Best Vpp: ',num2str(bestvbias),' V; Best Vpp AWG: ',num2str(bestawgvpp),' V' ]) + disp(['Best Vbias: ',num2str(bestvbias),' V; Best Vpp AWG: ',num2str(bestawgvpp),' V' ]) % Compute the logarithm of BER data % Adding a small epsilon to avoid log(0) @@ -53,8 +53,8 @@ for p = 1:numel(precomp_amp_max_vals) contourf_handle = contourf(v_bias_vals, awg_vpp_vals, log_bers, 'Parent', subplot1, "ShowText",true,"LabelFormat", @mylabelfun); % Set x and y labels with subscripts for clarity - xlabel('V_{bias}'); - ylabel('V_{pp} AWG'); + xlabel('V_{bias}','Interpreter','tex'); + ylabel('V_{pp} AWG','Interpreter','tex'); title(['Prec. Ampl.: ',num2str(precomp_amp_max_show), 'dB']); % Adjust the grid to display white lines diff --git a/projects/Lab_2024/offline_dsp_analysis/load_n_dsp.m b/projects/Lab_2024/offline_dsp_analysis/load_n_dsp.m new file mode 100644 index 0000000..6e8c897 --- /dev/null +++ b/projects/Lab_2024/offline_dsp_analysis/load_n_dsp.m @@ -0,0 +1,117 @@ + +% load data points + +foldername = 'C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\Lab_Data_24\sir_sweep_pam4'; +filename = 'PAM4_10km'; + +stuff = load([foldername,filesep,filename,'_wh']); +wh = stuff.obj; +i_atten_vals = wh.parameter.i_atten.values; +v_bias = wh.parameter.vbias.values(1); +awg_vpp = wh.parameter.awg_vpp.values(1); +eq_mode = wh.parameter.eq_mode.values(1); + + + +% Tx Bits +% Tx Symbols +% Rx Signal + +Bits = load([foldername, filesep, filename, '_bits'],'Bits'); +Bits = Bits.Bits; +Symbols = load([foldername, filesep, filename, '_symbols_92gbd'],'Symbols'); +Symbols = Symbols.Symbols; + +Eq = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1); + + +for atten = 0:4:40 + Signal_cell = load([foldername, filesep, filename, '_rx_signal_iatten_',num2str(atten)]); + Scpe_sig = Signal_cell.S{1}; + + bers = wh.getStoValue('ber',v_bias,awg_vpp,eq_mode,atten); + + + [EQ_sig] = Eq.process(Scpe_sig,Symbols); + + EQ_sig.plot("fignum",50,"displayname",'After EQ','clear',1); + + Noi = EQ_sig-Symbols; + + Rx_bits = PAMmapper(M,0).demap(EQ_sig); + [~,errors_bm,ber_ffe_only,errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1); + + nc = 2; + burg_coeff = arburg(Noi.signal,nc); + + EQ_sig = EQ_sig.filter(burg_coeff,1); + + if 1 + Noi.spectrum('displayname','Noise PSD','fignum',123) + [h,w] = freqz(1,burg_coeff,length(Noi),"whole",Noi.fs); + h = h/max(abs(h)); + hold on + w_ = (w - Noi.fs/2); + plot(w_.*1e-9,20*log10(fftshift(h)),'DisplayName',['', num2str(nc), ' coefficients for burg alg.']); + end + + if 0 + figure(53); + constellation = unique(Symbols.signal); + received = NaN(numel(constellation),length(Symbols)); + for lvl = 1:numel(constellation) + received(lvl,Symbols.signal==constellation(lvl)) = EQ_sig.signal(Symbols.signal==constellation(lvl)); + hold on + histogram(received(lvl,:),1000,"EdgeAlpha",0); + end + end + + EQ_sig = MLSE("DIR",burg_coeff,"duobinary_output",0,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig); + + Rx_bits = PAMmapper(M,0).demap(EQ_sig); + [~,errors_bm,ber,errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1); + + disp(['FFE: ',sprintf('%.1E',ber_ffe_only),' -> PF -> MLSE: ',sprintf('%.1E',ber),' dB | PD_in: ',num2str(pd_in),' dBm']); + +end + + + + +cols = linspecer(8); + +i_atten_vals = wh.parameter.i_atten.values; +v_bias = wh.parameter.vbias.values(1); +awg_vpp = wh.parameter.awg_vpp.values(1); +eq_mode = wh.parameter.eq_mode.values(1); + +bers = wh.getStoValue('ber',v_bias,awg_vpp,eq_mode,i_atten_vals); + +figure(90); +hold on; % Retain the plot so new points can be added without complete redraw + +% Plot the data and get the line handle +hLine = plot(i_atten_vals, bers, "LineWidth", 0.5, "LineStyle", "-", "Marker", ".", "MarkerSize", 15, "DisplayName", 'nbla'); + +% Customize the data tips +% Set labels for existing data tip rows +hLine.DataTipTemplate.DataTipRows(1).Label = 'Fsym'; +hLine.DataTipTemplate.DataTipRows(2).Label = 'BER'; +hLine.DataTipTemplate.DataTipRows(2).Format = '%.2e'; % Format BER as "3e-4" + + +% Continue with the rest of your plot settings +yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off'); +xlabel('Signal to Interference Ratio in dB'); +ylabel('Bit Error Rate (BER)'); +title('Bit Error Rate vs. SIR'); +set(gca, 'yscale', 'log'); +set(gca, 'Box', 'on'); +grid on; +grid minor; +legend('Interpreter', 'none'); + + +autoArrangeFigures(3,3,2) + +disp("measurement done") \ No newline at end of file