Exp 4
Exp 4
AIM:
Using Matlab, to design a state feedback controller for a type 1 servo system
THEORY :
PROCEDURE :
i. In the ‘main’ script file, check for controllability as the first step. If the system is
controllable, proceed with the controller design. Use the acker ()command of
MATLAB for the design of the controller, and step() command to simulate the step
response of the system without and with control, for comparison and study. Use the
following syntax of acker and step:
K = acker(A, B, P)
[y t X] = step(sys,T)
ii. Plot the graphs of the states vs. time (a) for the uncontrolled, (b) controlled system,
and (c) graph of control input u = −Kx + kr vs. time.
MATLAB CODE :
t = 0:0.1:10;
%%Testing for Controllability
M_c = ctrb(A,B);
if rank(M_c)<size(A,1)
disp('system is controllable');
end
system is controllable
K = acker(A,B,P);
A_cl = A - B*K;
B_cl = B*K(1); %%it is so for a servo operation (tracking problem)
sys = ss(A,B,C,D);
[y,t,x] = step(sys,t); %%step() function for the system to return step response
figure(1);
subplot(3,1,1), plot(t,x(:,1)), ylabel('O.L \theta'),xlabel('t'),grid on;title('Open loop response');
subplot(3,1,2), plot(t,x(:,2)), ylabel('O.L \omega'),xlabel('t'),grid on;
subplot(3,1,3), plot(t,x(:,3)), ylabel('O.L Ia'),xlabel('t'),grid on;
figure(3);
plot(t,-K*x_cl'+K(1)*1),ylabel('u'),title('Controller output: u = -KX+k_1r'),grid on;
disp('Simulation is finished')
Simulation is finished