version where the signal is flipped and added together

This commit is contained in:
Silas Oettinghaus
2023-07-10 15:08:25 +02:00
parent 93dd63bb18
commit 3c11e4b2e5
10 changed files with 778 additions and 421 deletions

View File

@@ -280,7 +280,7 @@ classdef Signal
end
%%
function obj = delay(obj,options)
function [obj,delay_n] = delay(obj,options)
arguments
obj Opticalsignal
@@ -291,27 +291,29 @@ classdef Signal
delay_n = round(delay_t .* obj.fs);
% build "long" hann window to fade the signal in and out
% -> prevent hard step in the signal!
hann_wind = hann(200);
ones_wind = ones(size(obj.signal));
ones_wind(1:100) = hann_wind(1:100);
ones_wind(end-100:end) = hann_wind(end-100:end);
% subtract average
mu = mean(obj.signal,"all");
obj.signal = obj.signal - mu;
%apply hann
obj.signal = obj.signal .* ones_wind;
%add average again
obj.signal = obj.signal + mu;
% % build "long" hann window to fade the signal in and out
% % -> prevent hard step in the signal!
% hann_wind = hann(200);
% ones_wind = ones(size(obj.signal));
% ones_wind(1:100) = hann_wind(1:100);
% ones_wind(end-100:end) = hann_wind(end-100:end);
%
% % subtract average
% mu = mean(obj.signal,"all");
%
% obj.signal = obj.signal - mu;
%
% %apply hann
% obj.signal = obj.signal .* ones_wind;
%
% %add average again
% obj.signal = obj.signal + mu;
% finally circshift the signal
obj.signal=circshift(obj.signal,delay_n);
% obj.signal=[obj.signal(delay_n:end); zeros(delay_n-1,1)];
end
end
end

View File

@@ -180,6 +180,18 @@ classdef PAMmapper
end
function [data_out] = decide_pamlevel(obj,data_in)
a = squeeze(repmat(real(data_in.signal),[1 1 length(obj.thresholds)])); %Eingangssignal in 3 spalten
b = squeeze(repmat(reshape(obj.thresholds(:).',[1 1 length(obj.thresholds)]),[1 length(data_in.signal) 1])); %Threshold in 3 Spalten
comp_real = a > b; %check for each symbol/ sampling if it exeeds the obj.thresholdseshold 1, 2 or 3
data_out = sum(comp_real,2);
%data_out = (data_out*2)-3;
%data_out = pam_level_decision .* 1/sqrt(5);
end
end
end

View File

@@ -40,16 +40,23 @@ classdef Filter
end
function signalclass_out = process(obj,signalclass_in)
function signal_out = process(obj,signal_in)
if isa(signal_in,'Signal')
% actual processing of the signal
signalclass_out = signalclass_in;
signalclass_out.signal = obj.process_(signalclass_in.signal);
% actual processing of the signal
signal_out = signal_in;
signal_out.signal = obj.process_(signal_in.signal);
% append to logbook
filterdesc = [num2str(obj.filtdegree),'. order ',char(obj.filterType),' filter with f_cutoff at ', num2str(obj.f_cutoff*1e-9), ' GHz.'];
signal_out = signal_out.logbookentry(filterdesc);
% append to logbook
filterdesc = [num2str(obj.filtdegree),'. order ',char(obj.filterType),' filter with f_cutoff at ', num2str(obj.f_cutoff*1e-9), ' GHz.'];
signalclass_out = signalclass_out.logbookentry(filterdesc);
elseif isa(signal_in,"double")
signal_out = obj.process_(signal_in);
end
end
@@ -179,8 +186,8 @@ classdef Filter
% xlabel('Freq in GHz')
% ylabel('Magnitude (dB)')
% freqz(B, A, 2048, obj.fsamp);
% figure(30)
% freqz(B, A, 2048, obj.fsamp);
% hfvt = fvtool(B,A);
end

View File

@@ -61,10 +61,10 @@ classdef EML
end
function signalclass_out = process(obj,signalclass_in)
function [signalclass_out,obj] = process(obj,signalclass_in)
% actual processing of the signal (steps 1. - 3.)
signalclass_in.signal = obj.process_(signalclass_in.signal);
[signalclass_in.signal,obj] = obj.process_(signalclass_in.signal);
% cast the inform. signal to electrical signal
signalclass_in = Opticalsignal(signalclass_in,"fs",obj.fsimu,"logbook",signalclass_in.logbook,"lambda",obj.lambda*1e-9,"nase",0);
@@ -92,7 +92,7 @@ classdef EML
ph_noi = obj.createPhaseNoise;
laserfield = obj.field.*exp(1i*ph_noi);
%remember phase (! you need to receive the altered eml object in you sim program !)
obj.phase = ph_noi(end);
obj.phase = ph_noi;
else
laserfield = obj.field;
end
@@ -106,13 +106,18 @@ classdef EML
function noi = createPhaseNoise(obj)
%create random vector
noi = randn(obj.signal_len,1);
noi = randn(obj.signal_len/2,1);
%scale with noisefactor
noi = noi * obj.noisefactor;
%cumsum to accumulate noise over time vector
noi = cumsum(noi);
%add phase from previous block/ loop of simulation
noi = noi + obj.phase;
noi = [noi ; flip(noi)];
end
function modulated_laserfield = externalmodulation(obj,laserfield,electrical_in)

View File

@@ -104,15 +104,15 @@ classdef EQ
function signalclass_out = process(obj,signalclass_in, reference_signalclass_in)
% actual processing of the signal (steps 1. - 3.)
signalclass_in.signal = obj.process_(signalclass_in.signal', reference_signalclass_in.signal');
% actual processing of the signal (steps 1. - 3.)
signalclass_in.signal = obj.process_(signalclass_in.signal', reference_signalclass_in.signal');
signalclass_in.signal = signalclass_in.signal';
% append to logbook
lbdesc = ['EQ '];
% append to logbook
lbdesc = ['EQ '];
signalclass_in = signalclass_in.logbookentry(lbdesc);
% write to output
% write to output
signalclass_out = signalclass_in;
end
@@ -218,14 +218,20 @@ classdef EQ
e_ = zeros(obj.Ne(1)+N2+N3,1); % initialization of filter coefficients
% e(ceil(obj.Ne(1)/2)) = 1; % set central tap to 1 (better starting point since it's closer to the expected solution)
b_ = zeros(obj.Nb(1)+Nb2+Nb3,1);
e_dc = mean(data_in); % initilaization of the dc tap with the mean value of the data
% e_save = NaN(361,8.6e5);
% save_ind = 1;
for trainloops = 1:obj.training_loops
m = obj.k0+1; % starting symbol index at the delay compared to the training sequence
error_log = [];
for n = obj.K*obj.k0+1:obj.K:obj.K*obj.training_length
m = m+1;
X_1 = data(obj.Ne(1)+n+(obj.K-1):-1:n+obj.K).';
% X_1(X_1~=0) = X_1(X_1~=0) - mean(X_1(X_1~=0));
[X_2,X_3] = obj.calc_nl_vecs(X_1,ind_mat_2nd,ind_mat_3rd,norm_fac2,norm_fac3,delta_2,delta_3,cplx);
D_1 = ref(obj.Nb(1)-obj.k0+m-2:-1:m-obj.k0-1).';
@@ -255,14 +261,22 @@ classdef EQ
% e_save(:,save_ind) = e;
% save_ind = save_ind+1;
e_dc = e_dc - obj.DCmu*error;
error_log(end+1) = e_dc;
if obj.Nb(1) > 0
b_ = b_ + obj.DFEmu*error*reference_vec; % Seems like normalized DFE has worse performance
end
end
end
%%
end
end
%%
% Plot the intermediate coefficients after training mode
obj.b = b_(1:obj.Nb(1));
obj.b2 = b_(obj.Nb(1)+1:obj.Nb(1)+Nb2);
@@ -273,7 +287,8 @@ classdef EQ
if obj.plottrain
figure(8052)
subplot(2,3,1); stem(abs(obj.e),'Markersize',2);
sgtitle('Training Coeff')
subplot(2,3,1); stem((obj.e),'Markersize',2);
title('FFE coeff linear')
xlabel('coefficient index'); ylabel('value'); set(gca,'Fontsize',12)
subplot(2,3,2); stem(obj.e2,'Markersize',2);
@@ -291,9 +306,10 @@ classdef EQ
subplot(2,3,6);stem(obj.b3,'Markersize',2);
title('DFE coeff nl 3rd')
xlabel('coefficient index'); ylabel('value'); set(gca,'Fontsize',12)
set(gcf,'Position',[200 500 700 400])
%set(gcf,'Position',[200 500 700 400])
end
if obj.l1act
neg_lin = find(abs(obj.e) < obj.thres(1));
neg_2nd = find(abs(obj.e2) < obj.thres(2));
@@ -369,6 +385,9 @@ classdef EQ
for k = 1:obj.K:length(data_in)
m=m+1; % Symbol index
X_1 = data(obj.Ne(1)+k-1:-1:k).';
[X_2,X_3] = obj.calc_nl_vecs(X_1,ind_mat_2nd,ind_mat_3rd,norm_fac2,norm_fac3,delta_2,delta_3,cplx);
if obj.l1act
@@ -405,6 +424,7 @@ classdef EQ
if mu_mat ~= 0
e_dc = e_dc - obj.DCmu*error;
error_log(end+1) = e_dc;
end
end
@@ -434,6 +454,7 @@ classdef EQ
if obj.plotfinal
figure(8054)
if obj.l1act
sgtitle('Final Coeff')
subplot(2,3,1); stem(rel_lin,obj.e,'Markersize',2);
title('FFE coeff linear')
xlabel('coefficient index'); ylabel('value'); set(gca,'Fontsize',12)
@@ -453,6 +474,7 @@ classdef EQ
title('DFE coeff nl 3rd')
xlabel('coefficient index'); ylabel('value'); set(gca,'Fontsize',12)
else
sgtitle('Final Coeff')
subplot(2,3,1); stem(obj.e/max(e_),'Markersize',2);
title('FFE coeff linear')
xlabel('coefficient index'); ylabel('value'); set(gca,'Fontsize',12)