- added trigon mode

git-svn-id: http://moon:8086/svn/matlab/trunk@134 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
2020-08-10 18:51:26 +00:00
parent 4f603ad18e
commit 4758ea347a
+28 -4
View File
@@ -23,7 +23,9 @@
## Author: Jens <jens@orion>
## Created: 2020-08-07
function retval = mc_pd_eval3 (phase_lo, freq, slave_oversample)
function retval = mc_pd_eval3 (phase, freq, slave_oversample)
USE_TRIGON = 0;
Nc = 10;
Nspc = 25;
@@ -50,8 +52,19 @@ dfreq = freq/slave_oversample;
omega = 0;
sample_count = slave_oversample;
a = 0.5;
y(1) = a*cos(2*pi*phase);
y(2) = a*sin(2*pi*phase);
for n=1:N,
phase = mod(phase_lo - 0.5, 1);
if USE_TRIGON
[phase, y] = process_trigon(y, omega);
else
phase = process_linear_phase(phase, omega);
endif
_lo(n) = phase;
perr = phase_det(phase, x(n));
sample_count = sample_count - 1;
if sample_count == 0,
@@ -59,18 +72,29 @@ for n=1:N,
else
perr = 0;
end
_lo(n) = phase_lo;
omega = dfreq - (klag*lag + klead*perr);
phase_lo = mod(phase_lo + omega, 1);
lag = lag + perr;
_perr(n) = perr;
_omega(n) = omega;
end
function perr = phase_det(lo, x)
lo = mod(lo - 0.5, 1);
perr = mod((lo - x), 1) - 0.5;
endfunction
function phase_out = process_linear_phase(phase_in, omega)
phase_out = mod(phase + omega, 1);
endfunction
function [phase_out, y] = process_trigon(y, omega)
b = 2.0 * sin(pi*omega);
y(1) = y(1) - b*y(2);
y(2) = y(2) + b*y(1);
phase_out = mod(0.5 + 0.5*atan2(y(1), -y(2))/pi, 1);
endfunction
close all;
subplot(3, 1, 1)
plot(1:N, _lo, 1:N, x); legend('Lo', 'x'); grid