资源简介
基于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
相关资源
- 第二版 PDF 李国勇智能预测控制及其
-
MATLAB/Simuli
nk控制论电弧仿真模型 接 - 合成孔径雷达的BP成像算法
- matlab互信息法求延迟时间
- 动态NSGA-II算法matlab代码
- LMS自适应滤波器MATLAB代码
- 基于MATLAB和FPGA的CIC滤波器.zip
- 路面谱密度matlab代码
- 通过matalb实现图形学中的扫描线填充
- 反步控制轨迹跟踪算法
- Surf特征匹配Matlab代码
- 支持向量机三分类算法
- 航位推算DR算法实现
- 捷联惯导姿态解算
- matlab 实现去噪各种算法
- IMM滤波算法
- 多级小波分解完整matlab代码
- WSN仿真-MATLAB节点个数和节点通信半径
- matlab编写的九宫格小游戏源代码
- 电力系统潮流计算MATLAB课程设计源码
- 永磁电机矢量控制模型
- VREP仿真matlab控制四轮小车到达目标位
- fuzzy-pid(模糊PID控制器)matlab simuli
- 基于matlab读取GPS中GPGGA信息(包含经纬
- DOA双向平滑(FBSS)算法
- MATLAB实现Harris角点检测与图像配准
- matlab演化博弈代码
- music算法及其改进
- 相关向量机RVM_MATLAB
- 三次样条插值三弯矩算法matlab程序.
评论
共有 条评论