commit old stuff from lab

This commit is contained in:
Silas Labor Zizou
2025-04-16 09:55:32 +02:00
28 changed files with 728 additions and 60 deletions

View File

@@ -5,7 +5,7 @@ databasePath = 'Z:\2025\ECOC Silas\';
databasePath = 'C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
database_name = 'ecoc2025_loops.db';
db = DBHandler("pathToDB", [databasePath, database_name],"type","sqlite");
db = DBHandler("pathToDB", [databasePath, database_name],"type","mysql");
num_occ = 30;
run_par = true;

View File

@@ -230,7 +230,6 @@ for occ = 1:record_realizations
fprintf("BER DB: %.2e \n",dbenc_package{occ}.resultsDBsignaling.BER);
end

View File

@@ -4,9 +4,9 @@
savePath = 'Z:\2025\ECOC Silas\ecoc_2025\';
databasePath = 'C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
database_name = 'ecoc2025_loops.db';
% db = DBHandler("pathToDB", [databasePath, database_name],"type","sqlite");
db = DBHandler("type","mysql");
num_occ = 1;
db = DBHandler("pathToDB", [databasePath, database_name],"type","mysql");
% db = DBHandler("type","mysql");
num_occ = 5;
run_par = false;
run_id = 2589;
[out, ~] = submit_dsp(run_id, databasePath, database_name, savePath,"parallel",run_par,'max_occurences',num_occ);
run_id = 1958;
[out, future] = submit_dsp(run_id, databasePath, database_name, savePath,"parallel",run_par,'max_occurences',num_occ);

View File

@@ -8,14 +8,14 @@ end
precomp_path = "C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\";
precomp_fn = "precomp_1km_1mm_cable_70ghz_pd_shf_t850_2p8_bias_shot2";
precomp_mode = 2; %0=do nothing ; 1= measure; 2=precomp active
run_lab_automation = 1;
run_lab_automation = 0;
%% Configuration
conf = confRequest;
referenceFields = fieldnames(db.tables.Configurations);
assert(isequal(fieldnames(conf), referenceFields), 'Fieldnames do not match the reference structure!');
% assert(isequal(fieldnames(conf), referenceFields), 'Fieldnames do not match the reference structure!');
%% Lab Automation
@@ -41,24 +41,65 @@ if run_lab_automation
end
voa.set('value',[0,conf.pd_in_desired,conf.signal_attenuation,conf.interference_attenuation]);
if voa.power_state(3) > -24 || voa.power_state(1)+ voa.atten_state(4) > -38
if voa.power_state(3) > -24 || voa.power_state(1)+ voa.atten_state(4) > -37
holdAndShowValue
end
% PDFA
if ~exist('pdfa','var')
pdfa = Thor_PDFA("safety_mode",0,"serialport_number",'COM15');
end
% Construct AWG and Scope Modules %%%%%%
fdac = 224e9;
fadc = 160e9;
Scp = ScopeKeysight("model","DSAZ634A",'autoscale',0,"fadc","GSa_160","channel",[0,0,1,0],"recordLen",recordlen,"removeDC",1,"extRef",1);
Awg = AwgKeysight("model","M8199A_ILV","fdac",fdac,"scaletodac",[1,1],"skews",[0,0],"voltages",[0,conf.v_awg]);
A2S = Awg2Scope(Awg,Scp,[0,0,3,0],"waitUntilClick",0);
end
% if conf.symbolrate == 72e9
% if conf.pam_level == 2
% conf.v_awg = 0.55;
% conf.pulsef_alpha = 0.6;
% elseif conf.pam_level == 4
% conf.v_awg = 0.55;
% conf.pulsef_alpha =0.6;
% elseif conf.pam_level == 6
% conf.v_awg = 0.55;
% conf.pulsef_alpha = 0.6;
% elseif conf.pam_level == 8
% conf.v_awg = 0.55;
% conf.pulsef_alpha = 0.6;
% end
% elseif conf.symbolrate == 96e9
% if conf.pam_level == 2
% conf.v_awg = 0.8;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 4
% conf.v_awg = 0.8;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 6
% conf.v_awg = 0.8;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 8
% conf.v_awg = 0.8;
% conf.pulsef_alpha = 0.2;
% end
% elseif conf.symbolrate == 112e9
% if conf.pam_level == 2
% conf.v_awg = 0.85;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 4
% conf.v_awg = 0.85;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 6
% conf.v_awg = 0.85;
% conf.pulsef_alpha = 0.2;
% elseif conf.pam_level == 8
% conf.v_awg = 0.85;
% conf.pulsef_alpha = 0.2;
% end
% end
awg_upload_required = 1;
if any(confPrev.pam_level == conf.pam_level) && any(confPrev.symbolrate == conf.symbolrate)
awg_upload_required = 0;
end
%% Signal generation and transmission
if awg_upload_required || isempty(loop_id)
@@ -69,6 +110,13 @@ if awg_upload_required || isempty(loop_id)
sequence_order = min(18,sequence_order);
end
% Construct AWG and Scope Modules %%%%%%
fdac = 224e9;
fadc = 160e9;
Scp = ScopeKeysight("model","DSAZ634A",'autoscale',0,"fadc","GSa_160","channel",[0,0,1,0],"recordLen",recordlen,"removeDC",1,"extRef",1);
Awg = AwgKeysight("model","M8199A_ILV","fdac",fdac,"scaletodac",[1,1],"skews",[0,0],"voltages",[0,conf.v_awg]);
A2S = Awg2Scope(Awg,Scp,[0,0,3,0],"waitUntilClick",0);
Pamsource = PAMsource(...
"fsym",conf.symbolrate,"M",conf.pam_level,"order",sequence_order,"useprbs",1,...
"fs_out",fdac,...
@@ -79,11 +127,11 @@ if awg_upload_required || isempty(loop_id)
"randkey",1,...
"duobinary_mode", conf.db_mode);
conf.pam_source = Pamsource;
confPrev = conf;
[Digi_sig,Symbols,Bits] = Pamsource.process();
figure(10);clf;
Digi_sig.spectrum("displayname",'Tx Pulse Shaped','fignum',10,'normalizeTo0dB',1);
%%%%% Precompensation Routine %%%%%%
if precomp_mode == 1 % measure channel
@@ -94,11 +142,13 @@ if awg_upload_required || isempty(loop_id)
Digi_sig = precomp_est.precomp(Digi_sig,'maxampdb',conf.precomp_amp,'loadPath',precomp_path,'fileName',precomp_fn);
end
% Digi_sig.spectrum("displayname",'Tx Spectrum','fignum',10,'normalizeTo0dB',0);
Digi_sig.spectrum("displayname",'Tx Pre-Emphasized','fignum',10,'normalizeTo0dB',1);
%%%%% Resample to DAC rate %%%%%%
Digi_sig = Digi_sig.resample("fs_out",Awg.fdac);
Digi_sig.spectrum("displayname",'Tx Resampled','fignum',10,'normalizeTo0dB',1);
% [~,~,Scpe_sig_raw,~] = A2S.process("signal2",Digi_sig);
Awg.upload("signal2",Digi_sig);
@@ -113,6 +163,8 @@ if precomp_mode == 1
return; % End routine if precomp mode is active
end
confPrev = conf;
%% Save static TX data (only once)
currentTime = datetime('now', 'Format', 'yyyyMMdd_HHmmss');
timeStr = char(currentTime);
@@ -142,7 +194,7 @@ for recIdx = 1:n_recording
end
% Plot spectrum and time domain (optional)
% Scpe_sig_raw.spectrum("displayname", 'Rx Spectrum', 'fignum', 10, 'normalizeTo0dB', 0);
Scpe_sig_raw.spectrum("displayname", 'Rx Spectrum', 'fignum', 10, 'normalizeTo0dB', 0);
Scpe_sig_raw.plot("clear", 1, "displayname", 'Rx Signal', 'fignum', 11);
%% Save Routine
@@ -153,7 +205,6 @@ for recIdx = 1:n_recording
rx_raw_path = [filesep, current_folder, filesep, filename, '_rx_signal_raw'];
save([savePath, rx_raw_path], "Scpe_sig_raw");
% Check if loop_id is already created
if isempty(loop_id)
newLoop = db.tables.LoopControl;
@@ -165,7 +216,6 @@ for recIdx = 1:n_recording
fprintf('LoopControl entry created: loop_id = %d\n', loop_id);
end
%% Append to Runs Table
newRun = db.tables.Runs;
newRun.run_id = NaN;
@@ -183,6 +233,8 @@ for recIdx = 1:n_recording
%% Append to Configurations Table
conf.configuration_id = NaN;
conf.run_id = run_id;
conf.bitrate = conf.symbolrate .* floor(log2(6)*10)/10;
conf.pam_source = Pamsource;
db.appendToTable('Configurations', conf);
%% Append to Measurements Table
@@ -210,6 +262,11 @@ for recIdx = 1:n_recording
[out, a] = submit_dsp(run_id, databasePath, database_name, savePath, ...
"parallel", parallel_dsp, "max_occurences", max_occurences);
end
if awg_upload_required
[out, a] = submit_dsp(run_id, databasePath, database_name, savePath, ...
"parallel", 0, "max_occurences", 1);
end
end
end

View File

@@ -2,7 +2,7 @@
basePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
database_name = 'ecoc2025.db';
database = DBHandler("pathToDB", [basePath, database_name]);
database = DBHandler("pathToDB", [basePath, database_name],"type",'mysql');
filterParams = database.tables;
filterParams.Configurations = struct( ...

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,15 @@
%% Laser
start_wavelength = 1550;
laser = Exfo_laser("mainframe_channel",3,"safety_mode",0,"connection_id",'10','lab_interface','gpib');
laser.getLaserInfo();
laser.setWavelength(start_wavelength)
laser.setPower(0);
laser.enableLaser();
for l = 1550:1560
laser.setWavelength(l);
end
laser.disableLaser();

View File

@@ -0,0 +1,74 @@
clear all
visastring = "GPIB0::22::INSTR";
v_pwrmtr = visadev(visastring);
writeline(v_pwrmtr, "*IDN?");
answ = readline(v_pwrmtr);
disp(['Yay! We can talk to Instrument: ',char(answ)]);
% laser = Exfo_laser("mainframe_channel",3,"safety_mode",0,"connection_id",'15','lab_interface','gpib');
% laser.getLaserInfo();
L = OptLaserN7714A("GPIB0::20::INSTR");
% visastring = 'GPIB0::10::INSTR';
% v_lsr = visadev(visastring);
% writeline(v_lsr, "*IDN?");
% answ = readline(v_lsr);
% disp(['Yay! We can talk to Instrument: ',char(answ)]);
steps = 100;
wavelength_sweep = linspace(1554,1556,steps);
start_wavelength = wavelength_sweep(1);
% laser.setWavelength(start_wavelength);
L.setWavelength(start_wavelength,0);
% laser.setPower(0);
% laser.enableLaser();
L.setPower(0, true,0);
pwr_save = NaN(size(wavelength_sweep));
for l = 1:numel(wavelength_sweep)
% 1)
% laser.setWavelength(wavelength_sweep(l));
L.setWavelength(wavelength_sweep(l),0);
%writeline(v_lsr, ['L=' num2str(wavelength_sweep(l))]);
% 2) Set Wavelength of Power Meter
t = string(['SENS2:POW:WAVE ',num2str(wavelength_sweep(l)),'NM']);
writeline(v_pwrmtr, t);
% writeline(v, "SENS:POW:WAVE?");
% wavel = readline(v);
% 3) Read Power of
writeline(v_pwrmtr, "READ2:POW?");
pwr = readline(v_pwrmtr);
pwr_save(l) = str2num(pwr);
figure(2025);clf
plot(wavelength_sweep,pwr_save,'Marker','*');
xlabel('Wavelength [nm]');
ylabel('Insertion Loss [dB]');
ylim([min(pwr_save)-1, min(pwr_save)+1]);
xlim([wavelength_sweep(1) wavelength_sweep(end)])
grid minor
end
% laser.disableLaser();
L.setPower(0, false,0);
L.delete();
%writeline(v_lsr, 'DISABLE');
path= "Z:\2025\NFT WDM DFG Olaf\lambda_vs_power";
dt = datetime('now','Format','yyyyMMdd_HHmmss');
filename = fullfile(path, "loop_5_7_"+num2str(wavelength_sweep(1)) +"nm_to_"+ num2str(wavelength_sweep(end))+ "nm_" + string(dt) + ".mat");
save(filename, "pwr_save","wavelength_sweep");
disp("Saved to: " + filename);

View File

@@ -0,0 +1,61 @@
clear all
%%%%%%%%%%%%%%%%%%%%%
start_wavelength = 1554.2; %nm
stop_wavelength = 1555.7; %nm
steps = 100;
power = 0; %dBm
name = "south_board_total_loss_ports_21_20";
%%%%%%%%%%%%%%%%%%%%%
wavelength_sweep = linspace(start_wavelength,stop_wavelength,steps);
wavelength_1 = wavelength_sweep(1);
visastring = "GPIB0::22::INSTR";
v_pwrmtr = visadev(visastring);
%writeline(v_pwrmtr, "*IDN?");
%answ = readline(v_pwrmtr);
%disp(['Yay! We can talk to Instrument: ',char(answ)]);
L = OptLaserN7714A("GPIB0::20::INSTR");
L.setWavelength(wavelength_1,0);
L.setPower(power, true,0);
pwr_save = NaN(size(wavelength_sweep));
for l = 1:numel(wavelength_sweep)
% 1)
L.setWavelength(wavelength_sweep(l),0);
% 2) Set Wavelength of Power Meter
t = string(['SENS1:POW:WAVE ',num2str(wavelength_sweep(l)),'NM']);
writeline(v_pwrmtr, t);
% 3) Read Power of
writeline(v_pwrmtr, "READ1:POW?");
pwr = readline(v_pwrmtr);
pwr_save(l) = str2num(pwr);
figure(2026);clf
plot(wavelength_sweep,pwr_save,'Marker','*');
xlabel('Wavelength [nm]');
ylabel('Insertion Loss [dB]');
ylim([min(pwr_save)-1, max(pwr_save)+1]);
xlim([wavelength_sweep(1) wavelength_sweep(eind)])
grid minor
end
L.setPower(0, false,0);
L.delete();
path= "Z:\2025\NFT WDM DFG Olaf\lambda_vs_power";
dt = datetime('now','Format','yyyyMMdd_HHmmss');
filename = fullfile(path, name+"_"+replace(num2str(wavelength_sweep(1)),".","_") +"nm_to_"+ replace(num2str(wavelength_sweep(end)),".","_")+ "nm_" + string(dt) + ".mat");
save(filename, "pwr_save","wavelength_sweep");
disp("Saved to: " + filename);

View File

@@ -0,0 +1,21 @@
clear all
% L = OptLaserN7714A("TCPIP0::134.245.243.209::inst0::INSTR");
% L.setWavelength(1551,1); % nm
% L.setPower(5.8, true,1); % dBm, also turns output ON
% L.setDither(0,1);
% % L.setPower(5.9, false,1);
% info = L.getLaserInfo();
%
% L.delete();
clear all
L = OptLaserN7714A("GPIB0::20::INSTR");
L.setWavelength(1550,0); % nm
L.setPower(0, true,0); % dBm, also turns output ON
L.setPower(0, false,0);
info = L.getLaserInfo();
L.delete();

View File

@@ -0,0 +1,29 @@
% --- Minimal N7714A example (MATLAB) ---
visa_addr = "TCPIP0::134.245.243.209::inst0::INSTR"; % <-- change to your laser's IP
port = 1; % 1..4 selects the N7714A output port
% v = visadev(visa_addr);
% Identify instrument
writeline(v,'*IDN?'); disp(strtrim(readline(v)));
% Make sure wavelength is settable (Auto mode)
writeline(v, sprintf('SOUR%d:WAV:AUTO 1', port)); % Auto Mode ON (wavelength set allowed).
% Set wavelength and power (units explicit)
writeline(v, sprintf('SOUR%d:WAV 1560NM', port)); % set 1550 nm. :contentReference[oaicite:3]{index=3}
writeline(v, sprintf('SOUR%d:POW:UNIT DBM', port)); % power unit = dBm. :contentReference[oaicite:4]{index=4}
writeline(v, sprintf('SOUR%d:POW:LEV:IMM:AMPL 6 DBM', port)); % set -3 dBm. :contentReference[oaicite:5]{index=5}
% Enable output (either OUTP or SOUR:POW:STAT works)
writeline(v, sprintf('OUTP%d:STAT ON', port)); % laser ON. :contentReference[oaicite:6]{index=6}
writeline(v, 'OUTP1 ON');
% ---- Read back to verify ----
writeline(v, sprintf('SOUR%d:WAV?', port)); wav_m = str2double(readline(v));
writeline(v, sprintf('SOUR%d:POW:LEV:IMM:AMPL?', port)); pow = str2double(readline(v));
writeline(v, sprintf('OUTP%d:ON?', port)); onoff = str2double(readline(v));
fprintf('Port %d -> %.2f nm, %.2f dBm, Output=%d\n', port, 1e9*wav_m, pow, onoff);
delete(v);

View File

@@ -0,0 +1,2 @@
L.setPower(power, false,0);
L.delete();

View File

@@ -0,0 +1,19 @@
clear all
% 1554.7097
% 1554.9032
% 1555.0968
% 1555.2904
%%%%%%%%%%%%%%%%%%%%%
wavelength = 1555.0968; %nm
power = 6; %dBm
%%%%%%%%%%%%%%%%%%%%%
L = OptLaserN7714A("GPIB0::20::INSTR");
L.setWavelength(wavelength,0);
L.setPower(power, true,0);

View File

@@ -13,42 +13,45 @@ end
database_name = 'ecoc2025_loops.db';
if ~exist('db','var')
db = DBHandler("pathToDB", [databasePath, database_name]);
end
db = DBHandler("pathToDB", [databasePath, database_name]);
conf = db.tables.Configurations;
% conf = db.tables.Configurations;
if ~exist('confPrev','var')
confPrev = db.tables.Configurations;
confPrev = conf;
end
awg_upload_required = 1; %still uploads every first round
subimt_DSP = 1;
recordlen = 5000000;
sequence_order = 19;
n_recording = 2; % Or any number you want
recordlen = 1000000;
sequence_order = 17;
n_recording = 1; % Or any number you want
conf=rmfield(conf,"interference_attenuation");
conf=rmfield(conf,"symbolrate");
conf=rmfield(conf,"pam_level");
% Define vector parameters directly in conf:
conf.unique_elab_id = "20250408-842b0a3078172b48dd032795226fbe683190afc4";
conf.db_mode = db_mode.no_db;
conf.pulsef_alpha = 0.2;
conf.v_bias = 2.65;
conf.v_awg = 0.9;
conf.v_awg = 0.85;
conf.precomp_amp = -64; %-64
conf.wavelength = 1310;
conf.laser_power = 11;
conf.fiber_length = 0;
conf.pd_in_desired = 9;
conf.is_mpi = 1;
conf.is_mpi = true;
conf.signal_attenuation = 0;
conf.interference_path_length = 300; %m
conf.interference_attenuation = [0:2:30,40];
conf.pam_level = [4,6,8];
conf.symbolrate = [56,72,96,112].*1e9;
conf.bitrate = conf.symbolrate .* floor(log2(6)*10)/10;
conf.interference_path_length = 20; %m
conf.interference_attenuation = 10;%[0:2:30,40];
conf.pam_level = 4;%[2,4,6,8];
conf.symbolrate = [112].*1e9;
conf.pam_source = [];
if conf.is_mpi
current_folder = ['mpi_',num2str(conf.interference_path_length),'m_pam',num2str(conf.pam_level)];
current_folder = ['test_mpi_opti_',num2str(conf.interference_path_length),'m_pam',num2str(conf.pam_level)];
else
current_folder = 'testing';
end
@@ -106,10 +109,23 @@ else
end
end
fprintf('Running measurement: %s\n', strjoin(paramDisplayCell, ', '));
fprintf('Running measurement: %s ---> %d of %d done \n ', strjoin(paramDisplayCell, ', '),runIdx, totalRuns);
if confRequest.pam_level == 2
confRequest.symbolrate = 112e9;
elseif confRequest.pam_level == 4
confRequest.symbolrate = 112e9;
elseif confRequest.pam_level == 6
confRequest.symbolrate = 96e9;
elseif confRequest.pam_level == 8
confRequest.symbolrate = 72e9;
end
confRequest.bitrate = confRequest.symbolrate * floor(log2(confRequest.pam_level) * 10) / 10;
% measure_run("config",confRun,"parallel",parallel_dsp,"max_occurences",max_occurences);
measure_run_script;
measure_run_script;
end
end