ecoc measurements

This commit is contained in:
Silas Labor Zizou
2025-04-13 16:29:12 +02:00
parent 00f1c557c0
commit 0236103b13
19 changed files with 709 additions and 359 deletions

View File

@@ -69,16 +69,16 @@ classdef AwgKeysight
obj.sampleMemorySize = 512000;
case awg_model.M8199A
obj.numChannels = 4;
obj.waveformGranularity = 512;
obj.sampleMemorySize = 1024000; %to check
obj.waveformGranularity = 256;
obj.sampleMemorySize = 512000; %see documentation "strg+f: granularity"
case awg_model.M8199A_ILV
obj.numChannels = 2;
obj.waveformGranularity = 512;
obj.sampleMemorySize = 1024000; %to check
obj.waveformGranularity = 512; %see documentation "strg+f: granularity"
obj.sampleMemorySize = 1024000;
case awg_model.M8199B
obj.numChannels = 2;
obj.waveformGranularity = 512;
obj.sampleMemorySize = 1024000; %to check
obj.waveformGranularity = 512; %see documentation "strg+f: granularity"
obj.sampleMemorySize = 1024000;
end
end
@@ -175,7 +175,10 @@ classdef AwgKeysight
% The waveform granularity is e.g. 128. This means that the waveform length must be a multiple of this granularity. The minimum waveform length is 128 samples.
if rem(length(signal{s}),obj.waveformGranularity) ~= 0
signal{s} = [signal{s} signal{s}(:,1:(obj.waveformGranularity-rem(length(signal{s}),obj.waveformGranularity)))];
fill_length = (obj.waveformGranularity-rem(length(signal{s}),obj.waveformGranularity));
segment__fill_samples = signal{s}(:,1:fill_length);
signal{s} = [signal{s} segment__fill_samples];
debug = 0;
if debug
@@ -196,7 +199,7 @@ classdef AwgKeysight
siglen = min(length(signal{s}),obj.sampleMemorySize);
signal{s} = signal{s}(1:siglen);
if siglen==obj.sampleMemorySize
warning(['Signal ',num2str(s),' was truncated to ',num2str(obj.sampleMemorySize),' to fit into AWG sample memory'])
warning(['Signal ',num2str(s),' too long was truncated to ',num2str(obj.sampleMemorySize),' to fit into AWG sample memory! Reduce Num Symbols or Sampling Rate!'])
end
@@ -362,6 +365,7 @@ classdef AwgKeysight
writeline(visaobj,char(command));
writeline(visaobj,':syst:err?');
err_aw=readline(visaobj);
assert(strfind(err_aw,"No error"),['AWG System Error? after command: ', char(command)])

View File

@@ -53,7 +53,29 @@ classdef OptAtten < handle
try
%connect to device
v = visadev('TCPIP::134.245.243.248::INSTR');
ipAddress = 'TCPIP::134.245.243.248::INSTR';
maxRetries = 5;
pauseTime = 2; % seconds between retries
v = [];
success = false;
for attempt = 1:maxRetries
try
v = visadev(ipAddress);
success = true;
break; % Exit loop if successful
catch ME
fprintf('Connection attempt %d failed: %s\n', attempt, ME.message);
pause(pauseTime);
end
end
if ~success
error(' Could not connect to device after %d attempts.', maxRetries);
end
debug = 0;
if debug
@@ -315,7 +337,8 @@ classdef OptAtten < handle
p3 = obj.power_state(3);
p4 = obj.power_state(4);
if options.silent == 0
delete(v);
if options.silent ~= 0
fprintf("\n CH1: %.2f dB | CH2: %.2f dB | CH3: %.2f dB | CH4: %.2f dB\n \n",p1, p2, p3, p4);
end
end

View File

@@ -32,14 +32,30 @@ classdef Thor_PDFA < handle
end
end
obj.getStatus();
end
function o = connectSerial(obj)
% Connect to the PDFA
o = serialport(obj.serialport_number, 9600);
configureTerminator(o, "CR", "CR"); % Set the terminator to carriage return (CR)
flush(o);
try
% Connect to the PDFA
o = serialport(obj.serialport_number, 9600);
configureTerminator(o, "CR", "CR"); % Set the terminator to carriage return (CR)
flush(o);
catch ME
disp(['Error connecting to PDFA: ', ME.message]);
% List available serial ports
availablePorts = serialportlist("available");
if isempty(availablePorts)
disp('No available serial ports found.');
else
disp('Available serial ports:');
disp(availablePorts);
end
end
end