From b640c013cb425b3a623a807dba10115b5925c1b2 Mon Sep 17 00:00:00 2001 From: Silas Oettinghaus Date: Fri, 26 May 2023 11:06:39 +0200 Subject: [PATCH] =?UTF-8?q?WIP=20b=C3=BCro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/{ => 00_signals}/Electricalsignal.m | 0 Classes/{ => 00_signals}/Informationsignal.m | 0 Classes/{ => 00_signals}/Opticalsignal.m | 0 Classes/{ => 00_signals}/Signal.m | 0 Classes/{ => 01_transmit}/AWG.m | 0 Classes/{ => 01_transmit}/PAMmapper.m | 0 Classes/01_transmit/Pulseformer.m | 110 +++++++++++++++++++ Classes/{ => 02_etc}/Amplifier.m | 0 Classes/{ => 02_etc}/Filter.m | 0 Classes/{ => 02_optical}/EML.m | 0 Classes/{ => 02_optical}/Fiber.m | 0 Classes/{ => 03_receive}/Photodiode.m | 0 Classes/{ => 03_receive}/Scope.m | 0 Classes/{ => 04_DSP}/EQ.m | 0 Classes/class_template.m | 68 ++++++++++++ Datatypes/pulseform.m | 7 ++ Functions/.DS_Store | Bin 6148 -> 0 bytes Functions/functionSignatures.json | 14 --- Functions/myFunc.m | 34 ------ setup_simulation.m | 11 +- 20 files changed, 192 insertions(+), 52 deletions(-) rename Classes/{ => 00_signals}/Electricalsignal.m (100%) rename Classes/{ => 00_signals}/Informationsignal.m (100%) rename Classes/{ => 00_signals}/Opticalsignal.m (100%) rename Classes/{ => 00_signals}/Signal.m (100%) rename Classes/{ => 01_transmit}/AWG.m (100%) rename Classes/{ => 01_transmit}/PAMmapper.m (100%) create mode 100644 Classes/01_transmit/Pulseformer.m rename Classes/{ => 02_etc}/Amplifier.m (100%) rename Classes/{ => 02_etc}/Filter.m (100%) rename Classes/{ => 02_optical}/EML.m (100%) rename Classes/{ => 02_optical}/Fiber.m (100%) rename Classes/{ => 03_receive}/Photodiode.m (100%) rename Classes/{ => 03_receive}/Scope.m (100%) rename Classes/{ => 04_DSP}/EQ.m (100%) create mode 100644 Classes/class_template.m create mode 100644 Datatypes/pulseform.m delete mode 100644 Functions/.DS_Store delete mode 100644 Functions/functionSignatures.json delete mode 100644 Functions/myFunc.m diff --git a/Classes/Electricalsignal.m b/Classes/00_signals/Electricalsignal.m similarity index 100% rename from Classes/Electricalsignal.m rename to Classes/00_signals/Electricalsignal.m diff --git a/Classes/Informationsignal.m b/Classes/00_signals/Informationsignal.m similarity index 100% rename from Classes/Informationsignal.m rename to Classes/00_signals/Informationsignal.m diff --git a/Classes/Opticalsignal.m b/Classes/00_signals/Opticalsignal.m similarity index 100% rename from Classes/Opticalsignal.m rename to Classes/00_signals/Opticalsignal.m diff --git a/Classes/Signal.m b/Classes/00_signals/Signal.m similarity index 100% rename from Classes/Signal.m rename to Classes/00_signals/Signal.m diff --git a/Classes/AWG.m b/Classes/01_transmit/AWG.m similarity index 100% rename from Classes/AWG.m rename to Classes/01_transmit/AWG.m diff --git a/Classes/PAMmapper.m b/Classes/01_transmit/PAMmapper.m similarity index 100% rename from Classes/PAMmapper.m rename to Classes/01_transmit/PAMmapper.m diff --git a/Classes/01_transmit/Pulseformer.m b/Classes/01_transmit/Pulseformer.m new file mode 100644 index 0000000..c04ea8e --- /dev/null +++ b/Classes/01_transmit/Pulseformer.m @@ -0,0 +1,110 @@ +classdef Pulseformer + %Pulseformer Summary of this class goes here + % Detailed explanation goes here + + properties(Access=public) + fdac + fsym + pulseform + pulselength + rrcalpha + end + + methods (Access=public) + function obj = Pulseformer(options) + %NAME Construct an instance of this class + % Detailed explanation goes here + + arguments + options.fdac double + options.fsym double + options.pulseform pulseform = pulseform.rrc + options.pulselength double {mustBeInteger} = 32 + options.rrcalpha double = 0.05 + end + + % + fn = fieldnames(options); + for n = 1:numel(fn) + try + obj.(fn{n}) = options.(fn{n}); + end + end + + % do more stuff + + end + + function signalclass_out = process(obj,signalclass_in) + + % actual processing of the signal (steps 1. - 3.) + signalclass_in.signal = obj.process_(signalclass_in.signal); + + % append to logbook + lbdesc = ['Applied Pulseshaping']; + signalclass_in = signalclass_in.logbookentry(lbdesc); + + % write to output + signalclass_out = signalclass_in; + + end + + + + end + + methods (Access=private) + % Cant be seen from outside! So put all your functions here that can/ + % shall not be called from outside + + function data_out = process_(obj,data_in) + %METHOD1 Summary of this method goes here + % Detailed explanation goes here + arguments(Input) + obj + data_in double + end + + arguments(Output) + data_out double + end + + if ~rem(obj.fdac,obj.fsym) + %ist ein Vielfaches + sps = obj.fdac / obj.fsym; + up = sps; + dn = 1; + else + %ist kein Vielfaches + up = obj.fdac / gcd(obj.fdac, obj.fsym); + dn = obj.fsym / gcd(obj.fdac, obj.fsym); + sps= up; + end + + if obj.pulseform == pulseform.rrc + %Bau das Filter (hier rrc) + racos_len = obj.pulselength ; + alpha = obj.rrcalpha; + h = rcosdesign(alpha,racos_len,sps); + end + + %Apply Filter using Matlab build in fctn. + data_out = upfirdn(data_in,h,up,dn); + + %cut signal, which is longer due to fir filter + st = round(up/dn*racos_len/2); %we need to cut y_out + en = round(st + (length(data_in)*up/dn) -1); + + data_out = data_out(st:en); + + %Check output integrity + if round(up/dn * length(data_in)) ~= length(data_out) + warning('Check signal length after pulse shaping'); + end + + + end + + + end +end diff --git a/Classes/Amplifier.m b/Classes/02_etc/Amplifier.m similarity index 100% rename from Classes/Amplifier.m rename to Classes/02_etc/Amplifier.m diff --git a/Classes/Filter.m b/Classes/02_etc/Filter.m similarity index 100% rename from Classes/Filter.m rename to Classes/02_etc/Filter.m diff --git a/Classes/EML.m b/Classes/02_optical/EML.m similarity index 100% rename from Classes/EML.m rename to Classes/02_optical/EML.m diff --git a/Classes/Fiber.m b/Classes/02_optical/Fiber.m similarity index 100% rename from Classes/Fiber.m rename to Classes/02_optical/Fiber.m diff --git a/Classes/Photodiode.m b/Classes/03_receive/Photodiode.m similarity index 100% rename from Classes/Photodiode.m rename to Classes/03_receive/Photodiode.m diff --git a/Classes/Scope.m b/Classes/03_receive/Scope.m similarity index 100% rename from Classes/Scope.m rename to Classes/03_receive/Scope.m diff --git a/Classes/EQ.m b/Classes/04_DSP/EQ.m similarity index 100% rename from Classes/EQ.m rename to Classes/04_DSP/EQ.m diff --git a/Classes/class_template.m b/Classes/class_template.m new file mode 100644 index 0000000..e56c514 --- /dev/null +++ b/Classes/class_template.m @@ -0,0 +1,68 @@ +classdef Name + %NAME Summary of this class goes here + % Detailed explanation goes here + + properties(Access=public) + + + end + + methods (Access=public) + function obj = Name(options) + %NAME Construct an instance of this class + % Detailed explanation goes here + + arguments + options.bla bool = true + end + + % + fn = fieldnames(options); + for n = 1:numel(fn) + try + obj.(fn{n}) = options.(fn{n}); + end + end + + % do more stuff + + end + + function signalclass_out = process(obj,signalclass_in) + + % actual processing of the signal (steps 1. - 3.) + signalclass_in.signal = obj.process_(signalclass_in.signal); + + % append to logbook + lbdesc = ['Logbookentry']; + signalclass_in = signalclass_in.logbookentry(lbdesc); + + % write to output + signalclass_out = signalclass_in; + + end + + function data_out = process_(obj,data_in) + %METHOD1 Summary of this method goes here + % Detailed explanation goes here + arguments(Input) + obj + data_in double + end + + arguments(Output) + data_out double + end + + + end + + end + + methods (Access=private) + % Cant be seen from outside! So put all your functions here that can/ + % shall not be called from outside + + + end +end diff --git a/Datatypes/pulseform.m b/Datatypes/pulseform.m new file mode 100644 index 0000000..1c524c1 --- /dev/null +++ b/Datatypes/pulseform.m @@ -0,0 +1,7 @@ +classdef pulseform < int32 + + enumeration + rrc (1) + end + +end \ No newline at end of file diff --git a/Functions/.DS_Store b/Functions/.DS_Store deleted file mode 100644 index 221a2c77c035d0cf5af4dfa9d64da515415af348..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKQA@)x5Kgw~QiiYx1$_(nI&gF91YgRWf53`9sLYj?S**=iJNqyOeb+zaAMy8i zmt^9Yd+O4ftO^*bV#upvuX zz~ZH7a{NaIaPMlcV~!u6QUr5kh_~G2~^%ylO#xWu4e{>BbNj0v^{IcX{*&fY{*XYcs6sy&i=vKW&bIDPSmU6l*8wzWy|6m-oRL~ycchr z#3~s=#5{YRMMw+~1H{0ZGhmNBQCstM((;G_V&L}-;Q1gy5nYRgL49;UgTIeBUO_|w z8}AZ`(xPjzFbE?c+@u1URBo>r+@ynF+Bnx@VbG*Au4jh#*qOP#p>RDr_@xeK+%-ro zF+dC~GEg?%I@bS-)%X9!B?CLA8Kiq5 3 - if rem(nargin,2) - posA = varargin{1}; - V = varargin(2:end); - else - V = varargin; - end - for n = 1:2:size(V,2) - switch V{n} - case 'Name1' - NV1 = V{n+1}; - case 'Name2' - NV2 = V{n+1} - otherwise - error('Error.') - end - end - end -end \ No newline at end of file diff --git a/setup_simulation.m b/setup_simulation.m index 3085f72..b34e7e7 100644 --- a/setup_simulation.m +++ b/setup_simulation.m @@ -1,5 +1,5 @@ - +clear %% Set Simulation Variables O = 18; %order of prbs @@ -31,6 +31,8 @@ fsimu = kover * fdac ; digimod = PAMmapper(M,0); +pulsef = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.05); + awg = AWG('preset','M8199B','fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5); lp_laser = Filter('filtdegree',1,"f_cutoff",60e9,"fsamp",fdac,"filterType",filtertypes.bessel_inp); @@ -78,11 +80,12 @@ bits = Informationsignal(bitpattern); % Digi Mod mod_out = digimod.map(bits); - +% merken für EQ training reference = mod_out; -mod_out.signal = applyPulseShaping(mod_out.signal,fsym,fdac); - +% shape shape +mod_out = pulsef.process(mod_out); +test = applyPulseShaping(reference.signal,fsym,fdac); % AWG -> ELECTRICAL DOMAIN X = awg.process(mod_out);