锁相环仿真(基于MATLAB)
更新时间:2023-05-02 02:55:01 阅读量: 实用文档 文档下载
锁相环仿真
1.锁相环的理论分析
1.1锁相环的基本组成
锁相环路是一种反馈控制电路,简称锁相环(PLL,Phase-Locked Loop)。锁相
环的特点是:利用外部输入的参考信号控制环路部振荡信号的频率和相位。因锁相环可以实现输出信号频率对输入信号频率的自动跟踪,所以锁相环通常用于闭环跟踪电路。锁相环在工作的过程中,当输出信号的频率与输入信号的频率相等时,输出电压与输入电压保持固定的相位差值,即输出电压与输入电压的相位被锁住,这就是锁相环名称的由来。锁相环通常由鉴相器(PD,Phase Detector)、环路滤波器(LF,Loop Filter)和压控振荡器(VCO,Voltage Controlled Oscillator)三部分组成,锁相环组成的原理框图如图示:
锁相环中的鉴相器又称为相位比较器,它的作用是检测输入信号和输出信号的相位差,并将检测出的相位差信号转换成u
D
(t)电压信号输出,该信号经低通滤
波器滤波后形成压控振荡器的控制电压u
C
(t),对振荡器输出信号的频率实施控制。
1.2锁相环的工作原理
1.2.1鉴相器
锁相环中的鉴相器(PD)通常由模拟乘法器组成,利用模拟乘法器组成的鉴相器电路如图示:
鉴相器的工作原理是:设外界输入的信号电压和压控振荡器输出的信号电压分别为:
式中的ω
为压控振荡器在输入控制电压为零或为直流电压时的振荡角频率,称
为电路的固有振荡角频率。则模拟乘法器的输出电压u
D
为:
1.2.2 低通滤波器
低通滤波器(LF)的将上式中的和频分量滤掉,剩下的差频分量作为压控振荡器
的输入控制电压u
C (t)。即u
C
(t)为:
.. ..
. . . .
式中的ωi 为输入信号的瞬时振荡角频率,θi (t )和θO (t )分别为输入信号和输出信号的瞬时位相,根据相量的关系可得瞬时频率和瞬时位相的关系为: 即
则,瞬时相位差θd 为
对两边求微分,可得频差的关系式为
上式等于零,说明锁相环进入相位锁定的状态,此时输出和输入信号的频率和相位保持恒定不变的状态,u c (t )为恒定值。当上式不等于零时,说明锁相环的相位还未锁定,输入信号和输出信号的频率不等,u c (t )随时间而变。
1.2.3 压控振荡器
压控振荡器(VCO )的压控特性如图示
该特性说明压控振荡器的振荡频率ωu 以ω0为中心,随输入信号电压u c (t )线性地变化,变化的关系如下:
上式说明当u c (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; % 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 simulation loop
plot(yv,ydv) % plot phase plane
xlabel('y(t)') % label x axis
ylabel('dy/dt') % label y zxis
% End of script file.
% File: pllpost.m
%
kk = 0;
while kk == 0
k = menu('Phase Lock Loop Postprocessor',...
'Input Frequency and VCO Frequency',...
'Input Phase and VCO Phase',...
'Frequency Error','Phase Error','Phase Plane Plot',...
'Phase Plane and Time Domain Plots','Exit Program');
if k == 1
. . . .
.. ..
plot(t,fin,'k',t,fvco,'k')
title('Input Frequency and VCO Freqeuncy')
xlabel('Time - Seconds');ylabel('Frequency - Hertz');pause
elseif k ==2
pvco=phin-phierror;plot(t,phin,t,pvco)
title('Input Phase and VCO Phase')
xlabel('Time - Seconds');ylabel('Phase - Radians');pause
elseif k == 3
plot(t,freqerror);title('Frequency Error')
xlabel('Time - Seconds');ylabel('Frequency Error - Hertz');pause
elseif k == 4
plot(t,phierror);title('Phase Error')
xlabel('Time - Seconds');ylabel('Phase Error - Radians');pause
elseif k == 5
ppplot
elseif k == 6
subplot(211);phierrn = phierror/pi;
plot(phierrn,freqerror,'k');grid;
title('Phase Plane Plot');xlabel('Phase Error /Pi'); ylabel('Frequency Error - Hertz');subplot(212)
plot(t,fin,'k',t,fvco,'k');grid
title('Input Frequency and VCO Freqeuncy')
xlabel('Time - Seconds');ylabel('Frequency - Hertz');subplot(111)
elseif k == 7
kk = 1;
end end % End of script file.
% File: pllpre.m
%
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 % File: pll2sin.m
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.
function [] = pplane(x,y,nsettle)
% Plots the phase plane with phase in the range (-pi,pi)
ln = length(x);
maxfreq = max(y);
minfreq = min(y);
close % Old figure discarded
axis([-1 1 1.1*minfreq 1.1*maxfreq]); % Establish scale
hold on % Collect info for new fig
j = nsettle;
while j < ln
i = 1;
while x(j) < pi & j < ln
a(i) = x(j)/pi;
b(i) = y(j);
j = j+1;
i = i+1;
end
plot(a,b,'k')
a = [];
b = [];
x = x - 2*pi;
end
hold off
title('Phase-Plane Plot')
xlabel('Phase Error / Pi')
ylabel('Frequency Error in Hertz')
grid % End of script file. % File: ppplot.m
% ppplot.m is the script file for plotting phase plane plots. If the % phase plane is constrained to (-pi,pi) ppplot.m calls pplane.m.
kz = 0;
while kz == 0
k = menu('Phase Plane Options',...
'Extended Phase Plane',...
'Phase Plane mod(2pi)',...
'Exit Phase Plane Menu');
. . . .
正在阅读:
锁相环仿真(基于MATLAB)05-02
药物化学心血管系统药物习题及答案04-06
一句让我心潮澎湃的话作文600字06-29
过早穿高跟鞋 追溯产妇生BB侧切率高根源03-06
小学生阳光优秀作文100字06-15
超过保质期食品和收回食品管理及处置制度01-21
写一种美食的作文6篇03-31
基金管理公司机构投资者问卷调查表11-03
成长的感悟作文650字07-06
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 仿真
- 基于
- MATLAB
- 2020年春七年级语文下册第三单元11台阶教案新人教版
- 完整word版电气专业英语词汇大全
- 超声科图像质量评价评分标准细则
- 小学语文课堂教育评价策略研究【开题报告】
- 中国结缕草属_Zoysiaspp__植物抗寒性评价
- 酒店粤菜厅服务员日常工作流程
- 郑州年味社会实践活动报告范文doc
- 主日学第一年教材-列祖-07伯拉拉罕蒙召~1
- 2013年六年级英语测评及答案
- 市场营销习题集和答案
- 2014届高考语文一轮复习题库精选(江苏): 正确使用词语(包括熟语)
- 嘉兴市2019-2020学年八年级下期中考试英语试卷(有答案)(精校版)
- 新视角研究生英语读说写2部分课文翻译及课后练习翻译
- 混凝土结构设计原理试题及答案
- 猎头服务合同模板通用版
- 食品经营场所内部设施布局平面图和食品经营操作流程
- 采油工程技术员岗位竞聘自我介绍.doc
- 快递自动化分拣系统的开发
- 内部控制的国内外研究现状分析
- 高中物理--交变电流单元测试题