Lab 3 State Feedback Control Design

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Lab Session 3

Title
1. To study the controllability and observability
2. To study the full state feedback control design.

Apparatus
MATLAB Software

Introduction
Controllability definition: A system is said to be controllable if it is possible to derive the
system variables from given initial state X(to) to a final desired state X(tf) from a control
input vector U(t). It tells whether the state variables X (t) can be controlled (by U(t)) to
achieve the desired output)[from checking controllability matrix].

Controllable system: A linear system is (completely) controllable if and only if the


controllability matrix Pc =[ B AB A2 B … . A n−1 B ]has full rank, where A is an n x n matrix. For
single-input, single-output linear systems, the system is controllable if and only if the
determinant of the n x n controllability matrix is nonzero

Observability definition: In control theory, observability is a measure of how well internal


states of a system can be inferred from knowledge of its external outputs.

Observable: A linear system is (completely) observable if and only if the observability


matrix P0= [ C ; CA; CA 2 … . CA n−1 ]has full rank, where A is an n x n matrix. For single-input,
single-output linear systems, the system is observable if and only if the determinant of the n x
n observability matrix P() is nonzero.

Full-state feedback control law: A control law of the form u = -Kx where x is the state of
the system assumed known at all times.

In the state variable feedback form controllability and observability can be checked using the
functions “ctrb” and” obsv”, respectively. The inputs to the ctrb function are the system
matrix A and the input matrix B; the output of ctrb is the controllability matrix Pc. Similarly,
the input to the obsv function, shown in Figure, is the system matrix A and the output matrix
C; the output of obsv is the observability matrix Po.

The controllability matrix Pc is a function only of A and B, while the observability matrix Po
is a function only of A and C.

Example: Consider the system given below check the controllability and observability of the
system.
−6 2 0 5
ẋ=
[4 0 7 x+ 0 u
−10 1 11 1 ] []
y= [ 1 2 1 ] x

Solution:

clear all,clc
A=[-6 2 0;4 0 7;-10 1 11];
B=[5;0;1];
C=[1 2 1];
Pc=ctrb(A,B);
Po=obsv(A,C)
detPc=det(Pc)
detPo=det(Po)
if detPc==0
disp('system is not controllable')
else
disp('system is controllable')
end
if detPo==0
disp('system is not observable')
else
disp('system is observable')
end
MATLAB Result:
Po =

1 2 1
-8 3 25
-190 9 296
detPc =
-84933
detPo =
-3.6030e+03
system is controllable
system is observable
Ackermann's formula for finding state-feedback gain K

Now we discussed Ackermann's formula to place the poles of the system at desired locations.
The function acker calculates the gain matrix K to place the closed-loop poles at the desired
locations. The acker function is illustrated in Figure

Steps for full-state feedback control design :

1. All states x should be available


2. The system input u(t) is given by u = -Kx. . We need to find K.

3. With the system defined by the state variable model

ẋ =Ax + Bu
and the control feedback given by

u = -Kx,

we find the closed-loop system to be

ẋ == Ax + Bu = Ax - BKx = (A - BK)x.

Example: Consider the third-order system with the differential equation

d3 y d2 y d1 y
+5 +3 +2 y=u
dt 3 dt 2 dt

The state space form is


0 1 0 0

[
ẋ= 0 0 1 x+ 0 u
−2 −3 −5 1 ] []
y= [ 1 0 0 ] x

Solution:

A=[0 1 0;0 0 1;-2 -3 -5];


B=[0;0;1];
C=[1 0 0];D=[0];
Pc=ctrb(A,B);
Po=obsv(A,C)
detPc=det(Pc)
detPo=det(Po)
P=[-1+j;-1-j;-5];
K=acker(A,B,P)

%Convert to tf form
[b,a] = ss2tf(A,B,C,D)
sys=tf(b,a)
pole(sys) %system actual poles
pzmap(sys)
step(sys)
%Desired poles by ackerman
P=[-0.18+0.6j;-0.18-0.6j;-2.5];
%P=[-1+j;-1-j;-5];
K=acker(A,B,P)
A_new=A-B*K; %Modified A for desired pole placement
[b1,a1] = ss2tf(A_new,B,C,D) % new TF
sys_new=tf(b1,a1)
pole(sys_new)
pzmap(sys_new)
step(sys_new)
subplot(2,1,1),pzmap(sys_new),title('sys new')
subplot(2,1,2),pzmap(sys),title('sys')

MATLAB Result
Po =

1 0 0
0 1 0
0 0 1
detPc =
-1
detPo =
1
K =

-1.0190 -1.7076 -2.1400


Additional Task
See what happens when two complex poles are selected on imaginary axis such as:
P=[0+j;0-j;-5];
There will be immense oscillations in the system.

Using Simulink

Or you can use ODE45 or ODE23 for simulation of system.

Step 1: Define the differential equation as a MATLAB function (mydiff.m):


function ydot=mydiff(t,y)
ydot=zeros(3,1);
ydot(1)=y(2);
ydot(2)=y(3)
ydot(3)= -7*y(3)-12*y(2)-10*y(1);
end

Step 2: Use one of the built-in ODE solver (ode23, ode45, ...) in a Script

clear all,clc
xo=[5 0 0];
tspan = [0 20];
[t y]=ode45('mydiff',tspan,xo);
plot(t,y(:,1),'g',t,y(:,2),'r',t,y(:,3),'b')

Task:
Design the Full-State Feedback Control Law for Inverted Pendulum for settling time half
second.

The system matrices are given below

System parameters are

• l = 0.098 m
• g=9.8 m/ s2
• m=0.825 kg
• M=8.085 kg

Observations
Conclusion

You might also like