Adapt AWG to work with M8199B
Minor changes in Scope Measurement Codes for OFC 2025
This commit is contained in:
@@ -337,15 +337,24 @@ classdef Signal
|
||||
obj
|
||||
options.fignum
|
||||
options.displayname = "";
|
||||
options.color = [];
|
||||
options.normalizeToNyquist = 0;
|
||||
options.normalizeTo0dB = 0;
|
||||
end
|
||||
|
||||
% spectrum_plot(obj.signal,options.fsamp,options.figurename,options.displayname);
|
||||
|
||||
N = 2^(nextpow2(length(obj.signal))-8);
|
||||
|
||||
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,obj.fs,"centered","power","mean");
|
||||
normalize = 0;
|
||||
if normalize
|
||||
if options.normalizeToNyquist==0
|
||||
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,obj.fs,"centered","power","mean");
|
||||
w=w.*1e-9;
|
||||
else
|
||||
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,"centered","power","mean");
|
||||
end
|
||||
|
||||
|
||||
if options.normalizeTo0dB
|
||||
p_lin = p_lin./ max(p_lin);
|
||||
p_dbm = 10*log10(p_lin); %dB to dBm in case of "power"
|
||||
ylab = "normalized to 0 dB";
|
||||
@@ -357,14 +366,27 @@ classdef Signal
|
||||
figure(options.fignum); % If figure does not exist, create new figure
|
||||
ax = gca;
|
||||
hold on
|
||||
plot(w.*1e-9,p_dbm,'DisplayName',options.displayname,'LineWidth',1);
|
||||
xlabel("Frequency in GHz");
|
||||
%ylabel("Power/frequency (dB/Hz)");
|
||||
|
||||
if isempty(options.color)
|
||||
plot(w,p_dbm,'DisplayName',options.displayname,'LineWidth',1);
|
||||
else
|
||||
plot(w,p_dbm,'DisplayName',options.displayname,'LineWidth',1,'Color',options.color);
|
||||
end
|
||||
|
||||
if options.normalizeToNyquist==0
|
||||
xlabel("Frequency in GHz");
|
||||
%xlim([-obj.fs/2 obj.fs/2].*1e-9)
|
||||
edgetick = 2^(nextpow2(obj.fs*1e-9));
|
||||
xticks([-edgetick:16:edgetick]);
|
||||
xlim([100*round( min(w.*1e-9)/100,1)-10,100*round( max(w.*1e-9)/100,1)+10])
|
||||
else
|
||||
xlabel("Normalized Frequency");
|
||||
xlim([-pi, pi]);
|
||||
end
|
||||
|
||||
ylabel("Power/frequency (dB/Hz)");
|
||||
ylabel(ylab);
|
||||
xlim([-obj.fs/2 obj.fs/2].*1e-9)
|
||||
edgetick = 2^(nextpow2(obj.fs*1e-9));
|
||||
% xticks([-edgetick:16:edgetick]);
|
||||
xlim([100*round( min(w.*1e-9)/100,1)-10,100*round( max(w.*1e-9)/100,1)+10])
|
||||
|
||||
ylim([min(floor( min(p_dbm))-3 , ax.YLim(1)), max(ceil( max(p_dbm) )+(3), ax.YLim(2))]);
|
||||
yticks([-200:10:10]);
|
||||
grid on
|
||||
|
||||
@@ -104,7 +104,7 @@ classdef EQ
|
||||
|
||||
end
|
||||
|
||||
function [signalclass_out,error_log] = process(obj,signalclass_in, reference_signalclass_in)
|
||||
function [signalclass_out,noi] = process(obj,signalclass_in, reference_signalclass_in)
|
||||
|
||||
% actual processing of the signal (steps 1. - 3.)
|
||||
[signalclass_in.signal,error_log] = obj.process_(signalclass_in.signal', reference_signalclass_in.signal');
|
||||
@@ -120,6 +120,9 @@ classdef EQ
|
||||
% write to output
|
||||
signalclass_out = signalclass_in;
|
||||
|
||||
noi = signalclass_out;
|
||||
noi = signalclass_out - reference_signalclass_in;
|
||||
|
||||
end
|
||||
|
||||
function [yout,error_log] = process_(obj,data_in,ref_in)
|
||||
|
||||
@@ -215,7 +215,7 @@ classdef AwgKeysight
|
||||
switch obj.model
|
||||
case awg_model.M8196A
|
||||
v = visadev('TCPIP0::zizou.tf.uni-kiel.de::hislip0::INSTR');
|
||||
case awg_model.M8196A
|
||||
case awg_model.M8199B
|
||||
v = visadev('TCPIP0::localhost::hislip0::INSTR');
|
||||
end
|
||||
|
||||
@@ -224,10 +224,10 @@ classdef AwgKeysight
|
||||
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);
|
||||
assert(obj.numChannels==sscanf(aw, '%f'),['Wrong Channel config. AWG response: ',num2str(sscanf(aw, '%f')), ' Channels']);
|
||||
% %check if channel config matches (ONLY FOR M8196...)
|
||||
% writeline(v,'*opt?');
|
||||
% aw=readline(v);
|
||||
% assert(obj.numChannels==sscanf(aw, '%f'),['Wrong Channel config. AWG response: ',num2str(sscanf(aw, '%f')), ' Channels']);
|
||||
|
||||
switch obj.model
|
||||
case awg_model.M8196A
|
||||
@@ -276,33 +276,27 @@ classdef AwgKeysight
|
||||
|
||||
case awg_model.M8199B
|
||||
|
||||
% 1) TRAC DEl - delete the previous waveform
|
||||
xfprintf(f, sprintf(':TRAC:DEL ''M2.DataOut1'', %d', segm_num), 1);
|
||||
xfprintf(f, sprintf(':TRAC:DEL ''M2.DataOut2'', %d', segm_num), 1);
|
||||
% 1) TRAC DEl - delete the previous ch waveform
|
||||
obj.writeNcheck(v,sprintf(':TRAC:DEL ''M2.DataOut%d'', %d', chan, segm_num));
|
||||
|
||||
% 2) TRAC DEF - define properties of waveform
|
||||
xfprintf(f, sprintf(':TRAC:DEF ''M2.DataOut1'', %d,%d', segm_num, len));
|
||||
xfprintf(f, sprintf(':TRAC:DEF ''M2.DataOut2'', %d,%d', segm_num, len));
|
||||
obj.writeNcheck(v,sprintf(':TRAC:DEF ''M2.DataOut%d'', %d,%d', chan, segm_num, segm_len));
|
||||
% xfprintf(f, sprintf(':TRAC:DEF ''M2.DataOut1'', %d,%d', segm_num, len));
|
||||
|
||||
% 3) TRAC DATA - load the new waveform
|
||||
|
||||
% Example command: :TRAC:DATA 'M1.DataOut1', 1, 0 , -127,-126,,-1,0,1,,127,-127,,-1,0,1,,127
|
||||
% means : :TRAC:DATA 'identifier' , <segment_id>, <offset>, <block>|<numeric_values>
|
||||
|
||||
cmd = sprintf(':TRAC:DATA ''M2.DataOut1'', %d,%d,', segm_num, offset);
|
||||
binblockwrite(f, data(1+offset:offset+len), dataFormat, cmd);
|
||||
|
||||
cmd = sprintf(':TRAC:DATA ''M2.DataOut2'', %d,%d,', segm_num, offset);
|
||||
binblockwrite(f, data(1+offset:offset+len), dataFormat, cmd);
|
||||
offset = 0;
|
||||
cmd = sprintf(':TRAC:DATA ''M2.DataOut%d'', %d,%d,',chan, segm_num, offset);
|
||||
binblockwrite(v, signal{chan}, 'int8', cmd);
|
||||
|
||||
% 4) SET VOLTAGE (not possible to set 0v)
|
||||
xfprintf(f, sprintf(':VOLT:AMPL ''M2.DataOut1'', %gv', awg_volt(1)));
|
||||
xfprintf(f, sprintf(':VOLT:AMPL ''M2.DataOut2'', %gv', awg_volt(2)));
|
||||
obj.writeNcheck(v, sprintf(':VOLT:AMPL ''M2.DataOut%d'', %gv',chan, obj.voltages(chan)));
|
||||
% xfprintf(f, ':VOLT:AMPL ''M2.DataOut2'', 0.1v');
|
||||
|
||||
% 5) SET OUTPUTS ON/ OFF
|
||||
xfprintf(f, ':OUTP ''M2.DataOut1'', ON'); %sioe 11.23: Hier habe ich absichtlich auf OFF gestellt, wenn Kanal nicht bentigt!
|
||||
xfprintf(f, ':OUTP ''M2.DataOut2'', ON');
|
||||
obj.writeNcheck(v, sprintf(':OUTP ''M2.DataOut%d'', ON',chan)); %sioe 11.23: Hier habe ich absichtlich auf OFF gestellt, wenn Kanal nicht bentigt!
|
||||
|
||||
|
||||
|
||||
@@ -319,6 +313,9 @@ classdef AwgKeysight
|
||||
|
||||
case awg_model.M8199B
|
||||
|
||||
% SET Ref clock out (which is conn. to scope) to 100 MHz
|
||||
obj.writeNcheck(v, ':OUTPut:FREQuency ''M1.RefClkOut'',100000000');
|
||||
|
||||
% :OUTP:GLOB 'M1.System', OFF
|
||||
obj.writeNcheck(v, ':OUTP:GLOB ''M1.System'', ON');
|
||||
obj.writeNcheck(v, ':OUTP:GLOB ''M2.System'', ON');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
classdef DC_supply
|
||||
classdef DC_supply < handle
|
||||
% Simple control of DC supply via fixed GBIB address.
|
||||
% Agilent E3646A
|
||||
% No OVP or OCP implementation
|
||||
@@ -8,6 +8,10 @@ classdef DC_supply
|
||||
properties(Access=public)
|
||||
active
|
||||
voltage
|
||||
|
||||
|
||||
meas_voltage
|
||||
meas_current
|
||||
end
|
||||
|
||||
methods (Access=public)
|
||||
@@ -33,6 +37,10 @@ classdef DC_supply
|
||||
|
||||
end
|
||||
|
||||
function v = connectDevice(obj)
|
||||
v = visadev("GPIB1::19::INSTR");
|
||||
end
|
||||
|
||||
function success = set(obj,options)
|
||||
|
||||
|
||||
@@ -44,7 +52,14 @@ classdef DC_supply
|
||||
success = [0,0];
|
||||
|
||||
try
|
||||
%connect to device
|
||||
% %connect to device
|
||||
% if exist('v','var')
|
||||
% %v = visadev("GPIB1::19::INSTR");
|
||||
% v = obj.connectDevice();
|
||||
% else
|
||||
%
|
||||
% end
|
||||
|
||||
v = visadev("GPIB1::19::INSTR");
|
||||
|
||||
debug = 0;
|
||||
@@ -121,5 +136,55 @@ classdef DC_supply
|
||||
|
||||
end
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user