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 221a2c7..0000000 Binary files a/Functions/.DS_Store and /dev/null differ diff --git a/Functions/functionSignatures.json b/Functions/functionSignatures.json deleted file mode 100644 index 87b7369..0000000 --- a/Functions/functionSignatures.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "_schemaVersion": "1.0.0", - "myFunc": - { - "inputs": - [ - {"name":"in1", "kind":"required", "type":["numeric"], "purpose":"ID of item"}, - {"name":"in2", "kind":"required", "type":["numeric"], "purpose":"# Items"}, - {"name":"in3", "kind":"ordered", "type":["numeric"], "purpose":"Input Value"}, - {"name":"Name1", "kind":"namevalue", "type":["logical","scalar"],"purpose":"Option"}, - {"name":"Name2", "kind":"namevalue", "type":["char", "choices={'Default','Choice1','Choice2'}"]} - ] - } -} \ No newline at end of file diff --git a/Functions/myFunc.m b/Functions/myFunc.m deleted file mode 100644 index 4fd16b7..0000000 --- a/Functions/myFunc.m +++ /dev/null @@ -1,34 +0,0 @@ -% myFunc Example function -% This function is called with any of these syntaxes: -% -% myFunc(in1, in2) accepts 2 required arguments. -% myFunc(in1, in2, in3) also accepts an optional 3rd argument. -% myFunc(___, NAME, VALUE) accepts one or more of the following name-value pair -% arguments. This syntax can be used in any of the previous syntaxes. -% * 'NAME1' with logical value -% * 'NAME2' with 'Default', 'Choice1', or 'Choice2' -function myFunc(reqA,reqB,varargin) - % Initialize default values - NV1 = true; - NV2 = 'Default'; - posA = []; - - if nargin > 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);