Commit before first big baudrate sweep

This commit is contained in:
Silas Labor Zizou
2024-10-24 19:41:59 +02:00
parent cfd1bdb513
commit bafc7f12b7
11 changed files with 588 additions and 318 deletions

View File

@@ -51,90 +51,90 @@ classdef DC_supply < handle
success = [0,0];
try
% %connect to device
% if exist('v','var')
% %v = visadev("GPIB1::19::INSTR");
% v = obj.connectDevice();
% else
%
% end
% %connect to device
% if exist('v','var')
% %v = visadev("GPIB1::19::INSTR");
% v = obj.connectDevice();
% else
%
% end
v = visadev("GPIB1::19::INSTR");
v = visadev("GPIB1::19::INSTR");
debug = 0;
if debug
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
end
debug = 0;
if debug
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
end
cmd = 'INST:SEL?';
cmd = 'INST:SEL?';
writeline(v, cmd);
prev_selected_channel = readline(v);
for ch = 1:2
% choose channel
cmd = ['INST:SEL OUT',num2str(ch)];
writeline(v, cmd);
prev_selected_channel = readline(v);
for ch = 1:2
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
act_volt = str2num(readline(v));
% choose channel
cmd = ['INST:SEL OUT',num2str(ch)];
writeline(v, cmd);
% desired voltage (round to two digits after comma)
des_volt = round(options.voltage(ch),2);
cnt = 0;
while abs(act_volt-des_volt) > 0
selected_channel = ['OUT',num2str(ch)];
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
act_volt = str2num(readline(v));
% desired voltage (round to two digits after comma)
des_volt = round(options.voltage(ch),2);
% difference
diff_volt = act_volt-des_volt;
cnt = 0;
while abs(act_volt-des_volt) > 0
selected_channel = ['OUT',num2str(ch)];
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
act_volt = str2num(readline(v));
% difference
diff_volt = act_volt-des_volt;
% set new voltage
increment_voltage = -0.01* sign(diff_volt) ;
cmd = ['VOLT ',num2str(act_volt+increment_voltage)];
writeline(v, cmd);
cnt = cnt+1;
if mod(cnt,100) == 0
wait(1);
end
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
act_volt = str2num(readline(v));
% set new voltage
increment_voltage = -0.01* sign(diff_volt) ;
cmd = ['VOLT ',num2str(act_volt+increment_voltage)];
writeline(v, cmd);
cnt = cnt+1;
if mod(cnt,100) == 0
pause(1);
end
% check if voltage is set
if act_volt ~= des_volt
hMsgBox = msgbox('An error occurred in dc supply module. Check if voltage is set correctly.');
uiwait(hMsgBox);
else
success(ch) = 1;
end
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
act_volt = str2num(readline(v));
end
% choose channel
cmd = ['INST:SEL ',char(strtrim(prev_selected_channel))];
writeline(v, cmd);
% check if voltage is set
if act_volt ~= des_volt
hMsgBox = msgbox('An error occurred in dc supply module. Check if voltage is set correctly.');
uiwait(hMsgBox);
else
success(ch) = 1;
end
%disconnect
delete(v);
catch
end
% choose channel
cmd = ['INST:SEL ',char(strtrim(prev_selected_channel))];
writeline(v, cmd);
%disconnect
delete(v);
end
function [voltage,current] = readVals(obj)