You are on page 1of 14

DIGITAL CONTROL SYSTEMS (EE-372)

Lab #8 Report

Course Instructor: Lt Col Dr Atif Qayyum


Lab Engineer: Azmat Saeed

Group Members Registration Number


Zain Rehan 301822
Muhammad Umer Siddiq 296908
Syed Muhammad Abdullah Shah 286767
Degree 41 Syndicate B
LAB 8: State Feedback with Observer

Objectives:
• Design an observer in MATLAB
• Implement state feedback with observer in Simulink

Model

Consider the following state space model

Exercise 1:

Using MATLAB, test the controllability and observability of the system. Some commands of
interest are: ctrb(), obsv(), rank()

MATLAB Code:
% Exercise 1

% System Matrices
A = [1 2; 7 1];
B = [0; 1];
C = [1 0];
D = 0;

% State-Space Model
sys = ss(A,B,C,D);

% Test controllability
ctrb_matrix = ctrb(sys)
controllability_rank = rank(ctrb_matrix)
if controllability_rank == size(A, 1)
disp('The system is controllable.');
else
disp('The system is not controllable.');
end
% Test observability
obsv_matrix = obsv(sys)
observability_rank = rank(obsv_matrix)
if observability_rank == size(A, 1)
disp('The system is observable.');
else
disp('The system is not observable.');
end

MATLAB Output:
ctrb_matrix =

0 2

1 1

controllability_rank =

The system is controllable.

obsv_matrix =

1 0

1 2

observability_rank =

The system is observable.

Exercise 2:

Design the state feedback gain matrix K, such that the closed loop poles meet the following
criteria:

Damping ratio = 0.707

Settling time = 4 seconds


MATLAB Code:
%% Exercise 2

% Determine the desired closed-loop pole locations


damping_ratio = 0.707;
settling_time = 4;
wn = 4 / (damping_ratio * settling_time);
desired_poles = [-damping_ratio*wn+i*wn*sqrt(1-damping_ratio^2), -
damping_ratio*wn-i*wn*sqrt(1-damping_ratio^2)];
disp(' ');
disp('The desired closed-loop poles are: ');
disp(desired_poles);

% Compute the state feedback gain matrix K


K = place(A, B, desired_poles);

% Display the state feedback gain matrix K


disp('State feedback gain matrix K:');
disp(K);

MATLAB Output:
The desired closed-loop poles are:

-1.0000 + 1.0003i -1.0000 - 1.0003i

State feedback gain matrix K:

9.5003 4.0000

Exercise 3:

Design the observer gain matrix L, such that the eigen values of A-LC are at -1 and -1.5.

MATLAB Code:
%% Exercise 3

% The desired observer pole locations


desired_poles = [-1 -1.5];
% Compute the observer gain matrix L
L = place(A', C', desired_poles)';

% Display the observer gain matrix L


disp('Observer gain matrix L:');
disp(L);

MATLAB Output:
Observer gain matrix L:

4.5000

9.5000

Exercise 4:

Make a model of the system in Simulink as shown in the diagram below.

Double click on the integrator block and set the initial condition to [-1 -1].
Double click on the gain block. Enter the name of the gain matrix e.g. ‘A’ and select the
multiplication type as Matrix(K*u). Note that over here K denotes the gain matrix of this block
and u denotes the input to this block. This should not be confused with the state feedback gain K
and the input to the plant.

Now connect the state feedback controller as shown in the figure below. I have used different
colors to differentiate between the plant and the controller.

We also need to specify the values of different matrices. This can be done by going to
File>> model properties >> callbacks >>InitFcn and filling in the values of the matrices.

Run the simulation and see the signals on the scope. Is the plant stable?
Simulink Implementation:

Simulink Output:

The plant is stable because the output has zero steady state error. It takes 6 seconds for the plant
output to become stable.
Exercise 5:
Now make an observer in Simulink as shown in the figure below:

Set the initial value of the estimated states to be [0 0]. In this exercise we are not using the
estimated states for feedback. We will just examine the difference between the estimated and the
observed states.

Using a summer block find the difference of the estimated state and the actual state. Plot this
error on a Scope. This summer and scope are shown in blue color in the lower right corner of the
diagram.

Using an observer gain matrix L such that the eigen values of A-LC are at [-1,-1.5], examine
whether the error is converging to zero or not. Try this again a few times with a different
placement of eigen values, such as [-2,-2.5], [-5,-5.5], [-10,-10.5].

Hint: You can use the command L = place(A’,C’,[-10,-10.5])’; in InitFcn


Simulink Implementation:

Simulink Outputs for Difference of Estimated State and Actual State:

For eigen values: [-1, -1.5]

The error converges to zero after 4 seconds.


For eigen values: [-2, -2.5]

The error converges to zero at around 3 seconds.

For eigen values: [-5, -5.5]

The error converges to zero at about 2 seconds.


For eigen values: [-10, -10.5]

The error converges to zero at around 1 second.

Exercise 6:

In a physical plant, the actual states are not always available. In you Simulink file, instead of
using the states of the actual system for feedback, use the estimated/observed states for feedback.

Look at the actual states or the output of the system to see whether it is stable or not. You may
try different eigen value placements of A-LC.
Simulink Implementation:

Simulink Output:

The output is stable, but it takes longer to stabilize.


Exercise 7:
Make another system which uses full state feedback as shown in the figure.

Run the simulation and compare ‘the states of the physical system with actual state feedback’
and ‘the states of the physical system with observed state feedback’. Is there a difference
between these states? Try this for different Eigen value placements of A-LC.

Simulink Outputs:

For states of the physical system with actual state feedback:


For states of the physical system with observed state feedback:

Comparison of Outputs:
• The system with observed state feedback takes longer to stabilize as compared to the system
with actual state feedback.
• It can also be seen that the observed state feedback system has a higher overshoot when
compared with the actual state feedback system.

Conclusion:
In this lab, we learned how to check the controllability and observability of a system to
determine if that system can be controlled and observed. We learned how to design the state
feedback gain matrix and observer gain matrix. Additionally, we learned how to create a system
with actual state feedback and observed state feedback in Simulink. For these systems we were
able to perceive their outputs via the scope and determine how different eigen values affected
observer state feedback system performance.

You might also like