声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 991|回复: 0

[线性振动] 基于RBF网络整定的PID控制

[复制链接]
发表于 2011-11-15 17:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
function RBF_PID()
%Adaptive PID control based on RBF Identification
%缺点:采样时间不能很长,学习效果不如BP
clc
clear all
close all
%%%%%%%%%%%%%%%%%%%%initial vallue and set the parameter of system %%%%%%%%
Lr=0.25;                    %RBF learn efficiency
alfa=0.05; belte=0.01;      %inertia form of learn
Lrpid=[0.5;0.33;0.4;];       %采用梯度法的PId的学习效率
input_n=3;                  %set the construct of RBF net
hidden_n=7;                 %the number of hidden
output_n=1;
h=0.001;tmax=2;             %simulation time and step length
Kpid_1=[0.03;0.03;0.01];    %PDi
   
M=0; Kpid0=[1;0.03;0.18];        %PDI控制  当M=1是仅PID控制

Ci=0.5*rand(input_n,hidden_n);Bi=0.5*rand(hidden_n,1);W=0.5*rand(hidden_n,output_n); %初始值的选取很关键,随机的优势大于都为一的情况
%%%%%%%%%%%%%%%%%%%%%%loop needed value%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y_1=0;u_1=0; input=[0;0;0]; W_1=W;W_2=W; W_3=W;
Bi_1=Bi;Bi_2=Bi;Bi_3=Bi;Ci_1=Ci;Ci_2=Ci;Ci_3=Ci;
Xc=[0;0;0]; er_1=0;er_2=0;
                                   %yacobin
for k=1:1:tmax/h
%%%%%%%%%%%%%%%%%%%%%be controled model%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   rin=1.0*(sin(2*pi*k*h));
   yout=(-0.1*y_1+u_1)/(1+y_1^2);  
   er=rin-yout;
%%%%%%%soling the output of RBF,and regulation the related parameters%%%%%%   
  for j=1:1:hidden_n
      H(j)=exp(-norm(input-Ci(:,j))^2/(2*Bi(j)*Bi(j)));  %transfer function
  end
  ymout=H*W;  err=yout-ymout;                 %RBF output
  dW=Lr*err*H.';
  W=W_1+dW+alfa*(W_1-W_2)+belte*(W_2-W_3);           %weight adjustment
  for j=1:1:hidden_n
     dBi(j)=err*W(j)*H(j)*(Bi(j)^-3)*norm(input-Ci(:,j))^2;
  end
  Bi=Bi_1+ Lr*dBi.'+alfa*(Bi_1-Bi_2)+belte*(Bi_2-Bi_3);     %扩展常熟调整
  for i=1:1:input_n
     for j=1:1:hidden_n
      dCi(i,j)=err*W(j)*H(j)*(input(i)-Ci(i,j))*(Bi(j)^-2);
     end
   end
Ci=Ci_1+Lr*dCi+alfa*(Ci_1-Ci_2)+belte*(Ci_2-Ci_3);        % center value adjustment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Jacobin calculation%%%%%%%%%%%%%%%%%%%%%%%%%%
%对象的输出对控制输入变化的灵敏度信息,通过神经网络的辨识来获得,用于稍后的Kp,Ki,Kd的调整梯度计算
  ydu=0;
for  j=1:1:6
      ydu=ydu+W(j)*H(j)*(-input(1)+Ci(1,j))/Bi(j)^2;
end

Kpid=Kpid_1+ er*ydu*(Lrpid.*Xc); Kpid(find(Kpid)<0)=0;

  switch M;  
      case 0;
      case 1
          Kpid=Kpid0;
  end;  % choose whether the RBF played role
dU=Kpid.'*Xc;
u=u_1+dU;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%parameter update%%%%%%%%%%%%%%%%%%%%%%%%%
u_1=u;input=[dU;rin;yout];y_1=yout;         %!!!输入项可更改。。但dU bu 不行
W_3=W_2;W_2=W_1; W_1=W;  Bi_3=Bi_2;Bi_2=Bi_1;Bi_1=Bi;Ci_3=Ci_2;Ci_2=Ci_1;Ci_1=Ci;
Xc=[er-er_1;er-2*er_1+er_2;er];  %PDI
er_2=er_1;er_1=er; Kpid_1=Kpid;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%output save%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
time(k)=h*k;                  %record the time
RR(k)=rin; YY(k)=yout; YYm(k)=ymout;
end
plot(time,RR,'b',time,YY,'r',time,YYm,'-.');grid on















回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 13:49 , Processed in 0.052175 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表