Files
imdd_silas/Classes/04_DSP/Timing Recovery/MaxVar_Timing_Recovery.m
magf 3676d92b30 +++ Changes +++
+ duobinary_target now supports memoryless decoding (FFE targets DB response without MLSE)
+ PAMmapper.quantize now supports custom constellations for quantization
+ Added a new folder 'Documentations' for pdfs, slides, etc.
+ Added new FSO evaluation scripts in projects/FSO transmission/Evaluation Scripts
+ Added ffe_db (rudimentary module, not important anymore)
2026-03-05 10:41:36 +01:00

113 lines
3.5 KiB
Matlab

classdef MaxVar_Timing_Recovery < handle
properties(Access=public)
mode
sps
fsym
fadc
num_tau
comp_signal
comp_mode
end
methods(Access=public)
function obj = MaxVar_Timing_Recovery(options)
arguments(Input)
options.mode = 0;
options.sps = 2;
options.fsym = 32e9;
options.fadc = 80e9;
options.num_tau = 64;
options.comp_signal = 0;
options.comp_mode = 0;
end
fn = fieldnames(options);
for n = 1:numel(fn)
obj.(fn{n}) = options.(fn{n});
end
%obj-Initialization here%
end
function [data_out] = process(obj, data_in)
data_out = data_in;
x = data_in.signal;
if obj.comp_mode
our_signal = data_in;
their_signal = obj.comp_signal;
end
if obj.mode == 0
vars = zeros(obj.sps,1);
for phi = 1:obj.sps
% Test variance for different start samples
y_phi = x(phi:obj.sps:end);
vars(phi) = var(y_phi);
% Comparison to reference signal
if obj.comp_mode
our_signal.signal = x(phi:obj.sps:end);
our_signal.fs = 6e9;
our_signal.normalize("mode","rms").plot("displayname",['Our signal, ' num2str(vars(phi))],'fignum',1231+phi);
their_signal.normalize("mode","rms").plot("displayname",'Their signal','fignum',1231+phi);
end
end
% Choose signal configuration with the maximum variance
[~,phi_opt] = max(vars);
y = x(phi_opt:obj.sps:end).';
elseif obj.mode == 1
% Create a grid with different (sub)sample starting points
T = 1/obj.fsym;
t = (0:length(x)-1)/obj.fadc;
tauGrid = linspace(0, T, obj.num_tau);
% Interpolate the signal starting from every defined point
% and calculate the MMSE/variance
vars = zeros(size(tauGrid));
for i = 1:numel(tauGrid)
tau = tauGrid(i);
% tk = linspace(tau, t(end), length(x)/obj.sps);
tk = tau : T : t(end)+tau;
xk = interp1(t, x, tk, 'linear', 'extrap');
if obj.comp_mode % MMSE
e = xk.' - obj.comp_signal.signal;
vars(i) = mean(abs(e).^2);
else % Variance
vars(i) = var(xk, 1);
end
end
if obj.comp_mode % MMSE
[~,idx] = min(vars);
else % Variance
[~,idx] = max(vars);
end
tau_opt = tauGrid(idx);
% Choosing the signal at optimum
% tk = linspace(tau_opt, t(end), length(x)/obj.sps);
tk = tau_opt : T : t(end)+tau_opt;
y = interp1(t, x, tk, 'linear', 'extrap');
end
% if length(y) ~= length(x)/obj.sps
% y = [y 0];
% end
data_out.signal = y.';
data_out.fs = obj.fsym;
end
end
end