1、基于状态空间方程和置根法的汽车的匀速巡航控制 基于状态空间方程和置根法的汽车的匀速巡航控制 框图如下: 传递函数为: 利用置根法的Matlab 程序 求 反馈系数矩阵 K,并输出响应结果:m = 1000;b = 50;t = 0:0.1:10;r = ones(size(t);A = -b/m;B = 1/m;C = 1;D = 0;sys = ss(A,B,C,D);x0 = 0;p1 = -1.5;K = place(A,B,p1)sys_cl = ss(A-B*K,B,C,D);lsim(sys_cl,r,t,x0);axis(0 10 0 0.35)加比例系数补偿 稳态误差:求补偿系
2、数的函数如下:functionNbar = rscale(a,b,c,d,k) % Given the single-input linear system: % . % x = Ax + Bu % y = Cx + Du% and the feedback matrix K,% the function rscale(sys,K) or rscale(A,B,C,D,K) % finds the scale factor N which will % eliminate the steady-state error to a step reference % for a continuous
3、-time, single-input system % with full-state feedback using the schematic below: % /- % R + u | . | % - N -() - | X=Ax+Bu |- y = Cx - y % -| -/ % | | % |- K -| % % 8/21/96 Yanjie Sun of the University of Michigan % under the supervision of Prof. D. Tilbury % 6/12/98 John Yook, Dawn Tilbury revised e
4、rror(nargchk(2,5,nargin); % - Determine which syntax is being used - nargin1 = nargin; if (nargin=2), % System form A,B,C,D = ssdata(a); K=b; elseif (nargin=5), % A,B,C,D matrices A=a; A = a; B = b; C = c; D = d; K = k;else error(Input must be of the form (sys,K) or (A,B,C,D,K)end; % compute Nbar s
5、= size(A,1);s = size(A,1);Z = zeros(1,s) 1;N = inv(A,B;C,D)*Z;Nx = N(1:s);Nu = N(1+s);Nbar = Nu + K*Nx; 加入控制系统得到:Nbar = rscale(sys,K);sys_cl = ss(A-B*K,B*Nbar,C,D);rnew = r *10;lsim(sys_cl,rnew,t,x0);axis(0 10 0 11) 直流电机的速度控制1. 建模:(J) 转子的惯性常量 0.01 kg.m2(b) 电机摩擦系数 0.1 N.m.s(Ke) 电生电动势常数 0.01 V/rad/sec
6、(Kt) 力矩常数 0.01 N.m/Amp(R) 电阻 1 Ohm(L) 电感 0.5 H 传递函数模型:状态空间模型: 控制算法:1. PID 控制:J = 0.01;b = 0.1;K = 0.01;R = 1;L = 0.5;s = tf(s);P_motor = K/(J*s+b)*(L*s+R)+K2);PID 控制器 模型:(1)比例控制Kp = 100;C = pid(Kp);sys_cl = feedback(C*P_motor,1); t = 0:0.01:5; step(sys_cl,t) grid title(Step Response with Proportiona
7、l Control)(2) PID控制Kp = 75;Ki = 1;Kd = 1;C = pid(Kp,Ki,Kd);sys_cl = feedback(C*P_motor,1);step(sys_cl,0:1:200)title(PID Control with Small Ki and Small Kd)调整参数: Kp = 100; Ki = 200; Kd = 1; C = pid(Kp,Ki,Kd); sys_cl = feedback(C*P_motor,1); step(sys_cl, 0:0.01:4) grid title(PID Control with Large Ki
8、and Small Kd)2. 状态空间方程控制J = 0.01;b = 0.1;K = 0.01;R = 1;L = 0.5;A = -b/J K/J -K/L -R/L;B = 0 1/L;C = 1 0;D = 0;sys = ss(A,B,C,D);1. 求反馈控制系数 k(1) 判断能控性sys_order = order(sys)sys_rank = rank(ctrb(A,B)(2) 利用置根法求反馈矩阵Kp1 = -5 + 1i;p2 = -5 - 1i;Kc = place(A,B,p1 p2)t = 0:0.01:3;sys_cl = ss(A-B*Kc,B,C,D);step(sys_cl,t)gridtitle(Step Response with State-Feedback Controller)(3) 加上比例常数补偿:Nbar = rscale(sys,Kc)t = 0:0.01:10;step(sys_cl*Nbar,t)gridtitle(Step Response with State-Feedback Controller and Precompensator)