matlab costas环,Matlab的costas环的FPGA 实现

谢谢楼主的附件了

不过我也是刚研究PLL,感觉其实质很多东西还弄得不大明白

那个怎么计算我也不清楚,不好意思哈

我这里有一个在这个论坛下的PLL的程序,你可以看看,不知是否有帮助

(1)

% File: pllpre.m

% Software given here is to accompany the textbook: W.H. Tranter,

% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of

% Communication Systems Simulation with Wireless Applications,

% Prentice Hall PTR, 2004.

%

clear all                                                % be safe

disp(' ')                       % insert blank line

fdel = input('Enter the size of the frequency step in Hertz > ');

fn = input('Enter the loop natural frequency in Hertz > ');

lambda = input('Enter lambda, the relative pole offset > ');

disp(' ')

disp('Accept default values:')

disp(' zeta = 1/sqrt(2) = 0.707,')

disp(' fs = 200*fn, and')

disp(' tstop = 1')

dtype = input('Enter y for yes or n for no  > ','s');

if dtype == 'y'

zeta = 1/sqrt(2);

fs = 200*fn;

tstop = 1;

else

zeta = input('Enter zeta, the loop damping factor > ');

fs = input('Enter the sampling frequency in Hertz > ');

tstop = input('Enter tstop, the simulation runtime > ');

end

%

npts = fs*tstop+1;              % number of simulation points

t = (0:(npts-1))/fs;            % default time vector

nsettle = fix(npts/10);         % set nsettle time as 0.1*npts

tsettle = nsettle/fs;           % set tsettle

%

% The next two lines establish the loop input frequency and phase

% deviations.

%

fin = [zeros(1,nsettle),fdel*ones(1,npts-nsettle)];

phin = [zeros(1,nsettle),2*pi*fdel*t(1:(npts-nsettle))];

%

disp(' ')                       % insert blank line

%       end of script file pllpre.m

(2)

% File: pll2sin.m

% Software given here is to accompany the textbook: W.H. Tranter,

% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of

% Communication Systems Simulation with Wireless Applications,

% Prentice Hall PTR, 2004.

%

w2b=0; w2c=0; s5=0; phivco=0;                                %initialize

twopi=2*pi;                                                                        % define 2*pi

twofs=2*fs;                                                                        % define 2*fs

G=2*pi*fn*(zeta+sqrt(zeta*zeta-lambda));        % set loop gain

a=2*pi*fn/(zeta+sqrt(zeta*zeta-lambda));        % set filter parameter

a1=a*(1-lambda); a2 = a*lambda;                                % define constants

phierror = zeros(1,npts);                                          % initialize vector

fvco=zeros(1,npts);                                                        % initialize vector

%

% beginning of simulation loop

%

for i=1:npts

s1=phin(i) - phivco;                                % phase error

s2=sin(s1);                                % sinusoidal phase detector

s3=G*s2;

s4=a1*s3;

s4a=s4-a2*s5;                           % loop filter integrator input

w1b=s4a+w2b;                                                % filter integrator (step 1)

w2b=s4a+w1b;                                                % filter integrator (step 2)

s5=w1b/twofs;                                                % generate fiter output

s6=s3+s5;                               % VCO integrator input

w1c=s6+w2c;                                                        % VCO integrator (step 1)

w2c=s6+w1c;                                                        % VCO integrator (step 2)

phivco=w1c/twofs;                                        % generate VCO output

phierror(i)=s1;                                                % build phase error vector

fvco(i)=s6/twopi;                                        % build VCO input vector

end

%

% end of simulation loop

%

freqerror=fin-fvco;                                                                % build frequency error vector

% End of script file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值