diff --git a/setup_simulation.m b/setup_simulation.m index 6528500..4f89514 100644 --- a/setup_simulation.m +++ b/setup_simulation.m @@ -9,11 +9,11 @@ for lp = 1 %% A) Set Simulation Variables sir = -18; - delay = 10; %mpi delay in meter + delay = 50; %mpi delay in meter fiblen = 0; %main link in km - laser_linewidth =5e6; + laser_linewidth =1e6; O = 18; %order of prbs N = 2^(O-1); %length of prbs @@ -72,8 +72,8 @@ for lp = 1 eq = EQ("K",2,"plottrain",0,"plotfinal",0,... "training_length",4096,"training_loops",2,... - "Ne",[50,5,3],"Nb",[3,2,2],... - "DCmu",0.05,"DDmu",[0.0004 0.0005 0.0006 0.0007 ],"DFEmu",0.005,"FFEmu",0.005,... + "Ne",[50,5,3],"Nb",[3,0,0],... + "DCmu",0.05,"DDmu",[0.0004 0.0005 0.0006 0.0007 ],"DFEmu",0.005,"FFEmu",0.00,... "dd_loops",2,"epsilon",[10 100 1000 ],"M",2,... "thres",[0.005 0.004 0.0005 ],"l1act",0,"delay",0,"rho",0.0005,"ideal_dfe",0,"DB_aim",0); @@ -128,51 +128,53 @@ for lp = 1 % Delay the reflected signal [R,n] = R.delay("delay_meter",delay); -% % Add together -% col = cbrewer2('qual','Paired',8); -% -% xax = (1:X.length);% / fsimu * (physconst("LightSpeed")/1.4677); -% xax_mtr = (1:X.length) / fsimu * (physconst("LightSpeed")/1.4677); -% thresh = 0.7; -% phaseX = phase(X.signal); -% phaseR = phase(R.signal); -% phasediff = wrapToPi(phaseX-phaseR); -% [pos_high] = find(abs(phasediff)>thresh); -% [pos_low] = find(abs(phasediff)<=thresh); -% -% figure() -% subplot(3,1,1) -% scatter(xax_mtr,wrapToPi(phaseX),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','Phase of original Signal') -% hold on -% scatter(xax_mtr,wrapToPi(phaseR),4,'.','MarkerEdgeColor',col(7,:),'DisplayName','Phase of delayed Signal') -% hold on -% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off') -% lg = legend; -% lg.Location = "southwest"; -% -% subplot(3,1,2) -% scatter(xax_mtr(pos_low),phasediff(pos_low),4,'.','MarkerEdgeColor',col(6,:),'DisplayName','Phase Difference') -% hold on -% scatter(xax_mtr(pos_high),phasediff(pos_high),4,'.','MarkerEdgeColor',col(4,:),'HandleVisibility','off') -% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off') -% yline(thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off') -% yline(-thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off') -% lg = legend; -% lg.Location = "southwest"; + % Add together + col = cbrewer2('qual','Paired',8); - X = X+R; + xax = (1:X.length);% / fsimu * (physconst("LightSpeed")/1.4677); + xax_sec = (1:X.length) / fsimu .* 1e6;%* (physconst("LightSpeed")/1.4677); + xax_sec = xax_sec(n:end).'; + thresh = pi/4; + phaseX = phase(X.signal(n:end)); + phaseR = phase(R.signal(n:end)); + phasediff = wrapToPi(phaseX-phaseR); + [pos_high] = find(abs(phasediff)>thresh); + [pos_low] = find(abs(phasediff)<=thresh); -% subplot(3,1,3) -% scatter(xax_mtr(pos_low),abs(X.signal(pos_low).^2),4,'.','MarkerEdgeColor',col(6,:),'DisplayName','Constructive Interference'); -% hold on -% scatter(xax_mtr(pos_high),abs(X.signal(pos_high).^2),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','Destructive Interference'); -% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off') -% -% lg = legend; -% lg.Location = "southwest"; + figure() + subplot(3,1,1) + scatter(xax_sec.',wrapToPi(phaseX),4,'.','MarkerEdgeColor',col(2,:),'DisplayName','Phase of original Signal') + hold on + scatter(xax_sec,wrapToPi(phaseR),4,'.','MarkerEdgeColor',col(1,:),'DisplayName','Phase of delayed Signal') + hold on +% xline(delay/(physconst("LightSpeed")/1.4677),'LineWidth',4,'LineStyle','--','HandleVisibility','off') + lg = legend; + lg.Location = "southwest"; + + subplot(3,1,2) + scatter(xax_sec(pos_low),phasediff(pos_low),4,'.','MarkerEdgeColor',col(5,:),'DisplayName','Phase Difference') + hold on + scatter(xax_sec(pos_high),phasediff(pos_high),4,'.','MarkerEdgeColor',col(2,:),'HandleVisibility','off') +% xline(delay/(physconst("LightSpeed")/1.4677),'LineWidth',4,'LineStyle','--','HandleVisibility','off') + yline(thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off') + yline(-thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off') + lg = legend; + lg.Location = "southwest"; X.signal = X.signal(n:end); R.signal = R.signal(n:end); + X = X+R; + + subplot(3,1,3) + scatter(xax_sec(pos_low),abs(X.signal(pos_low).^2),4,'.','MarkerEdgeColor',col(5,:),'DisplayName','Constructive Interference'); + hold on + scatter(xax_sec(pos_high),abs(X.signal(pos_high).^2),4,'.','MarkerEdgeColor',col(2,:),'DisplayName','Destructive Interference'); +% xline(delay/(physconst("LightSpeed")/1.4677),'LineWidth',4,'LineStyle','--','HandleVisibility','off') + + lg = legend; + lg.Location = "southwest"; + + disp(['SIR ',num2str(10*log10(X.power/R.power))]); @@ -214,7 +216,7 @@ for lp = 1 Eq_in.signal = Eq_in.signal - 1/wl .* movsum( Eq_in.signal,[wl/2,wl/2]); % Equalize Signal - [Eq_out] = eq2.process(Eq_in,digimod_out); + [Eq_out] = eq.process(Eq_in,digimod_out); @@ -379,5 +381,5 @@ for lp = 1 end - +end