Files
imdd_silas/projects/FSO_transmission/Evaluation Scripts/evalscript_pam_2_20G.m
magf 3676d92b30 +++ Changes +++
+ duobinary_target now supports memoryless decoding (FFE targets DB response without MLSE)
+ PAMmapper.quantize now supports custom constellations for quantization
+ Added a new folder 'Documentations' for pdfs, slides, etc.
+ Added new FSO evaluation scripts in projects/FSO transmission/Evaluation Scripts
+ Added ffe_db (rudimentary module, not important anymore)
2026-03-05 10:41:36 +01:00

149 lines
4.7 KiB
Matlab

%%
M = 4;
current = 255;
power = [8.4, 8.4, 42.3, 8.4, 8.4, 8.4, 8.4];
rolloff = 0.6;
baudrate = 4:1:10;
baudrate_e = ["4e9", "5e9", "6e9", "7e9", "8e9", "9e9", "1e10"];
num_pf_coeff = 4;
taps_ffe = [300, 0, 0];
taps_dfe = [0, 0, 0];
trlength = 4096*4;
filter_length = 210;
x = 4:1:10;
num_currents = length(x);
num_signals = 18;
num_eq_methods = 4;
BER_PAM_2 = zeros(num_currents,num_signals);
save_name = "BER_PAM_4_Waitbar_Test";
% ---------------- Progressbar Setup ----------------
totalRuns = num_eq_methods * num_currents * num_signals;
runCount = 0;
h = waitbar(0, 'Starte Simulation...', 'Name', 'FSO Simulation Progress');
tStart = tic;
% Optional: nur alle N Schritte UI updaten (reduziert Overhead)
updateEvery = 1; % z.B. 10 setzen, wenn es extrem viele Iterationen werden
% ---------------------------------------------------
try
for eq_method = 1:1:4
num_current_iteration = 1;
for i = 1:num_currents
for num_signal = 1:1:num_signals
% --- Dein eigentlicher Run ---
try
BER_run = first_analysis_fso(current, power(i), baudrate(i), baudrate_e(i), rolloff, ...
num_pf_coeff, taps_ffe, taps_dfe, M, trlength, eq_method, filter_length, num_signal);
catch
BER_run = NaN;
end
BER_PAM_2(num_current_iteration, num_signal) = BER_run;
% -----------------------------
% --- Progress updaten ---
runCount = runCount + 1;
if mod(runCount, updateEvery) == 0 || runCount == 1 || runCount == totalRuns
frac = runCount / totalRuns;
elapsed = toc(tStart);
if frac > 0
remaining = elapsed * (1/frac - 1);
else
remaining = NaN;
end
msg = sprintf(['EQ %d/4 | i %d/%d | Signal %d/%d\n' ...
'Gesamt %d/%d (%.1f %%) | ETA ~ %.1f min'], ...
eq_method, i, num_currents, num_signal, num_signals, ...
runCount, totalRuns, 100*frac, remaining/60);
waitbar(frac, h, msg);
% Falls jemand das waitbar-Fenster schließt: sauber abbrechen
if ~ishandle(h)
error('Progressbar wurde geschlossen. Abbruch durch Nutzer.');
end
end
% ------------------------
end
num_current_iteration = num_current_iteration + 1;
end
save('C:\Users\magf\Desktop\Desktop\Projekte\FSO\Data\' + save_name + "_" + string(eq_method) + '.mat', 'x', 'BER_PAM_2')
BER_PAM_2 = zeros(num_currents, num_signals);
end
catch ME
% Falls irgendwas schiefgeht: waitbar schließen und Fehler weiterwerfen
if exist('h','var') && ishandle(h)
close(h);
end
rethrow(ME);
end
% Clean exit
if exist('h','var') && ishandle(h)
close(h);
end
%%
x = 4:1:10;
save_name = "BER_PAM_4_Waitbar_Test";
figure(202120); clf; hold on; grid on;
for k = 1:4
BER_min = zeros(1,length(x));
BER_avg = zeros(1,length(x));
BER_max = zeros(1,length(x));
tmp = load('C:\Users\magf\Desktop\Desktop\Projekte\FSO\Data\' + save_name + "_" + string(k) + '.mat');
BER = tmp.BER_PAM_2;
for i = 1:length(x)
BERs = BER(i,:);
BER_min(i) = min(BERs);
BER_avg(i) = mean(BERs);
BER_max(i) = max(BERs);
end
err_low = BER_avg - BER_min;
err_high = BER_max - BER_avg;
errorbar(x, BER_avg, err_low, err_high, '-o', 'LineWidth', 1.75);
end
old_BER = [-1.5, -1.75, -2, -2.3, -2.6, -2.25, -1.95];
old_BER = 10.^(old_BER);
plot(x, old_BER, '-o','LineWidth',1.75)
h1 = yline(2e-2, ':k', 'LineWidth',1.5);
h2 = yline(3.8e-3,':b', 'LineWidth',1.5);
h3 = yline(4.85e-3,':g', 'LineWidth',1.5);
h4 = yline(2.2e-4,':r', 'LineWidth',1.5);
% Legende NUR für Kurven
legend('FFE', 'FFE+PF+MLSE', 'DB', 'ML-MLSE', 'BER Paper', ...
'Interpreter','latex', ...
'Location','southwest', 'FontSize', 14)
% FEC Labels direkt im Plot
text(221,2.2e-2,'o-FEC','Color','k','FontSize', 14, 'Interpreter','latex')
text(221,3.3e-3,'HD-FEC','Color','b','FontSize', 14, 'Interpreter','latex')
text(221,5.4e-3,'KP4+Hamming','Color','g','FontSize', 14,'Interpreter','latex')
text(231,2.4e-4,'KP4','Color','r','FontSize', 14,'Interpreter','latex')
xlabel('Laser Bias Current [mA]', 'Interpreter','latex')
ylabel('BER', 'Interpreter','latex')
% title('BER for PAM-2', 'Interpreter','latex')
grid minor
ylim([1e-4 5e-1])
set(gca,'YScale','log')
% beautifyBERplot
hold off