Files
PTV_Archive/PT8612/Math/Matlab/PLL/DPLL_init_2.m
2022-02-21 17:51:05 +01:00

66 lines
1.1 KiB
Matlab

clear
wmax = 1e4;
wmin = 1e0;
%Frequency parameters:
fin=27e6;
Ndec1=91;
Ndec2=500;
fpll=fin/Ndec1;
hdecimator1 = 1/Ndec1;
hdecimator2 = 1/Ndec2;
% Phase comparator :
Tpll=1/fpll;
hphasecomparator = ss(0,1,Ndec2,0);
% Loop filter:
alpha = 2^-24%2^-12
beta = 2^-10%2^-4
% dx/dt = A*x+B*u
% Vo = C*x+D*u
% x = [Vc1 Vcp Vcs]'
% u = [ii Vth]'
hloopfilter = ss(0,1/Tpll,alpha,beta);
wkneeloop = alpha/beta/Tpll
%DAC:
Tdac = 4/148.5e6
Nbits=16
Vcc= 3.3
Mdac=3/4
hdac = Vcc*Mdac;
% RC filter :
C=680e-9
R=1/(wkneeloop*20)/C %100000
frc=1/2/pi/R/C
hrclowpass = ss(-1/C/R,1/C/R,1,0);
%VCXO characteristics:
Kvcxo=90e-6
fvcxo=148.5e6/1.001
Vvcxomin=0;
Vvcxomax=2.5;
Vvcxo0 = 1.25; %Linearization voltage
hvcxo = Kvcxo*fvcxo;
% Open loop gain:
hopenloop = hphasecomparator*hloopfilter*hdac*hrclowpass*hvcxo*hdecimator2;
figure(1)
bode(hopenloop,{wmin,wmax})
title('open loop')
grid on
% loop filter:
figure(2)
bode(hloopfilter,{wmin,wmax})
title('loop filter')
grid on
% RC filter:
figure(3)
bode(hrclowpass,{wmin,wmax})
title('RC filter')
grid on