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

@@ -28,8 +28,10 @@ classdef Electricalsignal < Signal
function pow = power(obj)
pow = mean( abs(obj.signal).^2 ) ;
pow = pow2db(pow)+30; %dbm
% Power of an electrical signal
R = 50;
pow = mean(abs(obj.signal).^2) / R; % Power in watts = V^2 / R
pow = 10*log10(pow) + 30; % Power in dB +30 = dBm
end
@@ -47,6 +49,66 @@ classdef Electricalsignal < Signal
end
function obj = normalize(obj,options)
arguments
obj Electricalsignal
options.mode normalization_mode = normalization_mode.rms
end
switch options.mode
case normalization_mode.milliwatt
curpow = sqrt(mean(obj.signal.^2)/50); %watt
tgtpow = sqrt(1e-3); %watt -> wir wollen milliwatt
scling = tgtpow/curpow;
obj.signal = obj.signal*scling;
case normalization_mode.rms
obj.signal = obj.signal / sqrt(mean(obj.signal.^2));
case normalization_mode.oneone
obj.signal = obj.signal - min(obj.signal);
obj.signal = obj.signal/max(abs(obj.signal));
obj.signal = (2*obj.signal) - 1;
end
end
function obj = setPower(obj,outputpower, mode)
arguments
obj Electricalsignal
outputpower
mode power_notation
end
switch mode
case power_notation.W
case power_notation.mW
outputpower_w = outputpower/1000; %mW to Watt
case power_notation.dBm
outputpower_w = 10^((outputpower-30)/10); % dBm to Watt
case power_notation.dBW
outputpower_w = 10^((outputpower)/10); % dBm to Watt
end
curpow = sqrt(mean(obj.signal.^2)/50); %watt mit 50 ohm ref
tgtpow = sqrt(outputpower_w); %watt -> wir wollen milliwatt
scling = tgtpow/curpow;
obj.signal = obj.signal*scling;
end
end

View File

@@ -28,7 +28,7 @@ classdef Informationsignal < Signal
function pow = power(obj)
pow = mean(abs(obj.signal),"all") ;
pow = mean(abs(obj.signal.^2),"all") ;
end

View File

@@ -373,14 +373,14 @@ classdef Signal
fsig = obj.fs;
q = fsig/fsym;
if q > 10
sig = abs(obj.signal).^2;
if q > 10 && isinteger(q)
sig = (obj.signal);
else
sig = abs(obj.resample("fs_in",fsig,"fs_out",fsym*10).signal);
sig = (obj.resample("fs_in",fsig,"fs_out",fsym*30).signal);
q = 10;
end
figure(12)
figure()
clf
cursor = 200*q;
@@ -390,6 +390,8 @@ classdef Signal
cursor=cursor+q;
s=s+1;
end
ylim([-3 3]);
end