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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

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

matlab程序仿真报错,求解

[复制链接]
发表于 2014-6-9 11:03:06 | 显示全部楼层 |阅读模式

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

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

x
初步估计是数组错误,程序下面

%  XO Phase Noise
    dBcxO=0;    % carrier amplitude;
    fc=125e6;    % XO center frequency
    XO=[dBcxO, -55,10, -82,100,-109,1000, -129,10000,-131,100000];
    PN_XO=plotPN(f,XO); %spectrum created from above & plotted
    XOX=10*log10(PN_XO);


报错信息:
Undefined function 'plotPN' for input arguments of type 'double'.

Error in pll_loop_noise (line 140)
    PN_XO=plotPN(f,XO); %spectrum created from above & plotted
 楼主| 发表于 2014-6-9 11:18:53 | 显示全部楼层
% PLL Matlab Script
% B. Bereza
% PLL.m - V6.3 The modular version

% Created   19 Jan 1995
% Last Modified 28 Mar 2001
clear;
% Options ... if YES, set to "1". If NO, use anything else.
plot_OpenLoop=1;    % Open Loop Plots (Stability)
overlay_OL=0;       % Overlay successive plots (HOLD ON)
plot_Jtrans=1;      % Closed Loop Plots
overlay_Jtrans=0;   % Overlay successive closed loop plots (HOLD ON)
plot_JTOL=0;        % Plot Jitter Tolerance
overlay_JTOL=0;     % Overlay successive closed loop plots (HOLD ON)
plot_VCOphaseNoise=0;   % Plot VCO phase Noise (in dBc/Hz)
plot_XOphaseNoise=0;    % Plot XO phase Noise (in dBc/Hz)
plot_ROphaseNoise=0;    % Plot Residual RO phase Noise (in dBc/Hz)
plot_CL_VCOphaseNoise=0;% Plot VCO phase Noise seen at output of PLL.

% Useful Math Constructs
flo=10;         % low frequency for Plotting
fhi=1e9;            % high frequency for Plotting
numpts=10000;       % number of points for Plotting

f=logspace(log10(flo),log10(fhi),numpts);
w=2*pi*f;

% Givens & Loop Parameters
% fo=2e9
fo=2e9;            % VCO free-running frequency
UI=1/fo;        % Define Unit Interval

Ip=50e-6;       % Charge-pump nominal current
DF=1/2;         % Density Factor for Data Recovery of NRZ data
   
pfd_range=2*pi;     % PFD range [rads] from 0 to edge
%hogge_range=1*pi;  % Hogge range [rads] from 0 to edge
%Dlatch_range=.75*pi/2; % D-Latch range [rads] from 0 to edge
K2=1;           % Additional Gain of Loop Filter
K3conv=1;       % Gain inc. SEor DE conversion (2,1 or 1/2)
Kgm=1;          %Transconductance [A/V] inc. SE or DE conversion.
fp1=50e10;      % Parasitic Pole Frequency [Hz] (-3dB freq)
K3_OSC=2e9; %Nom    % Gain sensitivity [Hz/V] of VCO or [Hz/A] for ICO
%K3_OSC=1.4e9;    % Gain sensitivity [Hz/V] of VCO or [Hz/A] for ICO
Ko=2*pi*K3_OSC;     % Gain sensitivity [rads/s/V] of V/ICO

N1=10;      % Divider Ratio  

% Simple Phase-Lead Loop Filter R-C & Cshunt
r2=2e3;     % Parameters for transimpedance filter
c2=200e-12;
%cs=1*3e-12;
cs=10e-12;

% Frequency Dependent Calculations

Kpfd=Ip/pfd_range;      % PFD [A/rad] Std. Resettable type (CSU)
%Khogge=DF*Ip/hogge_range;  % Hogge [A/rad] Std. hogge PD. (CRU)
%KDlatch=DF*Ip/Dlatch_range;  % D-latch [A/rad] PD
K1=Kpfd;            % ***CHOOSE*** Gain of K1 [A/rad]  

% Loop Filter  (Simple one)
lf_num=[r2*c2 1];       % Numerator and Denominator
lf_den=[c2*cs*r2 cs+c2 0];  % in the form of s^n s^(n-1)  ...s^0

% Loop Filter ( More complex)   % Future Work
%lf_num=[r2*c2 1];      % Numerator and Denominator
%lf_den=[c2*cs*r2 cs+c2 0]; % in the form of s^n s^(n-1)  ...s^0

F2=freqs(lf_num,lf_den,w);  % ***CHOOSE*** which loop filter

% Transconductor or Gain Stage
Kgain_num=[1];      % Num and Den of parasitic pole only
Kgain_den=[1/(2*pi*fp1) 1];
F31=freqs(Kgain_num,Kgain_den,w);   % Freq. characteristics
%K31=K3conv;        % DC gain of the gain stage
K31=Kgm;        % DC gain of the transconductor

% Current-Controlled or Voltage-Controlled Oscillator  
Ko_num=[1]; Ko_den=[1 0];   % VCO/ICO has 1/s characterisic
F32=freqs(Ko_num,Ko_den,w); % Freq. Characteristics of the VCO/ICO
K32=Ko;             % Gain of the VCO/ICO [rads/s/V] or [rads/s/A]

% Total VCO or ICO
K3=K31*K32;         % Total gain (K3)  
F3=F31.*F32;            % Total Freq. response of the VCO.

% Divider
fref=fo/N1;     % Fref is the compare frequency.
Tref=1/fref;
Fdiv=(1-exp(-1*j.*w./fref))./(j.*w./fref);  
% The exact version (limited analysis possible)

ii=60;      
for i=ii:-1:1,              % The series expansion version
% Fdivx_num(ii+1-i)=(-1)^(i+1)/fac(i)*Tref^(i-1);
Fdivx_num(ii+1-i)=(-1)^(i+1)/factorial(i)*Tref^(i-1);
end
Fdivx_den=[1];
Fdivx=freqs(Fdivx_num,Fdivx_den,w);
Nx=N1./Fdivx;        % Divider with Sampling Delay (expansion based)
N=N1./Fdiv;          % Divider with Sampling Delay (pure) or PD-referred.
%N=N1;               % Divider with no Sampling effects at all.


% Open Loop (Stability)

G=K1*K2*K3.*F2.*F3./N;     % Pure method (No Bilinear possible later)

%Gs_num=K1*K2*K3*conv(conv(conv(lf_num,Kgain_num),Ko_num),Fdivx_num);   
% Expansion method in S
%Gs_den=N1*(conv(conv(lf_den,Kgain_den),Ko_den));
%Gs=freqs(Gs_num,Gs_den,w);    % Expansion method for comparison with Pure

% Closed Loop (Jitter Transfer) See Notes at end of this script.
A=K1*K2*K3.*F2.*F3;     % Forward Loop
B=1./N;             % Feedback Loop
Jtrans=A./(1+A.*B);     % Jitter Transfer - Direct output of the VCO
H=1./N.*A./(1+A.*B);  % Compare Transfer Function - VCO divided down.
M=1-H;              % Phase Error Transfer Function
P0=1./(1+A.*B);   % Power-Supply Noise Transfer Function at output of VCO
Vtrans=1./(1+A.*B);     % VCO Perturbation transfer function
P3=1./N.*1./(1+A.*B);  % Power-Supply Noise Transfer Function at PD output
Jtol=1./(1-H);          % Jitter Tolerance
%Jtol=1./(1-Jtrans);       % Jitter Tolerance Multiplier

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  PNoise Notes...
%  PNoise - Takes the form..[Carrier dBm, dBc/Hz(f4),.. dBc/Hz(f0)]
%  Notes: If Carrier dBm is not known, set to 0dBm.
%         OR if quoted in dBc/Hz, set to 0dBm.
%         dBc/Hz @ f4 (on 40dB/dec slope), freq at measurement
%         set to -900 if there is no measurement with freq
%         dBc/Hz @ f0 (thermal only, at freq. of measurement)

%  XO Phase Noise
    dBcxO=0;    % carrier amplitude;
    fc=125e6;    % XO center frequency
    XO=[dBcxO, -55,10, -82,100,-109,1000, -129,10000,-131,100000];
    PN_XO=plotPN(f,XO); %spectrum created from above & plotted
    XOX=10*log10(PN_XO);
    %[jitdBc,jitUIrms,jitRMSw]=jitter(fc,f,PN_XO,10e3,80e6);
    % determine jitter
%jitRMSw

%  Residual Phase Noise
    dBcrO=0;    % carrier amplitude;
    fc=125e6/N1; % XO center frequency
    RO=[dBcrO, -51,10,-82,100,-109.0,1000,-129,10000,-131,100000];
    PN_RO=plotPN(f,RO); %spectrum created from above & plotted
    XRX=10*log10(PN_RO);
    %[jitdBc,jitUIrms,jitRMSr]=jitter(fc,f,PN_RO,10e3,80e6);
    % determine jitter
%jitRMSr

%semilogx(f,-dBcO+30+10*log10(PN_XO));
%  Residual PD Phase Noise
%  NF and Gain of forward loop required. Use kTB, with B=1
%  VCO Phase Noise
%  See Note below on possible overestimation of
%  phase noise jitter and spectrum Note4.
    dBcO=0;     % carrier amplitude;
    fc=2e9; % VCO center frequency
    VCO=[dBcO, -56,10,-82,100,-109,1000,-129,10000,-132,1e7];
    PN_VCO=plotPN(f,VCO);  %spectrum created from above & plotted
    XXX=10*log10(PN_VCO);
    %[jitdBc,jitUIrms,jitRMSg]=jitter(fc,f,PN_VCO,10e0,10e6);
    % determine jitter
%jitRMSg
%semilogx(f,XXX);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Total Noise from Most Sources... (Have not included Wireless stuff)
% NTM - I should want to put in AM to PM (V-Phi) Noise
% Remember... Keep to PSDs so PN_VCO should be multiplied by abs(Vtrans)^2
PNtot_vco=PN_VCO.*(abs(Vtrans)).^2;
PNtot_ref=PN_XO.*(abs(Jtrans)).^2;
PNtot_div=PN_RO.*(abs(Jtrans)).^2;
PNtot=(PN_XO+PN_RO).*(abs(Jtrans)).^2+PN_VCO.*(abs(Vtrans)).^2;
    [jitdBc,jitUIrms,jitRMSv]=jitter(fc,f,PNtot_vco,10e0,10e6);
    % determine jitter jitRMSv

if plot_CL_VCOphaseNoise==1
figure
semilogx(f,10*log10(abs(PNtot_vco)),'r');
hold on
semilogx(f,10*log10(abs(PNtot_ref)),'c');
semilogx(f,10*log10(abs(PNtot_div)),'g');
semilogx(f,10*log10(abs(PNtot)))
end


% Plotting  (Set this at beginning of program)
if plot_OpenLoop==1
    plotOL(G,f,overlay_OL);
end

if plot_Jtrans==1
    plotCL(Jtrans,H,M,f,overlay_Jtrans);
end

if plot_JTOL==1
%   plotJTOL(Jtol,f,overlay_JTOL);
    plotJTOL(Jtol,H,M,f,overlay_JTOL);
end
if plot_ROphaseNoise==1
    figure;
    semilogx(f,XRX);
end

if plot_XOphaseNoise==1
    figure;
    semilogx(f,XOX);
end
if plot_VCOphaseNoise==1
    figure;
    semilogx(f,XXX);
end


%Notes:
%1) See Documentation on this program for further details.
%2) Power supply noise transfer functions:
%Power supply attenuation is defined as theta_out/theta_disturbance,where
%theta_out occurs at the same location as theta_disturbance.
% Dividing down by any N (ie. along
%the divder chain will produce Pxx.
%3)
%4) Phase Noise near transition points will approach 6dB too
%much due to superposition as opposed to theoretical.
%In reality, this is real!, so do not subtract it.





这个是整个PLL噪声的程序。
发表于 2016-8-1 10:25:57 | 显示全部楼层
楼主能发一下你的matalb PLL 建模程序吗?不胜感谢!
发表于 2016-8-5 20:11:32 | 显示全部楼层
太长了,看的好捉急
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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


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

GMT+8, 2024-12-23 02:22 , Processed in 0.025389 second(s), 9 queries , Gzip On, Redis On.

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