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

@@ -7,11 +7,12 @@ classdef Awg2Scope
Scope
mapping;
waitUntilClick
end
methods (Access=public)
function obj = Awg2Scope(Awg,Scope,mapping)
function obj = Awg2Scope(Awg,Scope,mapping,options)
%Simple class to call the Awg and Scope and map the signals
%accordingly in the correct formats with correct l
% ogbook
@@ -21,16 +22,19 @@ classdef Awg2Scope
Awg
Scope
mapping
options.waitUntilClick = 0;
end
obj.Awg = Awg;
obj.Scope = Scope;
obj.mapping = mapping; % AWG CH [1,2,3,4] -> Scope CH [0,0,0,1]
obj.waitUntilClick = options.waitUntilClick;
end
function [S1,S2,S3,S4] = process(obj,channels)
function [S1,S2,S3,S4] = process(obj,channels, options)
arguments
obj
@@ -41,15 +45,33 @@ classdef Awg2Scope
channels.signal4 Informationsignal = Informationsignal([])
% add new optional arguments here
options.waitUntilClick = obj.waitUntilClick;
end
%%% UPLOAD TO AWG %%%
[S1,S2,S3,S4]=obj.Awg.upload("signal1",channels.signal1,...
"signal2",channels.signal2,...
"signal3",channels.signal3,...
"signal4",channels.signal4...
);
%%% UPLOAD TO AWG %%%
scpe_sig_cell = obj.Scope.read();
%%% READ FROM SCOPE %%%
scpe_sig_cell = obj.Scope.read("waitUntilClick",options.waitUntilClick);
%%% READ FROM SCOPE %%%
% Map Scope measurement to output signal
% mapping index is the AWG chanel and mapping number is the

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)

View File

@@ -193,8 +193,9 @@ classdef OptAtten < handle
differ = abs(state.outputpower(i)-options.value(i));
%create msgbox when necessary
if differ >= 2
hMsgBox = msgbox(['Output Power at attenuator slot ' num2str(2) ' differs by 2dB or more!']);
uiwait(hMsgBox);
warning(['Output Power at attenuator slot ' num2str(2) ' differs by ', num2str(differ), 'or more!'])
% hMsgBox = msgbox(['Output Power at attenuator slot ' num2str(2) ' differs by 2dB or more!']);
% uiwait(hMsgBox);
end
end
end

View File

@@ -12,6 +12,8 @@ classdef ScopeKeysight
interpolate
recordLen
IPaddress
waitUntilClick
end
methods (Access=public)
@@ -30,6 +32,7 @@ classdef ScopeKeysight
options.interpolate logical = 0;
options.recordLen double = 1000000;
options.IPaddress
options.waitUntilClick = 0;
end
%
@@ -55,6 +58,7 @@ classdef ScopeKeysight
arguments
obj
options.channel logical = obj.channel
options.waitUntilClick = obj.waitUntilClick;
end
%%%%%%%%%%%%%%%%%%%%%%%%
@@ -119,14 +123,43 @@ classdef ScopeKeysight
obj.writeNcheck(v,sprintf(':CHANnel%u:DISPlay ON',n));% display captured data trace
end
set(v,'Timeout',150);
if obj.autoScale
obj.writeNcheck(v,':AUTOscale');
for n = 1:4
range = str2double(obj.writeReceiveCheck(v,sprintf(':CHANnel%u:RANGe?',n)));
obj.writeNcheck(v,sprintf(':CHANnel%u:RANGe %.3f',n,range/1.2));
%use this to finetune autoscaling - VERY helpful
% higher value leads to higher scaling
fintunefactor = 1.4; % within [1,...,2]
obj.writeNcheck(v,sprintf(':CHANnel%u:RANGe %.3f',n,range/fintunefactor));
end
else
obj.writeNcheck(v,':SINGLE');
%obj.writeNcheck(v,':SINGLE');
end
% After Autoscale, let the user adjust the scope scaling...
% "options.waitUntilClick" was a shit name but now this is it :-)
if options.waitUntilClick
% Create a dialog box with the desired text
d = dialog('Name', 'Scale Scope then press continue', 'Position', [300, 300, 300, 180]);
% Add a text label with the instruction
uicontrol('Parent', d, ...
'Style', 'text', ...
'Position', [20, 100, 260, 40], ...
'String', 'Please adjust scope scaling now, then press continue', ...
'HorizontalAlignment', 'center');
% Add a button to close the dialog and resume execution
uicontrol('Parent', d, ...
'Style', 'pushbutton', ...
'Position', [100, 40, 100, 40], ...
'String', 'Continue', ...
'Callback', 'uiresume(gcbf); delete(gcbf)');
% Pause execution until the dialog box is closed
uiwait(d);
end
if obj.extRef