New AWG M8199A now included

ExfoLaser now uses GPIB
minor stuff
This commit is contained in:
Silas Labor Zizou
2025-03-03 09:13:16 +01:00
parent 492f889dce
commit 6570746d17
9 changed files with 211 additions and 141 deletions

View File

@@ -8,7 +8,6 @@ classdef DC_supply < handle
properties(Access=public)
active
voltage
meas_voltage
meas_current
@@ -18,7 +17,6 @@ classdef DC_supply < handle
function obj = DC_supply(options)
arguments
options.active logical = true
options.voltage double = [0,0];
@@ -35,10 +33,14 @@ classdef DC_supply < handle
assert(size(obj.voltage,1)==1,'Set Voltage for CH1 and CH2 must be given as vector [V1, V2]');
assert(size(obj.voltage,2)==2,'Set Voltage for CH1 and CH2 must be given as vector [V1, V2]');
v = obj.connectDevice();
disp(['Connected to: ', char(v.Vendor),' ', char(v.Model),' :-)']);
end
function v = connectDevice(obj)
v = visadev("GPIB1::19::INSTR");
v = visadev("GPIB0::19::INSTR");
end
function success = set(obj,options)
@@ -51,15 +53,7 @@ classdef DC_supply < handle
success = [0,0];
% %connect to device
% if exist('v','var')
% %v = visadev("GPIB1::19::INSTR");
% v = obj.connectDevice();
% else
%
% end
v = visadev("GPIB1::19::INSTR");
v = obj.connectDevice();
debug = 0;
if debug
@@ -133,58 +127,55 @@ classdef DC_supply < handle
end
function [voltage,current] = readVals(obj)
try
%connect to device
v = visadev("GPIB1::19::INSTR");
debug = 0;
if debug
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
end
%connect to device
v = obj.connectDevice;
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);
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
voltage(ch) = str2num(readline(v));
% get current voltage level
cmd = 'MEAS:CURR?';
writeline(v, cmd);
current(ch) = str2num(readline(v));
end
% set channel back to prev. selected one
cmd = ['INST:SEL ',char(strtrim(prev_selected_channel))];
writeline(v, cmd);
obj.meas_voltage = voltage;
obj.meas_current = current;
%disconnect
delete(v);
catch
debug = 0;
if debug
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
end
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);
% get current voltage level
cmd = 'VOLT?';
writeline(v, cmd);
voltage(ch) = str2num(readline(v));
% get current voltage level
cmd = 'MEAS:CURR?';
writeline(v, cmd);
current(ch) = str2num(readline(v));
end
% set channel back to prev. selected one
cmd = ['INST:SEL ',char(strtrim(prev_selected_channel))];
writeline(v, cmd);
obj.meas_voltage = voltage;
obj.meas_current = current;
%disconnect
delete(v);
end
end
end