锁相环仿真(基于MATLAB)Word文档格式.doc
《锁相环仿真(基于MATLAB)Word文档格式.doc》由会员分享,可在线阅读,更多相关《锁相环仿真(基于MATLAB)Word文档格式.doc(10页珍藏版)》请在冰豆网上搜索。
1.2.2低通滤波器
低通滤波器(LF)的将上式中的和频分量滤掉,剩下的差频分量作为压控振荡器的输入控制电压uC(t)。
即uC(t)为:
式中的ωi为输入信号的瞬时振荡角频率,θi(t)和θO(t)分别为输入信号和输出信号的瞬时位相,根据相量的关系可得瞬时频率和瞬时位相的关系为:
即
则,瞬时相位差θd为
对两边求微分,可得频差的关系式为
上式等于零,说明锁相环进入相位锁定的状态,此时输出和输入信号的频率和相位保持恒定不变的状态,uc(t)为恒定值。
当上式不等于零时,说明锁相环的相位还未锁定,输入信号和输出信号的频率不等,uc(t)随时间而变。
1.2.3压控振荡器
压控振荡器(VCO)的压控特性如图示
该特性说明压控振荡器的振荡频率ωu以ω0为中心,随输入信号电压uc(t)线性地变化,变化的关系如下:
上式说明当uc(t)随时间而变时,压控振荡器(VCO)的振荡频率ωu也随时间而变,锁相环进入“频率牵引”,自动跟踪捕捉输入信号的频率,使锁相环进入锁定的状态,并保持ω0=ωi的状态不变。
2.信号流程图
锁相环的原理框图如下:
其工作过程如下:
(1)压控振荡器的输出Uo经过采集并分频;
(2)输出和基准信号同时输入鉴相器;
(3)鉴相器通过比较上述两个信号的频率差,然后输出一个直流脉冲电压Ud;
(4)Ud进入到滤波器里面,滤除高频成分后得到信息Ue;
(5)Ue进入到压控震荡器VCO里面,控制频率随输入电压线性地变化;
(6)这样经过一个很短的时间,VCO的输出就会稳定于某一期望值。
3.二阶环仿真源程序代码及仿真结果
3.1程序代码:
%File:
c6_nltvde.m
w2b=0;
w2c=0;
%initializeintegrators
yd=0;
y=0;
%initializedifferentialequation
tfinal=50;
%simulationtime
fs=100;
%samplingfrequency
delt=1/fs;
%samplingperiod
npts=1+fs*tfinal;
%numberofsamplessimulated
ydv=zeros(1,npts);
%vectorofdy/dtsamples
yv=zeros(1,npts);
%vectorofy(t)samples
%
%beginningofsimulationloop
fori=1:
npts
t=(i-1)*delt;
%time
ift<
20
ydd=4*exp(-t/2)-3*yd*abs(y)-9*y;
%defort<
else
ydd=4*exp(-t/2)-3*yd-9*y;
%defort>
=20
end
w1b=ydd+w2b;
%firstintegrator-step1
w2b=ydd+w1b;
%firstintegrator-step2
yd=w1b/(2*fs);
%firstintegratoroutput
w1c=yd+w2c;
%secondintegrator-step1
w2c=yd+w1c;
%secondintegrator-step2
y=w1c/(2*fs);
%secondintegratoroutput
ydv(1,i)=yd;
%builddy/dtvector
yv(1,i)=y;
%buildy(t)vector
end %endofsimulationloop
plot(yv,ydv) %plotphaseplane
xlabel('
y(t)'
) %labelxaxis
ylabel('
dy/dt'
) %labelyzxis
%Endofscriptfile.
pllpost.m
kk=0;
whilekk==0
k=menu('
PhaseLockLoopPostprocessor'
...
'
InputFrequencyandVCOFrequency'
InputPhaseandVCOPhase'
FrequencyError'
'
PhaseError'
PhasePlanePlot'
PhasePlaneandTimeDomainPlots'
ExitProgram'
);
ifk==1
plot(t,fin,'
k'
t,fvco,'
)
title('
InputFrequencyandVCOFreqeuncy'
xlabel('
Time-Seconds'
Frequency-Hertz'
pause
elseifk==2
pvco=phin-phierror;
plot(t,phin,t,pvco)
Phase-Radians'
elseifk==3
plot(t,freqerror);
title('
FrequencyError-Hertz'
elseifk==4
plot(t,phierror);
PhaseError-Radians'
elseifk==5
ppplot
elseifk==6
subplot(211);
phierrn=phierror/pi;
plot(phierrn,freqerror,'
grid;
PhaseError/Pi'
ylabel('
subplot(212)
grid
subplot(111)
elseifk==7
kk=1;
endend%Endofscriptfile.
pllpre.m
clearall %besafe
disp('
'
)%insertblankline
fdel=input('
EnterthesizeofthefrequencystepinHertz>
fn=input('
EntertheloopnaturalfrequencyinHertz>
lambda=input('
Enterlambda,therelativepoleoffset>
Acceptdefaultvalues:
'
zeta=1/sqrt
(2)=0.707,'
fs=200*fn,and'
tstop=1'
dtype=input('
Enteryforyesornforno>
s'
ifdtype=='
y'
zeta=1/sqrt
(2);
fs=200*fn;
tstop=1;
else
zeta=input('
Enterzeta,theloopdampingfactor>
fs=input('
EnterthesamplingfrequencyinHer