% Figure 5.42 Feedback Control of Dynamic Systems, 8e 
%                   Franklin, Powell, Emami
%                   
% attitude hold auto pilot for Dakota
% time response with integral control

clf 
s=tf('s');
sysG = 160*(s+2.5)*(s+0.7)/((s^2+5*s+40)*(s^2+0.03*s+0.06));
sysD = (s+3)/(s+20);
sysDG=sysD*sysG;
Kc=1.5;

% now add integral control

KI=.15;        % Inegral FB gain
sysDI=Kc*sysD*(1+KI/s);

figure(1)

sysLICL=feedback(sysDI*sysG,1);
step(5*sysLICL,30)   % X5 because we're doing a step command of 5 deg
grid
axis([0 30 0 6])
hold on
title ('Step response of \theta with Integral Control')
hold off

% now do control, Delta_e

figure(2)
sysFBDe=sysG*(1+KI/s);
sysDeCL=feedback(Kc*sysD,sysFBDe);
step(5*sysDeCL,30)
axis([0 30 -0.2 0.2])
grid
hold on
title('Step response of \delta_e with Integral Control')
hold off
figure(1)



% set(gco,'LineWidth',4)
