Question

Include all MATLAB code:

Utilize root contours as a way to select a set of admissible
parameters {KP, KI, KD} based on a damping ratio and settling time
criteria:
20 < P.O < 25
1.5<= Ts <= 2.0 sec
settling band is < 5% (use #TC=3)
1) Add overlays showing the admissible regions to the plot that
shows
all contours (the last one plotted in the code). Show with the
provided
gains.
2) Try to find a few (more than 2 less than 5) sets of parameters
that
meet the specifications. These should have significantly
different
values of {KP, KI, KD}.
3) Verify the results by drawing the block diagram and finding
C(s)/R(s)
for the closed loop system and then use Matlab to plot the
step
response. Hint try using the function step(num,den, time). You
may
need the Matlab controls toolbox, older versions of student
Matlab
have this built in, otherwise be creative…
4) Show time response plots for the system

5) Have explanations discussing what you did.

Matlab code to use:
% file: sec_PID_rl.m
% This program shows the root contours for a 3rd order plant
% with a PID controller attached

% plot the system with only KP gain
figure
plot(root_r(1:2,1:Kp_range_size),root_im(1:2,1:Kp_range_size),
'x')
title('Root Locus vs Kp with Kd and Ki set to zero')
axis([xmin, xmax, ymin, ymax])
% note the color rotation in plotting for ease of
understanding

% now let use see what happens if Ki varies for a given value of
Kp
% here the system becomes a 3rd order system (type 1)
% PID parameters for second run
Kp_sel = 40; % index of Kp
Kp = Kp_range(Kp_sel) ; % use one value of Kp
Kd = 0
Ki_range = linspace(0,800,100); % vector of Ki gains
Ki_root_r = []; % accumulator for real roots
Ki_root_im = []; % accumulator for imaginary roots
Ki_range_size= max(size(Ki_range));

for i = 1:Ki_range_size
Ki = Ki_range(i);
% ce = [1, (a+b+c), (a*c + b*c + a*b + Kd), (a*b*c+ Kp), Ki];
% note we have to include Ki to get a 3th order system
ce = [1, (a+b+Kd), (a*b + Kp), Ki];
r= roots(ce); % there are three roots here
r_r = real(r); % note this is a 3x1 vector
r_im = imag(r);% noet this is a 3x1 vector
Ki_root_r = [Ki_root_r, r_r];
Ki_root_im = [Ki_root_im,r_im];
% note that we have forced the vector r_r and r_im to be
concatantated as
% 3x1 vectors
end

for i = 1:Kd_range_size
Kd = Kd_range(i);
% note we have to include Ki to get a 3rd order system
ce = [1, (a+b+Kd), (a*b + Kp), Ki];
r= roots(ce); % there are three roots here
r_r = real(r); % note this is a 3x1 vector
r_im = imag(r);% noet this is a 3x1 vector
Kd_root_r = [Kd_root_r, r_r];
Kd_root_im = [Kd_root_im,r_im];
% note that we have forced the vector r_r and r_im to be
concatantated as
% 3x1 vectors
end