📄 pll_mod_param.m
字号:
% Lab #3 - integer-N PLL parameters%% note: this matlab m-file is used to compute the PLL parameters% for the simulink model. you have to design the loop filters% such that the PLL is stable (i.e. choose a suitable damping factor% zeta)%% Author: Walt Bax% Date: November 25, 1998%%-----------------------------------------------------------echo off;if ~exist('gc') gc='b';endstr=sprintf('graph colour <%s>: ',gc);buff=input(str,'s');if ~isempty(buff) gc=buff;endif ~exist('samples') samples=5000; % set initial # samples for time domainendnpts=800;if ~exist('fr') fr=10e6;endstr=sprintf('Reference frequency <%4.1fMHz>: ',fr/1e6); buff=input(str);if ~isempty(buff) fr=buff;endT=1/fr;if ~exist('gmode') gmode='log';endstr=sprintf('x-axis (lin|log) <%s>: ',gmode);buff=input(str,'s');if ~isempty(buff) clf; % clear figure for new graph mode gmode=buff;endf=logspace(1,log10(fr-1),npts);%-----------------------------------------------------------% given PLL loop parametersBW=;Kphi=2;Kv=50e6;N=;K=Kphi*Kv/N;%-----------------------------------------------------------% PFD [rad] --> [V]Bpfd=Kphi*[1];Apfd=[1];Hpfd=freqs(Bpfd,Apfd,2*pi*f);%-----------------------------------------------------------% loop filter 1 - analog integrator with compensating zero%% B(s) (Tau2)s + 1 % H(s) = ---- = ------------% A(s) (Tau1)sif (1)zeta=; % zeta specified for this filterTau2=;Tau1=;Bloop=[Tau2 1];Aloop=[Tau1 0];Hloop1=freqs(Bloop,Aloop,2*pi*f);end%-----------------------------------------------------------% VCO [V] --> [rad]Bvco=2*pi*Kv*[1];Avco=[1 0];Hvco=freqs(Bvco,Avco,2*pi*f);%-----------------------------------------------------------% PLL frequency responseHloop=Hloop1; % choose a loop filterHopen=Hpfd.*Hloop.*Hvco/N; % PLL open-loop responseHclose=Hpfd.*Hloop.*Hvco./(1 + Hopen); % PLL closed-loop response%-----------------------------------------------------------% plot routinetf=input('transfer function: ');fprintf(1,' fr = %2.0fMHz\n',fr/1e6);fprintf(1,' BW = %2.1fKHz\n',BW/1e3);%fprintf(1,' Wn = %2.1fKHz\n',wn/(2*pi)/1e3);%fprintf(1,'zeta = %3.1f\n',zeta);fprintf(1,' K = %3.0f\n',K);if ~isempty(tf) mag=abs(tf); % magnitude response phase=360/(2*pi)*unwrap(angle(tf)); % phase response [deg] %clf; subplot(2,1,1); semilogx(f,20*log10(mag),gc); grid on hold on; plot([min(f) max(f)],[0 0],'r'); plot(2*pi*BW,0,'ro'); title('Transfer function'); xlabel('Frequency (Hz)'); ylabel('Gain (dB)'); subplot(2,1,2); semilogx(f,phase,gc); grid on hold on; plot([min(f) max(f)],[-180 -180],'r'); xlabel('Frequency (Hz)'); ylabel('Phase (deg)');end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -