Vous êtes sur la page 1sur 19

# State Feedback Controller

## Design using MATLAB

Version 2.0
M.Varatharajan
Asst.Professor
Department of EEE
Thiagarajar College of Engineering
Madurai

## State Feedback Controller

Consider the transfer function,
G (s) =

s2

10
+ as + b

X = AX + BU

&

Y = CX

## Controllable canonical form can be obtained directly



 
0
1
0

X =
X+
u
b a
1


Y = 10 0 X



If control input is applied as u = KX , where k = k1 k2 , the
closed loop system state equation is X = (A BK ) X
State Feedback Control

## E67 Control & Instrumentation Lab

i.e.


0
1
X
(b + k1 ) (a + k2 )
Characteristic equation of the above system is
X =

2 + (a + k2 ) + (b + k1 ) = 0
Let D() = 0 be the desired characteristic equation. By
comparing the coefficients of powers of the values of k1 & k2
can be found.
Another method is by using Ackermans Formula: (It can be
used even if the state model is not in controllable canonical
form)

K = 0 0


1 WC1 D(A)

where,
Wc is the controllability matrix.
Wc = B AB A2 B An1 B
If D() = 2 + d1 + d0 = 0, then, D(A) = A2 + d1 A + d0 I
State Feedback Control

## e.g. In the previous example consider a=-2 and b=-3

MATLAB Code
A=[0 1 ; -2 -3];
B=[0 1];
C=[10 0];
%Let the eigen values of the system be at 10 and 11
p=[-10 -11];
K=place(A,B,p)
eig(A-B*K)
%Using Ackermans formula
t=conv([1 10],[1 11])
d=polyvalm(t,A);
Wc=[B A*B]
K1=[0 1]*inv(Wc)*d
eig(A-B*K1)

## Closed Loop Response

For Control law (u = r KX )

## Note that speed of the system is increased.

steady state error is not zero.

But

## Control law, u = r KX is in some sense like a

proportional control action
To bring steady state error = 0, add we need integral
control action.
So integral of error shall be added as one of the state as
shown below
e(t) = v = r(t) y(t)
r(t)
+

1
s

ki
R

v(t) = e(t)dt

x = Ax + Bu

u(t)
K

y(t)

## New state space model will be

..

.
0 X
B
0
X
A
= + u + r (t)

..
v
0
1
v
C
.
0
Because of inclusion of new state order of the system is
increased to 3.
State feedback controller can be designed for this new
system
Now the control law is u(t) = KX ki v

## E67 Control & Instrumentation Lab

MATLAB Code
A=[0 1; -2 -3];
B=[0 1];
C=[1 0];
%New matrices with augmented with integral error as state
Anew=[A zeros(2,1); -C 0];
Bnew=[B; 0];
%Let the desired eigenvalues be 10 and 11 and 100
%The third eigen value is added far from the other two
%so that the dominant pole approximation is valid
p=[-10 -11 -100];
K=place(Anew,Bnew,p)
eig(Anew-Bnew*K)

## Closed Loop Response

For State Feedback with Integral control (u = r KX ki

e(t)dt)

## Note that steady state error has become zero, while

achieving desired dynamics

## State Space Analysis of Discrete Systems

When the system X = AX + BU is sampled and hold with a
ZOH then discrete equivalent of the system is given by
Xk+1 = FXk + GUk
where F = e AT & G =

RT

e At Bdt

## For simulation G can be expanded as

T

B
G = A1 e Aq
0


= A1 e AT I B


1 2 2
1 3 3
1
=A
I + AT + A T + A T + I B
2!
3!


1
1
1 3 4
2
2 3
= T + AT + A T + A T + B
2!
3!
4!
State Feedback Control

## Simulation of discrete state space model

Using Scripts

T=0.1;
Tstop=10; %Duration of simulation
A=[0 1 ;-2 -3];
B=[0;1];
C=[10 0];
F=expm(A*T);
%G is approximated with first four terms of expansion
G=(T*eye(2)+A*T^2/factorial(2)+ ...
+A^2*T^3/factorial(3)+ A^3*T^4/factorial(4))*B;
R=[1 0];%Reference
nsteps=Tstop/T;
X0=[0;0]; %Initial state
XX=[X0]
tt=;

Contd..

## P=[-10 -20]; %Desired poles in S plane

Pd=exp(P*T); %Pole location in Z planes
K=acker(F,G,Pd); %State feedback controller gain
for i=1:nsteps
U=K*(R-X0);
X=F*X0+G*U;
XX=[XX X];
tt=[tt i*T];
X0=X;
end
Y=C*XX;
plot(tt,Y,r);
xlabel(Time(s));
ylabel(y(t));
legend(Output);
State Feedback Control

Simulink Model

Response

## Here also there is steady state error.

State Feedback Control

## State Feedback with integral control

To remove steady state error we need integral of error (Vk ) as a
state. The augmented state equation will be,

..
G
0
Xk
.
0 X
F
+ u + rk
=

..
vk
v
0
T
CT
.
1
Control law is uk = rk Kxk ki vk
e(k) = r(k) y(k)

r(k)
+

1
z

vk

ki

xk+1 = Fxk + Guk

y(k)

## State Feedback with integral control

Let the desired poles be -10 and -20 in S-domain. Since the
order of system is increased due to addition of integral of error,
let us assume the third pole at least 10 times in the left hand
side of -20 i.e., at -200
MATLAB Code
T=0.01; A=[0 1 ;-2 -3]; B=[0;1];
C=[10 0]; F=expm(A*T);
%G is approximated with first four terms of expansion
G=(T*eye(2)+A*T^2/factorial(2)+ ...
+A^2*T^3/factorial(3)+ A^3*T^4/factorial(4))*B;
Fnew=[F zeros(2,1); -C*T 1]; Gnew=[G;0];
P=[-5 -6 -20]; %desired poles in Sdomain
Pd=exp(P); %desired poles in Zdomain
K=acker(Fnew,Gnew,Pd)
State Feedback Control

## Effect of Sampling Period

Sampling Period T has adverse effect on closed loop response.
Substitute various values and analyze the impact.