%File: design2_rlocus.m
%Revised December 2, 2008 by Cody Priess

%Design Project #2 Root Locus
%Compare results with and without high frequency pole

%Insert system parameters
ke = 25;
kh = 0.8;
J = 0.008;
b = 0.025;
k = 1.6;

%Insert assumed zero location and time delay pole location
%Get controller gains Kp, and Kd
tdelay = input('Enter the time delay constant, tdelay: ');
if isempty(tdelay); tdelay=0.006; end
zero = input('Enter the assumed zero location, zero: ');
if isempty(zero); zero=-10; end

%System without high frequency pole:
num=ke*kh*[1 -zero];
den=[J b k];
G1=tf(num,den);

%System with high frequency pole
den=conv([tdelay 1],[J b k]);
G2=tf(num,den);

%root locus without high frequency pole
rlocus(G1)
title('Root Locus without time delay pole')
pause

%root locus with high frequency pole
rlocus(G2)
title('Root Locus with time delay pole')
pause

%Overlay the two root loci to see the difference
rlocus(G1);hold;rlocus(G2);hold
title('Root Locus with and without time delay pole')