Update April
This commit is contained in:
198
projects/MPI_April/mpi_simulation_cspr.m
Normal file
198
projects/MPI_April/mpi_simulation_cspr.m
Normal file
@@ -0,0 +1,198 @@
|
||||
%% Settings
|
||||
clear
|
||||
|
||||
filename = '112G_2';
|
||||
load_sequence = 0;
|
||||
|
||||
M = 4;
|
||||
datarate = 112e9;
|
||||
|
||||
kover = 8;
|
||||
fsym = round(datarate*1e-9 / log2(M))*1e9;
|
||||
%fsym = 50e9;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
|
||||
laser_linewidth = 1e6;
|
||||
mpi_ = 50; %meter
|
||||
sir = 20; %decibel = attenuation of interference path
|
||||
|
||||
lowpass_cutoff = fsym/2 * 1;
|
||||
awg_bw = lowpass_cutoff;
|
||||
mod_bw = lowpass_cutoff;
|
||||
phd_bw = lowpass_cutoff;
|
||||
scp_bw = lowpass_cutoff;
|
||||
|
||||
mpi_path=50;
|
||||
|
||||
vp = [0.25];
|
||||
vb = [0.5:0.05:0.8];
|
||||
vb = 0.7;
|
||||
pn_key = [27];
|
||||
rop = -5;
|
||||
|
||||
LP_awg = Filter('filtdegree',2,"f_cutoff",awg_bw,"fs",fdac,"filterType","butterworth");
|
||||
LP_laser = Filter('filtdegree',4,"f_cutoff",mod_bw,"fs",fdac*kover,"filterType",filtertypes.gaussian);
|
||||
LP_opt = Filter('filtdegree',4,"f_cutoff",fsym/log2(M).*1.5,"fs",fdac*kover,"filterType",filtertypes.gaussian);
|
||||
LP_phd = Filter('filtdegree',2,"f_cutoff",phd_bw,"fs",fdac*kover,"filterType",filtertypes.butterworth);
|
||||
LP_scpe = Filter('filtdegree',2,"f_cutoff",scp_bw,"fs",fadc,"filterType","butterworth");
|
||||
|
||||
for pnk = 1:length(pn_key)
|
||||
for m = 1:length(vb)
|
||||
if load_sequence
|
||||
|
||||
load(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_April\',filename,'.mat'],'X');
|
||||
|
||||
spectrum_plot(X.signal',X.fs,'spectrum');
|
||||
else
|
||||
|
||||
% 1) PRBS Generation
|
||||
O = 17; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
bitpattern=[];
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = PAMmapper(M,0).map(bits);
|
||||
digimod_out.fs = fsym;
|
||||
|
||||
X = Pulseformer("fsym",fsym,"fdac",fdac,"pulse","rrc","pulselength",16,"rrcalpha",0.01).process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
%X = M8196A().process(X);
|
||||
kover = 16;
|
||||
X = AWG("fdac",fdac,"dac_min",-1,"dac_max",1,"H_lpf",LP_awg,"kover",kover).process(X);
|
||||
|
||||
% 6) Lowpass behavior before laser
|
||||
X = LP_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
|
||||
%save(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_April\',char(filename)],'X');
|
||||
end
|
||||
|
||||
% 1) Laser; Modulation -> OPTICAL DOMAIN
|
||||
u_pi = 2;
|
||||
vbias = -vb(m)*u_pi;
|
||||
extmodlaser = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",X.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",pn_key(pnk));
|
||||
E = X.*vp(1);
|
||||
[Opt,extmodlaser] = extmodlaser.process(E);
|
||||
|
||||
% figure(m)
|
||||
% hold on
|
||||
% scatter(E.signal(1:100000),(abs(Opt.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF')
|
||||
% xlabel('Input in V')
|
||||
% ylabel('abs(Output) in mW')
|
||||
|
||||
Opt = LP_opt.process(Opt);
|
||||
|
||||
cspr(m) = Opt.cspr;
|
||||
|
||||
% 2) ping pong fiber propagation
|
||||
Interference_sig = Fiber("fsimu",Opt.fs,"fiber_length",mpi_path*2/1000,"alpha",0,"D",0,"lambda0",1310,"gamma",0).process(Opt);
|
||||
|
||||
Interference_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",-sir).process(Interference_sig);
|
||||
|
||||
% In the meantime: delay the main signal
|
||||
[Main_sig,n] = Opt.delay("delay_meter",mpi_path*2);
|
||||
|
||||
% Add
|
||||
Combined_sig = Main_sig + Interference_sig;
|
||||
|
||||
% Cut (due to the delays there is a jump in the signals)
|
||||
if n == 0;n = 1;end
|
||||
Combined_sig.signal = Combined_sig.signal(ceil(n):end);
|
||||
|
||||
% Fiber
|
||||
Combined_sig = Fiber("fsimu",Combined_sig.fs,"fiber_length",0,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.08).process(Combined_sig);
|
||||
|
||||
for i = 1:length(rop)
|
||||
|
||||
% Set ROP
|
||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",rop(i)).process(Combined_sig);
|
||||
rop_save(m,i) = Rx_sig.power;
|
||||
|
||||
% Square Law
|
||||
Rx_sig = Photodiode("fsimu",Rx_sig.fs,"dark_current",2e-08,"responsivity",1,"temperature",20).process(Rx_sig);
|
||||
|
||||
%Lowpass PhDiode
|
||||
Rx_sig = LP_phd.process(Rx_sig);
|
||||
|
||||
% Scope
|
||||
Rx_sig = Scope("fsimu",Rx_sig.fs,"fadc",fadc,...
|
||||
"delay",0,"fixed_delay",0,"lpf_bw",scp_bw,"filtertype",filtertypes.butterworth,...
|
||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
||||
"adcresolution",16,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',LP_scpe).process(Rx_sig);
|
||||
|
||||
% Sample to 2x fsym
|
||||
Rx_sig = Rx_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
||||
|
||||
% Sync Rx signal with reference
|
||||
[Rx_sig,D,cuts] = Rx_sig.tsynch("reference",digimod_out,"fs_ref",fsym);
|
||||
|
||||
% % simple EQ (optimum mudc: 0.05 -> 0.005)
|
||||
EQ_sig = EQ_silas_plain("Ne",[20,8,8],"Nb",[2,0,0],"trainlength",4096,"mu_dc_dd",0.005,"mu_dc_train",0.05,...
|
||||
"mu_ffe_train",0.005,"mu_combined_dd",[0.0004 0.0006 0.0003 0.005],"ddloops",3,'trainloops',3,'sps',2).process(Rx_sig,digimod_out);
|
||||
|
||||
% Demap
|
||||
Rx_Bits = PAMmapper(M,0).demap(EQ_sig);
|
||||
|
||||
Rx_symboldecision = PAMmapper(M,0).decide_pamlevel(EQ_sig,"symbol_levels",unique(digimod_out.signal));
|
||||
|
||||
levels = PAMmapper(M,0).separate_pamlevels(EQ_sig);
|
||||
level_avg(:,m,i) = mean(levels,'omitnan');
|
||||
level_std(:,m,i) = std(levels,'omitnan');
|
||||
|
||||
% BER
|
||||
[~,errors_bm,BER(m,i),errors] = calc_ber(Rx_Bits.signal,bitpattern,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
|
||||
|
||||
formatted_ber = sprintf('%.1e', BER(m,i));
|
||||
disp(formatted_ber);
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
plot_analysis_window;
|
||||
save(['C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\MPI\Investigation_April_2024\','PAM_',num2str(M),'_mpi_',num2str(mpi_path),'_lw_',num2str(laser_linewidth)],"BER");
|
||||
|
||||
% BER plot
|
||||
figure(340)
|
||||
cols = linspecer(7);
|
||||
for m = 1:size(BER,1)
|
||||
hold on
|
||||
plot(rop,BER(m,:),'DisplayName',['Bias: ',num2str(vb(m)), ' V'],'LineStyle','-','Color',cols(m,:),'LineWidth',1,'Marker','o','MarkerEdgeColor',[1 1 1],'MarkerFaceColor',cols(m,:));
|
||||
|
||||
end
|
||||
set(gca,'YScale','log');
|
||||
legend
|
||||
xlabel("ROP in dBm")
|
||||
yline(3.8e-3,'DisplayName','FEC');
|
||||
|
||||
|
||||
figure(21)
|
||||
hold on
|
||||
plot(rop,mean(BER),'DisplayName',['Modulation: ',num2str(2*vp/extmodlaser.u_pi*100), ' $\%$'],'LineStyle','-','Color',cols(2,:),'LineWidth',1);
|
||||
set(gca,'YScale','log');
|
||||
legend
|
||||
ylabel("ROP in dBm")
|
||||
yline(3.8e-3,'DisplayName','FEC');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%check Rx and TX symbols
|
||||
figure(101)
|
||||
scatter(1:100,Rx_symboldecision.signal(1:100),10,'o');
|
||||
hold on
|
||||
scatter(1:100,digimod_out.signal(1:100),5,'x');
|
||||
70
projects/MPI_April/plot_analysis_window.m
Normal file
70
projects/MPI_April/plot_analysis_window.m
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
%straight outta workspace, show everything I want
|
||||
|
||||
cols = linspecer(8);
|
||||
colpairs = cbrewer2('paired',8);
|
||||
|
||||
f=figure(20);
|
||||
clf(f)
|
||||
f.Name="Optspec";
|
||||
%Spectrum of Optical Signal after superposition
|
||||
subplot(3,2,1:2)
|
||||
spectrum_plot(Combined_sig.normalize("mode","rms").signal',Combined_sig.fs,'Optspec',['Papr: ',num2str(Combined_sig.papr), '; CSPR: ',num2str(Combined_sig.cspr)]);
|
||||
hold on
|
||||
ylim([-100,0]);
|
||||
|
||||
%Phase Investigation
|
||||
subplot(3,2,3)
|
||||
hold on
|
||||
phase_int = extmodlaser.phase(n:end);
|
||||
phase_main = delayseq(extmodlaser.phase,n);
|
||||
phase_main = phase_main(n:end);
|
||||
phase_diff = phase_int - phase_main;
|
||||
t = (1:length(phase_int))' ./ extmodlaser.fsimu ;
|
||||
plot(t*1e6,phase_int,'Color',colpairs(1,:),'DisplayName','Interferer Phase');
|
||||
plot(t*1e6,phase_main,'Color',colpairs(2,:),'DisplayName','Signal Phase (delayed)');
|
||||
plot(t*1e6,phase_diff,'Color',colpairs(4,:),'DisplayName','Delta Phase');
|
||||
legend
|
||||
|
||||
subplot(3,2,4)
|
||||
%Received Signal after Phdiode
|
||||
yyaxis left
|
||||
t = (1:Rx_sig.length)' ./ Rx_sig.fs;
|
||||
scatter(t*1e6,Rx_sig.normalize("mode","oneone").signal.*max(unique(digimod_out.signal)),1,'.','MarkerEdgeColor',cols(5,:));
|
||||
hold on
|
||||
errors_t = errors./Rx_Bits.fs;
|
||||
errors_sym = Rx_symboldecision.signal(errors);
|
||||
scatter(errors_t*1e6,errors_sym,2,'x','LineWidth',1);
|
||||
yline(PAMmapper(M,0).thresholds);
|
||||
|
||||
%Again: Phase Diff
|
||||
yyaxis right
|
||||
t = (1:length(phase_int))' ./ extmodlaser.fsimu ;
|
||||
plot(t*1e6,phase_diff,'Color',colpairs(4,:),'DisplayName','Delta Phase');
|
||||
|
||||
title(['Lwidth:',num2str(laser_linewidth) ,'; SIR: ', num2str(sir) ,'dB; ROP: ',num2str(rop(i)),' dBm'])
|
||||
xlabel('t in $\mu$s')
|
||||
legend
|
||||
|
||||
%Equalized Signal
|
||||
subplot(3,2,5)
|
||||
t = (1:EQ_sig.length)' ./ EQ_sig.fs;
|
||||
for h = 1:size(levels,2)
|
||||
scatter(t*1e6,levels(:,h),1,'.');
|
||||
hold on
|
||||
end
|
||||
yline(PAMmapper(M,0).thresholds);
|
||||
title(['BER: ',sprintf('%.1e', BER(m,i))]);
|
||||
|
||||
%Histogram of EQzed Signal
|
||||
subplot(3,2,6)
|
||||
for h = 1:size(levels,2)
|
||||
std_dev = std(levels(:,h),'omitnan');
|
||||
mean_val = mean(levels(:,h),'omitnan');
|
||||
hold on
|
||||
histogram(levels(:,h),1000,"EdgeColor","none","Normalization","pdf");
|
||||
text(mean_val, 0.1, ['$\sigma^2:$ ',sprintf('%.2f', std_dev)], 'HorizontalAlignment', 'center');
|
||||
end
|
||||
hold on
|
||||
xline(PAMmapper(M,0).thresholds);
|
||||
xticks(sort([unique(digimod_out.signal);PAMmapper(M,0).thresholds']));
|
||||
55
projects/MPI_April/simulate_tx_sig.m
Normal file
55
projects/MPI_April/simulate_tx_sig.m
Normal file
@@ -0,0 +1,55 @@
|
||||
function simulate_tx_sig(filename)
|
||||
|
||||
%% Params
|
||||
M=4;
|
||||
digimod = PAMmapper(M,0);
|
||||
|
||||
fdac = 120e9;
|
||||
fsym = 112e9;
|
||||
pulseform = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.027);
|
||||
|
||||
kover = 16;
|
||||
awg = AWG('fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5);
|
||||
%awg = M8199B();
|
||||
|
||||
lp_laser = Filter('filtdegree',2,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.butterworth);
|
||||
|
||||
|
||||
|
||||
%% PROCESS TX
|
||||
|
||||
% 1) PRBS Generation
|
||||
O = 20; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = digimod.map(bits);
|
||||
|
||||
% 4) Pulse shaping -> racos
|
||||
X = pulseform.process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
X = awg.process(X);
|
||||
|
||||
% 6) Lowpass behavior before laser
|
||||
X = lp_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
X.signal = X.signal;
|
||||
|
||||
spectrum_plot(X.signal',X.fs,'spectrum');
|
||||
|
||||
if nargin == 1
|
||||
save(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\',char(filename)],'X');
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user