updates of framework

- focus on AWG output power and lowpass characteristics
This commit is contained in:
Silas Oettinghaus
2024-04-26 14:08:21 +02:00
parent 0600abfcbf
commit 7c1d9850d6
25 changed files with 864 additions and 279 deletions

View File

@@ -5,9 +5,10 @@ classdef AWG
properties(Access=public)
kover %oversampling factor e.g. 16
upsampling_method
repetitions %repeat the signal to generate a longer sequence?
fdac %needed
normalize %want to normalize at first? either 0 or 1
normalize2dac %want to normalize at first? either 0 or 1
bit_resolution %bit res. of quantizer (e.g. 5 bit)
dac_min
dac_max
@@ -32,8 +33,9 @@ classdef AWG
arguments
options.kover = 16;
options.upsampling_method upsampling_mode
options.repetitions = 1;
options.normalize = 1;
options.normalize2dac = 1;
options.fdac = 92e9;
options.bit_resolution = 5.5
options.dac_min = -0.5;
@@ -44,6 +46,7 @@ classdef AWG
options.lpf_type = 0;
options.f_cutoff = 32e9;
options.H_lpf Filter
end
fn = fieldnames(options);
@@ -59,9 +62,20 @@ classdef AWG
len_in = length(signalclass_in.signal);
if signalclass_in.fs ~= obj.fdac
signalclass_in = signalclass_in.resample("fs_in",signalclass_in.fs,"fs_out",obj.fdac);
end
% 1-3. actual processing of the signal (normalize->quantize->sample hold)
signalclass_in.signal = obj.process_(signalclass_in.signal);
% cast the inform. signal to electrical signal
signalclass_in = Electricalsignal(signalclass_in,"fs",obj.fdac*obj.kover,"logbook",signalclass_in.logbook);
% normalize to 0dBm before applying the lowpass
%signalclass_in = signalclass_in.normalize("mode","milliwatt");
signalclass_in = signalclass_in.setPower(12,"dBm");
% 4. Apply LPF on the signal
if obj.lpf_active
if isa(obj.H_lpf,'Filter')
@@ -74,10 +88,9 @@ classdef AWG
signalclass_in = lpf.process(signalclass_in);
end
end
% cast the inform. signal to electrical signal
signalclass_in = Electricalsignal(signalclass_in,"fs",obj.fdac*obj.kover,"logbook",signalclass_in.logbook);
% append to logbook
current_class = class(obj);
lbdesc = ['AWG ', current_class , '// k_over:',num2str(obj.kover),'. f_dac:',num2str(obj.fdac*1e-9),'GHz. Resolution:',num2str(obj.bit_resolution),' bits.'];
@@ -108,16 +121,17 @@ classdef AWG
obj.signal_length = length(data_in);
if obj.normalize
% 0a Normalize the signal to 1 Vpp and set the amplitude of the signal
if obj.normalize2dac
% 0a Normalize the signal to full scale DAC range
data_in = data_in - min(data_in);
data_in = data_in/(max(data_in)-min(data_in));
else
% 0b Cut the Signal at -1 and 1 and scale to amplitude
data_in(data_in > 1) = 1;
data_in(data_in < -1) = -1;
data_in = data_in * (obj.dac_max-obj.dac_min);
data_in = data_in + obj.dac_min;
end
% 1. Quantize the signal
% 1. Quantize the signal - Full Scale is between obj.dac_min
% and dac_max. If signal is smaller in between, you won't use
% the full bit-resolution.
if obj.bit_resolution>0
elec_out = obj.quantization(data_in) ;
else
@@ -125,8 +139,16 @@ classdef AWG
end
% 2. Sample and hold + repeat (data_out: 1xsignal length)
elec_out = repmat(elec_out,obj.repetitions,obj.kover);
elec_out = reshape(elec_out',[],1);
if obj.upsampling_method == 1
% just use matlab function
elec_out = resample(elec_out,obj.kover,1);
elseif obj.upsampling_method == 2
% sample and hold
elec_out = repmat(elec_out,obj.repetitions,obj.kover);
elec_out = reshape(elec_out',[],1);
else
error('chosen upsampling method not implemented?');
end
% 3. Add skew (not implemented so far)
if obj.skew_active
@@ -145,7 +167,7 @@ classdef AWG
if isreal(x_in)
% shift signal and clip to quantizer intervall
x_in = min(max(x_in-obj.dac_min,0),obj.dac_max-obj.dac_min);
x_in = min( max(x_in-obj.dac_min,0), obj.dac_max-obj.dac_min);
% quantize signal
x_in = round((steps-1)/(obj.dac_max-obj.dac_min)*x_in);