在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 1655|回复: 3

[资料] Phase-Locked Loops matlab code 锁相环参考代码范例

[复制链接]
发表于 2022-8-27 09:40:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
% EE 536: Phase-Locked Loops
%
% Matlab code for estimating total PLL phase noise
% Thanks to Aniruddhan Sankaran for providing the basis for this code
%

function Phase_Noise(PN_pcl, PN_vco, PN_div)
%
% PN_div - divider phase noise profile (from Cadence)
% PN_pcl - PFD/CP/LPF amplitude noise profile (from Cadence)
% PN_vco - VCO phase noise profile (from Cadence)
%

fstart=10e3;     % starting at 10kHz
fstep=10e3;      % freq step is 10kHz
fstop=10e6;     % stop freq is 10MHz

f=fstart:fstep:fstop;   % generate frequency vector
w=2*pi*f;

%%%% PLL Specification %%%%
%
% You will have to change these values to match those of your PLL
% You will need to change F, the loop filter transfer function to match
% that of your chosen loopfilter, right now it is configured with the
% "stock" loop filter values.
%

N=195;              % nominal division ratio
N_pre=2;            % prescaler division ratio
Kvco=2*pi*55.6e6;   % VCO gain
Icp=100e-6;         % charge pump current = 100 uA
Kpd=Icp/(2*pi);     % phase detector gain

R=156e3;            % resistor value
C=2.9e-12;          % capacitor value
F = R + 1./(j*w*C); % loop filter transfer function

%%%% Calculate the Loop Transfer Functions

A = Kpd*F*Kvco./(j*w);   % forward gain
B = 1/N;                 % feedback gain

H = A./(1+A*B);          % closed-loop TF
E = H.*j.*w./(Kpd*Kvco*F); % error TF

figure;
semilogx(f,20*log10(abs(H)));   % plot closed-loop TF
title('Closed-Loop Transfer Function');
grid ON;

figure;
semilogx(f,20*log10(abs(E)));   % plot error TF
title('Error Transfer Function');
grid ON;

%%%% Reference phase noise

PN_ref = -150 - 3*log10(f/1000);        % reference phase noise specified in dB
PN_out_ref = PN_ref + 20*log10(abs(H)); % output phase noise due to reference

%%%% Divider phase noise

PN_out_div = PN_div' + 20*log10(abs(H));      % output phase noise due to divider

%%%% PFD-CP-LPF combination phase noise

PN_out_pcl = PN_pcl' + 20*log10(abs(H./(Kpd*f)));       % output phase noise due to PFD-CP-LPF

%%%% VCO phase noise

PN_out_vco = PN_vco' + 20*log10(abs(E));   % output phase noise due to VCO

%%%% Total output phase noise

PN_out = 10*log10(10.^(PN_out_ref/10)+10.^(PN_out_div/10)+10.^(PN_out_pcl/10)+10.^(PN_out_vco/10));

figure;
grid ON;
semilogx(f,PN_out_ref, f,PN_out_div, f,PN_out_pcl, f,PN_out_vco, f,PN_out);
title('Output Phase Noise');
xlabel('Freq (Hz)');
ylabel('Phase Noise (dB)');
text(1e4,-130, ['Phase noise at 10 kHz = ',num2str(PN_out(1))]);        % Print phase noise totals
text(1e4,-140, ['Phase noise at 500 kHz = ',num2str(PN_out(100))]);     % You may need to adjust the
text(1e4,-150, ['Phase noise at 10 MHz = ',num2str(PN_out(2000))]);     % positioning on these.
axis([min(f),max(f),min(PN_out),max(PN_out)]);
axis 'auto y';



Phase_Noise.tar (4.5 KB, 下载次数: 76 )
Simulink Demo-1.tar (637.5 KB, 下载次数: 79 )




发表于 2022-8-29 10:46:38 | 显示全部楼层
多谢分享
发表于 2023-9-13 16:15:03 | 显示全部楼层
PN_out_pcl = PN_pcl' + 20*log10(abs(H./(Kpd*f)));       % output phase noise due to PFD-CP-LPF
PN_out_vco = PN_vco' + 20*log10(abs(E));   % output phase noise due to VCO

请问一下,这两句运行的时候有问题

点评

请问后来解决了吗?  发表于 2024-4-12 17:49
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-23 02:10 , Processed in 0.022673 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表