Labs

All the files are downloadable. See control_sys_lab_dir_list.txt and access the files. For example the lab0 main guide is accessable in CELAB_METHODS_0.pdf. Fils in folders called slprj are generated by Simulink and are not important. Our report is in celab_report_lab_2.pdf (source). spaces will be converted to ’-‘.

Bode Method

%performance parameters
t_r=0.15;
M_p=0.2;
alpha=4;
 
w_n=1.8/t_r;
delta=log(1/M_p)/sqrt(pi^2+log(1/M_p)^2);
phi_m=atan(2*delta/sqrt(sqrt(1+4*delta^4)-2*delta^2));
P_w_n=freqresp(sys_c,w_n);
delta_phi=-pi+phi_m-angle(P_w_n);
delta_k=1/abs(P_w_n);
 
K_P=delta_k*delta_phi;
T_D=(tan(delta_phi)+sqrt(tan(delta_phi)^2+4/alpha))/(2*w_n);
T_I=alpha*T_D;
 
K_D=T_D*K_P;
K_I=K_P/T_I;
 
%real deriverative 
T_l=0.01;
real_deriverative=tf([1 0],[T_l 1]);
 
% add anti wind up:
t_s5=3/delta/w_n;
k_w=5/t_s5;

We are having a clamping anti wind up.

State Feedback

% Compute steady-state gain for reference tracking (Feedforward gain)
M_Continuous = [A , B ; C , 0] ;
M_Discrete   = [A - eye(size(A,1)) , B ; C , 0] ; % For discrete systems
rhs = [zeros(size(A,1),1) ; 1] ;
sol = M \ rhs ;
Nx = sol(1:end-1) ;
Nu = sol(end) ;
 
w_n=1.8/t_r;
delta=log(1/M_p)/sqrt(pi^2+log(1/M_p)^2);
sigma=w_n*delta;
omega_d=w_n*sqrt(1-delta^2);
p1=-sigma+i*omega_d;
p2=conj(p1);
z1=exp(p1*T_s);
z2=exp(p2*T_s);
desired_poles=[z2 z1];
K=place(A,B,desired_poles');

Reduced Order State Observer

We assume we have some of the systems states. We need to make the system in such a formation that the first states in the state vector are the known states. This means we have to build the change of basis matrix . One example: Here the second state is known. The augmented system where the first states are know can be written as:

The Observer can be built now: It is the same in continous time.

Full state observer

This is the same in the discrete and continous time

w_n=1.8/t_r;
p1_o=-5*w_n;
p2_o=conj(p1_o);
z1=exp(p1_o*T_s);
z2=exp(p2_o*T_s);
desired_poles_o=[z2 z1]';
L=acker(A',C',desired_poles_o);
 
Phi_o=A-L'*C;
Gamma_o=[B L'];
H_o=eye(size(A,1));
J_o=zeros(2,2);

Keep in mind the first input is the input u and the second is y.

Robust tracking

This means we need to introduce an integral term. We define our new state as the integral of the deviation of the measurement to the reference. Here LQR was used but other methods can be used to get the K matrix.

sys_d=c2d(sys_c,T_s);
[A,B,C,D]=ssdata(sys_d);
Aaug_continous=[0 C;zeros(size(A,1),1) A];
Aaug_discete = [1 C;zeros(size(A,1),1) A];
Baug=[0;B];
Caug=[0 C];
Daug=D;
 
max_devi_x=10; %max deviation from 0
Q=diag(ones(1,size(Aaug,1))*1/max_devi_x^2);
max_devi_control=20;
R=1/max_devi_control^2;
[Ksol,~,~]=dlqr(Aaug,Baug,Q,R);
Ki=Ksol(1);
K=Ksol(2:end);

LQR

Nominal

% LQR Nominal
Q = diag([1/max_x1^2 , 1/max_x2^2]) ; 
R = 1/umax^2 ; 
K_continuos = lqr(A , B , Q , R) ;
K_discrete = dlqr(A , B , Q , R) ;

Robust

% LQR Robust 
Q = diag([1/max_x1^2 , 1/max_x2^2 , 1/max_x3^2 ]) ; 
R = 1/umax^2 ; 
K_aug_continuos = lqr(A_aug , B_aug , Q , R) ;
K_aug_discrete = dlqr(A_aug , B_aug , Q , R) ;
KI = K_aug(1) ;
K = K_aug(2:end) ;

Error State Approach

%Error-Space approach
% we need to track a sine and a step
% construction of the exo system
%! get alphas on paper !
alphas=[1 0 w^2 0];
 
A_e=[0 1 0 0 0;
     0 0 1 0 0
   alphas(1:3) C;
   zeros(size(A,2),3) A];
B_e=[zeros(3,1);B]
 
desired_poles=[linspace(-120,-20,5)];
Ksol=acker(A_e,B_e,desired_poles);
K_i=flip(Ksol(1:3));
K_e=Ksol(4:end);

Robust tracking with the extended estimator approach

By definition Extended estimator approach is robust.

The extended estimator approach basically consists of estimating both the reference input and the load disturbance (i.e. disturbance entering at the plant input) with a state estimator, and then using the estimates to perform a reference plus disturbance feedforward compensation

Here is the exo system. The rest that is surrounding the exo system marix (top left) differs from the Error State Approach.


and

desired_poles=linspace(-10,-11,5);
Le=acker(Ae',Ce',desired_poles)';
 
Ao=Ae-Le*Ce;
Bo=[Be Le];
Co=eye(size(Ao,1),1);
Do=zeros(size(Ao,1),2);
pk1=-delta*w_n+i*sqrt(1-delta^2);
pk2=conj(pk1);
 
K=acker(A,B,[pk1 pk2]);

something more…