Lab changes
This commit is contained in:
109
Classes/05_Lab/Awg2Scope.m
Normal file
109
Classes/05_Lab/Awg2Scope.m
Normal file
@@ -0,0 +1,109 @@
|
||||
classdef Awg2Scope
|
||||
%NAME Summary of this class goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
properties(Access=public)
|
||||
Awg
|
||||
Scope
|
||||
|
||||
mapping;
|
||||
|
||||
end
|
||||
|
||||
methods (Access=public)
|
||||
function obj = Awg2Scope(Awg,Scope,mapping)
|
||||
%Simple class to call the Awg and Scope and map the signals
|
||||
%accordingly in the correct formats with correct l
|
||||
% ogbook
|
||||
%entries...
|
||||
|
||||
arguments
|
||||
Awg
|
||||
Scope
|
||||
mapping
|
||||
end
|
||||
|
||||
obj.Awg = Awg;
|
||||
obj.Scope = Scope;
|
||||
|
||||
obj.mapping = mapping; % AWG CH [1,2,3,4] -> Scope CH [0,0,0,1]
|
||||
|
||||
end
|
||||
|
||||
function [S1,S2,S3,S4] = process(obj,channels)
|
||||
|
||||
arguments
|
||||
obj
|
||||
% leave this as it is! Important for further handling/ parsing
|
||||
channels.signal1 Informationsignal = Informationsignal([])
|
||||
channels.signal2 Informationsignal = Informationsignal([])
|
||||
channels.signal3 Informationsignal = Informationsignal([])
|
||||
channels.signal4 Informationsignal = Informationsignal([])
|
||||
|
||||
% add new optional arguments here
|
||||
end
|
||||
|
||||
[S1,S2,S3,S4]=obj.Awg.upload("signal1",channels.signal1,...
|
||||
"signal2",channels.signal2,...
|
||||
"signal3",channels.signal3,...
|
||||
"signal4",channels.signal4...
|
||||
);
|
||||
|
||||
scpe_sig_cell = obj.Scope.read();
|
||||
|
||||
% Map Scope measurement to output signal
|
||||
% mapping index is the AWG chanel and mapping number is the
|
||||
% respective Scope channel
|
||||
% mapping=[1 2 3 4] means that AWG chann 1 is mapped to Scope ch 1 and so on
|
||||
% mapping=[0 0 2 1] means that
|
||||
% AWG chann 3 is mapped to Scope ch 2
|
||||
% AWG chann 4 is mapped to Scope ch 1
|
||||
|
||||
lbdesc = ['Scope Record'];
|
||||
try
|
||||
S1 = Electricalsignal(S1,"fs",S1.fs,"logbook",S1.logbook);
|
||||
S1.signal = scpe_sig_cell{obj.mapping(1)}.signal;
|
||||
S1.fs = scpe_sig_cell{obj.mapping(1)}.fs;
|
||||
S1 = S1.logbookentry(lbdesc,obj);
|
||||
catch
|
||||
% S1.signal = scpe_sig_cell{1};
|
||||
end
|
||||
|
||||
try
|
||||
S2 = Electricalsignal(S2,"fs",S2.fs,"logbook",S2.logbook);
|
||||
S2.signal = scpe_sig_cell{obj.mapping(2)}.signal;
|
||||
S2.fs = scpe_sig_cell{obj.mapping(2)}.fs;
|
||||
S2 = S2.logbookentry(lbdesc,obj);
|
||||
catch
|
||||
% S2.signal = scpe_sig_cell{2};
|
||||
S2 = S2.logbookentry(lbdesc,obj);
|
||||
end
|
||||
|
||||
try
|
||||
S3 = Electricalsignal(S3,"fs",S3.fs,"logbook",S3.logbook);
|
||||
S3.signal = scpe_sig_cell{obj.mapping(3)}.signal;
|
||||
S3.fs = scpe_sig_cell{obj.mapping(3)}.fs;
|
||||
S3 = S3.logbookentry(lbdesc,obj);
|
||||
catch
|
||||
% S3.signal = scpe_sig_cell{3};
|
||||
S3 = S3.logbookentry(lbdesc,obj);
|
||||
end
|
||||
|
||||
try
|
||||
S4 = Electricalsignal(S4,"fs",S4.fs,"logbook",S4.logbook);
|
||||
S4.signal = scpe_sig_cell{obj.mapping(4)}.signal;
|
||||
S4.fs = scpe_sig_cell{obj.mapping(4)}.fs;
|
||||
S4 = S4.logbookentry(lbdesc,obj);
|
||||
catch
|
||||
% S4.signal = scpe_sig_cell{4};
|
||||
S4 = S4.logbookentry(lbdesc,obj);
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -24,9 +24,9 @@ classdef AwgKeysight
|
||||
|
||||
properties(Access=protected)
|
||||
model awg_model
|
||||
fdac double
|
||||
%fdac double
|
||||
skews double
|
||||
voltages double
|
||||
%voltages double
|
||||
scaletodac logical
|
||||
|
||||
numChannels double
|
||||
@@ -36,6 +36,11 @@ classdef AwgKeysight
|
||||
numProvidedSignals double
|
||||
end
|
||||
|
||||
properties(Access=public)
|
||||
fdac double
|
||||
voltages double
|
||||
end
|
||||
|
||||
methods (Access=public)
|
||||
|
||||
function obj = AwgKeysight(options)
|
||||
@@ -78,7 +83,7 @@ classdef AwgKeysight
|
||||
|
||||
end
|
||||
|
||||
function upload(obj,channels,options)
|
||||
function [signal1,signal2,signal3,signal4] = upload(obj,channels,options)
|
||||
|
||||
arguments
|
||||
obj
|
||||
@@ -116,7 +121,18 @@ classdef AwgKeysight
|
||||
|
||||
success = obj.upload_(unpackedSignals);
|
||||
|
||||
for s = 1:obj.numChannels
|
||||
lbdesc = ['Upload to Awg'];
|
||||
obj = channels.(fn{s}).logbookentry(lbdesc,obj);
|
||||
end
|
||||
|
||||
signal1 = channels.signal1;
|
||||
signal2 = channels.signal2;
|
||||
signal3 = channels.signal3;
|
||||
signal4 = channels.signal4;
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -203,8 +219,11 @@ classdef AwgKeysight
|
||||
v = visadev('TCPIP0::localhost::hislip0::INSTR');
|
||||
end
|
||||
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
|
||||
debug = 0;
|
||||
if debug
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
end
|
||||
|
||||
%check if channel config matches
|
||||
writeline(v,'*opt?');
|
||||
aw=readline(v);
|
||||
|
||||
@@ -47,7 +47,10 @@ classdef DC_supply
|
||||
%connect to device
|
||||
v = visadev("GPIB1::19::INSTR");
|
||||
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
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);
|
||||
|
||||
@@ -55,7 +55,10 @@ classdef OptAtten < handle
|
||||
%connect to device
|
||||
v = visadev('TCPIP::134.245.243.248::INSTR');
|
||||
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
debug = 0;
|
||||
if debug
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
end
|
||||
%Keysight Technologies, N7764A, MY49A00696, 1.13.1
|
||||
|
||||
|
||||
|
||||
@@ -79,8 +79,11 @@ classdef ScopeKeysight
|
||||
end
|
||||
end
|
||||
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
|
||||
debug = 0;
|
||||
if debug
|
||||
disp(['Connected to Instrument: ',char(v.Vendor),' ',char(v.Model),' SerNo:',char(v.SerialNumber)]);
|
||||
end
|
||||
|
||||
% Check if Scope is ready to go
|
||||
opdone = 0;
|
||||
acqdone = 0;
|
||||
@@ -202,6 +205,11 @@ classdef ScopeKeysight
|
||||
procdone = sscanf(obj.writeReceiveCheck(v,'pder?'), '%f');
|
||||
pause(0.005);
|
||||
end
|
||||
|
||||
% arrange to Electrcalsinal class as output %%
|
||||
for ch = 1:numel(obj.channel)
|
||||
recordedSignals{ch} = Electricalsignal(recordedSignals{ch},"fs",obj.fadc.getValue);%fs is a enum and requires get function
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user