资源简介
基于matlab的锁相环程序及仿真,通过锁相环的仿真能更好的帮助人们理解锁相环的原理,从而进一步的对锁相环的优化产生兴趣

代码片段和文件信息
%%%%%%%%%%%%%%costas_PLL
close all
clear all
format long
%%%%%%%%%%%%%%%%%%%%%%
aa = input(‘input original phase of signal(degree):‘)
bb = input(‘input doppler of signal(Hz):‘)
dt = 0.001
t = 0:dt:20
num = length(t)
flo = 40;
df = bb;
A = 1;
fin = flo + df;
PHin = aa * pi/180; %pi/12;
PHase_in = 2 * pi * fin * t + PHin;
input_sig = A * sin(PHase_in);
%%%%%%%%%%%%%%
sum_time = 50;%积分时间
PHout = zeros(11);
PHase_out = 2 * pi * flo * t(1:sum_time) + PHout;
lo_sin = zeros(1sum_time);
lo_cos = zeros(1sum_time);
lo_sin(1:sum_time) = sin(PHase_out);
lo_cos(1:sum_time) = cos(PHase_out);
%%%%%%%%%%%%%%%%%%%
w12 = 0;
w22 = 0;
w32 = 0;
w52 = 0;
G = 106;%%%%%%%加快收敛速度
par2 = 10;
par1 = 1;
K = 1/2;
%%%%%%%%%%%%%%%%%%%
for n = 1:1:round(num/sum_time)-1
w12 = 0;%积分前清零
w22 = 0;%积分前清零
for m = 1:1:sum_time
nn = (n - 1) * sum_time + m;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%下变频混频
mix_sin(nn) = input_sig(nn) * lo_sin(nn);
mix_cos(nn) = input_sig(nn) * lo_cos(nn);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%低通滤波器
w11 = w12 + mix_sin(nn) * dt/2;
w13 = w11 + w12;
w12 = w11;
w21 = w22 + mix_cos(nn) * dt/2;
w23 = w21 + w22;
w22 = w21;
end
%%%%%%%%%%%%%%%%%%%%%PD鉴相器
%x = w13 * w23;
% x = atan(w23/w13);%2相鉴相
%x = w23/w13;%
x = atan2(w23w13);%4相鉴相
%%%%%%%%%%%%%%%%%%%%
xouttemp(n) = x;
pll_locked_sin(n) = sin(x);
pll_locked_cos(n) = cos(x);
%%%%%%%%%%%%%%%%%%%有源比例积分环路滤波器LF
w41 = G * sin(x);
w42 = w41 * par2/par1;
w43 = w41 * 1/par1;
w31 = w32 + w43 * dt/2;
w33 = w32 + w31;
w32 = w31;
y = w42 + w33;
%%%%%%%%%%%%%%%%%%%%VCO相位输出
w51 = w52 + y * dt/2;
w53 = w51 + w52;
w52 = w51;
PHout = K * w52;
PHouttemp(n) = PHout;
%%%%%%%%%%%%%%%%%%%%LUT输出正弦、余弦
for m = 1:1:sum_time
nm = n * sum_time + m
PHase_out(nm) = 2 * pi * flo * (nm) * dt + PHout;
PHase_outtemp(nm) = PHase_out(nm);
lo_sin(nm) = sin(PHase_out(nm));
lo_cos(nm) = cos(PHase_out(nm));
%%%%%%%%%%%%%%%%%%%%
lo_sin_out(nm) = lo_sin(nm);
lo_cos_out(nm) = lo_cos(nm);
end
end
figure(1)
subplot(211)
plot((1:num)PHin * 180/pi)
title(‘original phase of input signal‘)
xlabel(‘sample times‘)
ylabel(‘degree‘)
grid on
subplot(212)
plot((1:num)PHase_in.* 180/pi);
title(‘phase of input signal‘);
xlabel(‘sample times‘)
ylabel(‘degree‘)
grid on
figure(2)
subplot(211)
plot((1:length(PHouttemp))PHouttemp.* 180/pi + 15)
title(‘costas loop vco phase output‘)
xlabel(‘sample times‘)
ylabel(‘degree‘)
grid on
subplot(212)
plot((1:length(PHase_outtemp))PHase_outtemp.* 180/pi)
title(‘costas loop track phase‘)
xlabel(‘sample times‘);
ylabel(‘degree‘);
grid on
figure(3)
subplot(311)
plot((1:length(xouttemp))xouttemp.* 180/pi)
title(‘costas loop track error‘)
xlabel(‘sample
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3677 2009-10-25 20:46 costas_PLL.m
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论