微分器描述
离散形式的非线性微分跟踪为
其中,h为采样周期;v(k)为第k时刻的输入信号,为决定跟踪快慢的系数;fst()为最速控制综合函数。描述如下
仿真分析
微分器测试
输入信号v(t)=sin2pit,采样周期h=0.001,δ=150;扰动信号为0.05的随机信号;
上图为带有噪声的正弦信号;下图为理想信号和微分跟踪器的输出信号;
上图为理想微分信号与差分求得的微分信号;
下图为理想微分信号和经过微分器输出的微分信号;
代码如下所示:
clear all;
close all;
h=0.001; %Sampling time
delta=150;
r1_1=0;r2_1=0;
vn_1=0;
for k=1:1:10000
time(k)=k*h;
v(k)=sin(2*pi*k*h);
n(k)=0.05*rands(1);
vn(k)=v(k)+n(k);
dv(k)=2*pi*cos(2*pi*k*h);
r1(k)=r1_1+h*r2_1;
r2(k)=r2_1+h*fst(r1_1-v(k),r2_1,delta,h);
dvn(k)=(vn(k)-vn_1)/h; %By difference
vn_1=vn(k);
r1_1=r1(k);
r2_1=r2(k);
end
figure(1);
subplot(211);
plot(time,v,'k:',time,vn,'r:','linewidth',2);
xlabel('time(s)'),ylabel('signal');
legend('ideal signal','signal with noise');
subplot(212);
plot(time,v,'k:',time,r1,'r:','linewidth',2);
xlabel('time(s)'),ylabel('signal');
legend('ideal signal','signal by TD');
figure(2);
subplot(211);
plot(time,dv,'k:',time,dvn,'r:','linewidth',2);
xlabel('time(s)'),ylabel('derivative signal');
legend('ideal derivative signal','derivative signal by difference');
subplot(212);
plot(time,dv,'k:',time,r2,'r:','linewidth',2);
xlabel('time(s)'),ylabel('derivative signal');
legend('ideal derivative signal','derivative signal by TD');
基于微分器的pd控制
输入信号v(t)=sint,采样周期h=0.001,δ=1000;扰动信号为0.05的随机信号;
控制对象:133/s2+25s
此时微分器的输入信号为对象的输出信号,采用微分器获取位置信息和速度信息;kp=10,kd=0.05;
红色为含有噪声的输入信号,蓝色为经过微分器处理的输入信号
黑色为理想的参考信号sin(t),红色为经过微分器处理后的反馈信号;
黑色为理想的微分参考信号cos(t),红色为经过微分器处理后的微分信号;
代码:
close all;
clear all;
h=0.001; % 采样周期
y_1=0;yp_1=0;
dy_1=0;
%Plant
a=25;b=133;
sys=tf(b,[1,a,0]);
dsys=c2d(sys,h,'z');
[num,den]=tfdata(dsys,'v');
u_1=0;u_2=0;
p_1=0;p_2=0;
for k=1:1:5000
t=k*h;
time(k)=t;
p(k)=-den(2)*p_1-den(3)*p_2+num(2)*u_1+num(3)*u_2;
dp(k)=(p(k)-p_1)/h;
yd(k)=sin(t);
dyd(k)=cos(t);
d(k)=0.5*sign(rands(1)); %Noise
%d(k) = 0;
if mod(k,100)==1|mod(k,100)==2
yp(k)=p(k)+d(k); %Practical signal
else
yp(k)=p(k);
end
M=2;
if M==1 %By Difference
y(k)=yp(k);
dy(k)=(yp(k)-yp_1)/h;
elseif M==2 %By TD
delta=1000;
y(k)=y_1+h*dy_1;
dy(k)=dy_1+h*fst(y_1-yp(k),dy_1,delta,h);
end
kp=10;kd=0.5;
u(k)=kp*(yd(k)-y(k))+kd*(dyd(k)-dy(k));
%u(k) = yd(k);
y_1=y(k);
yp_1=yp(k);
dy_1=dy(k);
u_2=u_1;u_1=u(k);
p_2=p_1;p_1=p(k);
end
figure(1);
plot(time,p,'k',time,yp,'r:',time,y,'b:','linewidth',2);
xlabel('time(s)');ylabel('position tracking');
legend('ideal position signal','position signal with noise','position signal by TD');
figure(2);
plot(time,yd,'k',time,p,'r:','linewidth',2);
xlabel('time(s)');ylabel('Position tracking');
legend('ideal position signal','tracking signal');