diff --git a/garage_ip.m b/garage_ip.m index 36609a6..8e86c6c 100755 --- a/garage_ip.m +++ b/garage_ip.m @@ -24,8 +24,8 @@ function [bits] = garage_ip (varargin) -params = struct ('x', [], 'sampleRate', 48000, 'numSamplesPerSym', 16, 'with_filter', 0, 'k_noise', 0.00); -units = struct ('x', '', 'sampleRate', '1/s', 'numSamplesPerSym', 'sps', 'with_filter', '', 'k_noise', ''); +params = struct ('x', [], 'sampleRate', 48000, 'numSamplesPerSym', 16, 'loopFilterGain', 1.0, 'with_filter', 0, 'k_noise', 0.00); +units = struct ('x', '', 'sampleRate', '1/s', 'numSamplesPerSym', 'sps', 'loopFilterGain', '', 'with_filter', '', 'k_noise', ''); % Parse parameters names = fieldnames(params); @@ -92,20 +92,20 @@ smp = []; smp_n = []; bits = []; -v_min = 0; % Threshold max -v_max = 0; % Threshold min -hyst_thr = 0.5; % Threshold hysteresis -rho_thr = 1e-5; % Threshold forgetting factor -alpha_thr = 0.1; % Min/Max update factor -k_leadLag = 2.0; % Overall loopfilter gain (scales k_lead and k_lag) -k_lead = 0.1; % Symbol syncronizer loop filter lead -k_lag = 0.0001; % Symbol syncronizer loop filter lag -lag_accu = 0; % Symbol syncronizer loop filter -k_leak = 0; % Lag forgetting factor -loopThreshold = 0.1; % Processing threshold -ns = 1; % Start sample source -n = 1; % Start sample sink -err = 0; % Error +v_min = 0; % Threshold max +v_max = 0; % Threshold min +hyst_thr = 0.5; % Threshold hysteresis +rho_thr = 1e-5; % Threshold forgetting factor +alpha_thr = 0.1; % Min/Max update factor +k_leadLag = params.loopFilterGain; % Overall loopfilter gain (scales k_lead and k_lag) +k_lead = 0.1; % Symbol syncronizer loop filter lead +k_lag = 0.0001; % Symbol syncronizer loop filter lag +lag_accu = 0; % Symbol syncronizer loop filter +k_leak = 0; % Lag forgetting factor +loopThreshold = 0.1; % Processing threshold +ns = 1; % Start sample source +n = 1; % Start sample sink +err = 0; % Error while ns < N % Get next interpolated sample is = fix(ns); @@ -156,7 +156,7 @@ while ns < N vcorr = k_leadLag*k_lead*err + lag_accu; lag_accu = lag_accu + k_leadLag*k_lag*err; lag_accu = lag_accu * (1-k_leak); - baud = (1+vcorr)*fs/numSamplesPerSym; + baud = fs/((1+vcorr)*numSamplesPerSym); _err(n) = err; _baud(n) = baud; _cnt(n) = vcorr;