本蚊介绍了仿真的环境以及二阶锁相环的仿真过程,并对其仿真结果进行了分析。在前三章的理论基础上,通过使用MATLAB7.0进行了仿真。
验结果表明:用MATLAB进行的二阶锁相环仿真达到了最初的设想,锁相环的失锁、跟踪、捕获、锁定各个阶段均有体现。达到了最初仿真的要求。
(典型仿真案例)图
仿真使用软件MATLAB7.0
仿真使用的软件是MATLAB7.0。由于MATLAB仿真软件适合多学科、多种工作平台且功能强大、界面友好、方便快捷、语言自然并且开放性强的大型优秀应用软件,已经也已成为国内外高等院校高等数学、数值分析、数字信号处理、自动控制理论以及工程应用等课程的基本教学工具。使用Matlab对锁相环仿真的实现是方便快捷的。
仿真采用二阶锁相环
仿真所采用的是二阶锁相环。这是由于我们实际应用中的绝大多数PLL,或者是二阶的,或者是通过忽略高阶效应(至少在初步设计时)而被设计成近似的二阶环路。鉴于二阶锁相环在实际应用的意义,所以在仿真采用了二阶锁相环。
MATLAB仿真程序代码
% File: c6_nltvde.m
w2b=0; w2c=0; % iniTIalize integrators
yd=0; y=0; % iniTIalize differenTIal equaTIon
tfinal = 50; % simulation time
fs = 100; % sampling frequency
delt = 1/fs; % sampling period
npts = 1+fs*tfinal; % number of samples simulated
ydv = zeros(1,npts); % vector of dy/dt samples
yv = zeros(1,npts); % vector of y(t) samples
%
% beginning of simulation loop for i=1:npts t = (i-1)*delt;
% time
if t《20
ydd = 4*exp(-t/2)-3*yd*abs(y)-9*y; % de for t《20
else
ydd = 4*exp(-t/2)-3*yd-9*y;
% de for t》=20 end
w1b=ydd+w2b; % first integrator - step 1 w2b=ydd+w1b;
% first integrator - step 2
yd=w1b/(2*fs); % first integrator output w1c=yd+w2c; % second integrator - step 1 w2c=yd+w1c;
% second integrator - step 2
y=w1c/(2*fs); % second integrator output ydv(1,i) = yd; % build dy/dt vector yv(1,i) = y; % build y(t) vector end
% end of simu