Work on lab PC

- many new automations
- scripts to record and save MPI and bias optimizations...
This commit is contained in:
Silas Labor Zizou
2024-10-15 08:43:27 +02:00
parent 7cb3f064df
commit bf94e3dc2f
16 changed files with 2548 additions and 104 deletions

View File

@@ -0,0 +1,74 @@
classdef Exfo_laser
properties(Access=public)
wavelength
power
end
methods (Access=public)
function obj = Exfo_laser(options)
arguments
options.wavelength = 1310; %dbm
options.power = -10; %dbm
end
%
fn = fieldnames(options);
for n = 1:numel(fn)
try
obj.(fn{n}) = options.(fn{n});
end
end
end
function success = set(obj,options)
arguments
obj
options.wavelength = obj.wavelength; %dbm
options.power = obj.power; %dbm
end
% Connect to the laser
o = serialport("COM8", 9600);
configureTerminator(o, "CR"); % Set the terminator to carriage return (CR)
writeline(o, "*IDN?");
pause(1);
if o.NumBytesAvailable ~= 0
disp(['Laser Mainframe: ', readline(o)]);
else
error('No connection to the mainframe');
clear o;
end
end
% Function to set the wavelength of the laser
function setLaserWavelength(~,serialObj, channel, wavelength)
command = ['CH', num2str(channel), ':L=', num2str(wavelength)];
writeline(serialObj, command);
pause(0.5); % Allow time for the wavelength to change
writeline(serialObj, ['CH', num2str(channel), ':L?']); % Query current wavelength
current_wavelen = readline(serialObj);
disp(['Current Wavelength: ', current_wavelen]);
end
% Function to set the laser power
function setLaserPower(~,serialObj, channel, power_dBm)
command = ['CH', num2str(channel), ':P=', num2str(power_dBm)];
writeline(serialObj, command);
pause(0.2); % Allow time for power to adjust
writeline(serialObj, ['CH', num2str(channel), ':P?']); % Query current power
current_power = readline(serialObj);
disp(['Current Power: ', current_power, ' dBm']);
end
end
end