EEE318 Experiment 5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

EEE 318

Experiment 5
PID Controller Design using Root Locus Method.

Submitted by-
Abdullah Jubair Bin Iqbal
Roll: 1706058
EEE A2
Level: 3, Term: 2
Compensator Transfer Improvement
0 Root Locus Method of Function
Controller Design PI 𝐾
𝑠 + 𝑍𝑐 Steady State
𝑠
The root locus indicates the achievable Error
Lag 𝑠 + 𝑧𝑐 Steady State
closed-loop pole locations of a system as a 𝐾
𝑠 + 𝑝𝑐
parameter (usually, the controller gain) Error
PD 𝐾(𝑠 + 𝑧𝑐 ) Transient
varies from zero to infinity. For a given plant
Lead 𝑠 + 𝑧𝑐 Transient
it may or may not be possible to implement 𝐾
𝑠 + 𝑝𝑐
a simple proportional control (i.e., select a PID 𝐾
(𝑠 + 𝑧𝑙𝑎𝑔 )(𝑠 + 𝑧𝑙𝑒𝑎𝑑 ) Both
𝑠
gain that specifies closed-loop locations along Lag-lead (𝑠 + 𝑧𝑙𝑎𝑔 )(𝑠 + 𝑧𝑙𝑒𝑎𝑑 ) Both
𝐾
the root locus) to achieve the specified (𝑠 + 𝑝𝑙𝑎𝑔 )(𝑠 + 𝑝𝑙𝑒𝑎𝑑 )
performance constraints. In fact, in most
cases it will not be possible. 1 Lab work 1
In this experiment we obtain the step
response of the following system with a
particular gain corresponding to the damping
ratio of 0.174. Then we use a PI controller to
reduce the SS error to 0.

At point B, the system might have desirable


1.1 Uncompensated System
characteristics, however, it is not possible to
The root locus of the original system is
obtain that since it is outside the root locus.
presented hereby. We choose a gain that
Hence, we can only modify the percentage
corresponds to 𝜁 = 0.174.
overshoot in this case, but settling time
cannot be optimized by a simple gain
adjustment.

In these cases, we need various controllers,


that work on different aspects of the system.
A brief overview of the controller types and
their general form is presented in the
following table.

The corresponding step response is as follows,


Here we can see that the there is around 10% Here we can see that the steady state error
steady state error present. has gradually decreased to 0 and the system
is now reaching its desired output.
1.2 PI Compensated System
We’d like to add a PI Compensator to see if 2 Lab Work 2
anything changes. The PI Compensator In this problem we’ll use lag compensation to
we’ve chosen is as follows, reduce the steady state error of the previous
𝑠 + 0.1 system by a factor of 10. We’ll put the
𝐶(𝑠) = compensator pole 𝑝𝑐 at −0.01 and the
𝑠
compensator zero accordingly. After that
After implementing the PI Compensator, the
we’ll compare both the responses.
root locus is as follows,
2.1 Uncompensated System
The root locus of the original system is
presented hereby. We choose a gain that
corresponds to 𝜁 = 0.174.

And after choosing a gain corresponding to


𝜁 = 0.174, we obtain the following step
response,

The corresponding step response is as follows,


Here we can see that there is around 10% Here we can see that the steady state error
steady state error present. has gradually decreased to 0 and the system
is now reaching its desired output.
2.2 Lag Compensated System
We’ve added a lag Compensator to see if
3 Lab Work 3
anything changes. The lag Compensator
we’ve chosen is as follows, In this problem we’ll observe the step
response of the following system with a 16%
𝑠 + 0.1113 overshoot.
𝐶(𝑠) =
𝑠 + 0.01
𝐾
After implementing the lag Compensator, the 𝐺(𝑠) =
𝑠(𝑠 + 4)(𝑠 + 6)
root locus is as follows,
After that, we’ll design a PD compensator to
reduce the settling time by three-fold while
keeping the overshoot constant.

3.1 Uncompensated System

And after choosing a gain corresponding to


𝜁 = 0.174, we obtain the following step
response,

The root locus for the uncompensated system


is shown above. Here we’ll chose a point
corresponding to the 16% overshoot After adding the compensator, we obtain the
requirement. root locus as shown above. Here, we again
choose a point that corresponds to the 16%
3.2 PD Compensated System overshoot requirement and then obtain the
For the system given, desired OS is 16%. according step response.
Thus, 𝜁 = 0.5039.

From the intercept point, we find 𝑠 =


−1.2043 + 2.064𝑗.

So, 𝜎 = −1.2043.
4
We know, 𝑇𝑠 =
𝜎

So, to reduce settling time 3 times, we need


to increase sigma three times.

Thus, new 𝜎 = −3.613, but to keep the


overshoot constant, ratio of 𝜎 and 𝜔𝑛 should
Here, when uncompensated, settling time is
be constant too.
3.4523 s, but after compensation settling
Thus, 𝜔𝑛 = 2.064 × 3 = 6.193. time is 1.117 s while overshoot is kept
constant. The slight variation is due to the
Now let’s look at the angle contribution for imprecise selection of the gain point.
new point (−3.6 + 6𝑗) which is −275.6°. But
it should be −180°, for that a zero is needed
4 Lab Work 4
which will contribute an angle of 95.6°. So,
In this task, we’ve designed a Lead
we need to put a zero at -3.
compensator to reduce the settling time by a
Thus, we implement the following PD factor of two while maintaining 30%
Compensator to reduce the settling time overshoot for the system described in the
three-fold. previous task.

𝐶(𝑠) = 𝑠 + 3 4.1 Uncompensated System


The root locus for the uncompensated system
is shown above. Here we’ll chose a point
corresponding to the 30% overshoot
requirement.

4.2 Lead Compensated System


For the system given, desired OS is 30%.
Thus, 𝜁 = 0.3579.

From the intercept point, we find, 𝑠 =


−1.0038 + 2.6303𝑗.

To reduce the settling time by a factor of 2,


we set new 𝑠 = −2.0076 + 5.2606𝑗. Here, when uncompensated, settling time is
Setting zero of lead compensator at −3. 3.9766 s, but after compensation settling
time is 1.9472 s, while overshoot is kept
Then total angle contribution will be constant. The slight variation is due to the
−153.63° . So, required contribution from imprecise selection of the gain point.
pole of lead compensator is −26.368°. So, the
pole should be placed at −12.6199. Thus 5 Lab Work 5
we obtain the following Lead Compensator, In this task, we’ve designed a Lead
compensator to meet the specifications:
𝑠+3
𝐶(𝑠) = settling time: 2s and Overshoot: 30% for the
𝑠 + 12.6199
system described below
𝐾
𝐺(𝑠) =
𝑠(𝑠 + 3)(𝑠 + 6)

5.1 Uncompensated System

After adding the compensator, we obtain the


root locus as shown above. Here, we again
choose a point that corresponds to the 30%
overshoot requirement and then obtain the
according step response. The root locus for the uncompensated system
is shown above. Here we’ll chose a point
corresponding to the 30% overshoot The slight variation is due to the imprecise
requirement. selection of the gain point.

5.2 Lead Compensated System


We’ve implemented the following Lead Uncompensated Compensated
Compensator to reduce the settling time by
% OS 19.0583 19.0180
a factor of two.
𝑇𝑠 4.0952 1.9622
𝑠+3 𝑒𝑠𝑡𝑒𝑝 (∞) 4.2033×10−7 4.5816×10−14
𝐶(𝑠) =
𝑠 + 5.602 𝑒𝑟𝑎𝑚𝑝 (∞) 0.5739 0.2727
𝐾 31.37 299.69

6 Lab Work 6
In this task, we’ve designed a Lead
compensator to meet the specifications:
settling time: 2s and Overshoot: 30% for the
system described below
𝐾
𝐺(𝑠) =
𝑠(𝑠 + 3)(𝑠 + 6)

After adding the compensator, we obtain the


6.1 Uncompensated System
root locus as shown above. Here, we again
choose a point that corresponds to the 30%
overshoot requirement and then obtain the
according step response.

The root locus for the uncompensated system


is shown above. Here we’ll chose a point
corresponding to the 30% overshoot
requirement.

Here, we can clearly see that for the 6.2 Lead Compensated System
compensated system, the settling time has We’ve implemented the following Lead
halved and the overshoot remained constant. Compensator to reduce the settling time by
a factor of two.
𝐶(𝑠) =
𝑠+5 7 Lab Work 7
𝑠 + 5.602
In this task, we’ve chosen the following Lead
compensator and integrated a PI Controller
to meet the specification of zero steady state
error:

𝑠+5
𝐶(𝑠) =
𝑠 + 5.602
7.1 PI Compensation
We’ve implemented the following PI
Compensator to reduce the steady state error
to 0.

𝑠+1
After adding the compensator, we obtain the 𝐶(𝑠) =
𝑠
root locus as shown above. Here, we again
choose a point that corresponds to the 30%
overshoot requirement and then obtain the
according step response.

After adding the compensator, we obtain the


root locus as shown above. Here, we again
choose a point that corresponds to the
appropriate overshoot requirement.
Here, we can clearly see that for the
compensated system, the settling time has
halved and the overshoot remained constant.
The slight variation is due to the imprecise
selection of the gain point.

Uncompensated Compensated
% OS 19.0583 20.0119
𝑇𝑠 4.0952 2.0529
𝑒𝑠𝑡𝑒𝑝 (∞) 2.0428 × 10−7 3.7842 × 10−14
𝑒𝑟𝑎𝑚𝑝 (∞) 0.5839 0.3982
𝐾 31.37 180.61
From the step response it is evident that the
steady state error has reached zero.

The response for the ramp input is shown


above. It is evident that even for the ramp
input, the steady state error has become zero.

8 Lab Work 8
For this part, we chose two additional zeros
at −0.8 and −0.6.

They all satisfy the particular design


constraints as evident from the graphs below.

We obtain the following step and ramp


responses:

As we can clearly see from the plots above


that using both the zeros result in the same
expected output, that the steady state error
is zero, although there are some minor
differences in their transient response.
9 Discussion set(axtime,'String','Time',
'Interpreter', 'Latex', 'Fontsize',
In this experiment, we’ve learnt to design 15);
control system according to various set(axAmp,'String','Angular
requirements, for example desired overshoot, Position, $\theta$(rad)',
settling time, steady state error etc. using the 'Interpreter', 'Latex', 'Fontsize',
15);
root locus. In the previous experiment we had
title("Step Response for Original
a slight introduction to how root locus can be
System", 'Interpreter', 'Latex',
a very powerful tool but, in this experiment, 'Fontsize', 16);
we’ve learnt first-hand how to use this very
powerful tool to efficiently design control figure
systems. The knowledge obtained in this rlocus(sys);
zeta = 0.174;
experiment will help us to design better
wn = 10;
control systems in future projects. sgrid(zeta, wn);
axis([-15 5 -10 10]);
set(findall(gcf,'type','line'),'line
width',1.3);
10 Appendix title('Root Locus for Original
System', 'Interpreter', 'Latex',
10.1 MATLAB Code
'Fontsize', 16);
10.1.1 Lab work 1 axIm =
findall(gcf,'String','Imaginary Axis
clc; (seconds^{-1})');
close all; axRe = findall(gcf,'String','Real
clear ll; Axis (seconds^{-1})');
set(axIm,'String','Imaginary Axis',
syms s; 'Interpreter', 'Latex', 'Fontsize',
15);
s = tf('s'); set(axRe,'String','Real Axis',
t = 0 : 0.1 : 30; 'Interpreter', 'Latex', 'Fontsize',
15);
num = 1;
den = (s+1)*(s+2)*(s+10);
sys = num/den; K = rlocfind(sys);

figure adjusted_sys = feedback(K*sys, 1);


step(feedback(sys, 1), t);
orig_sys_step = step(feedback(sys, figure()
1), t); step(adjusted_sys, t);
set(findall(gcf,'type','line'),'line gain_adjusted_sys_step =
width',1.3); step(adjusted_sys, t);
axtime = findall(gcf,'String','Time
(seconds)'); set(findall(gcf,'type','line'),'line
axAmp = width',1.3);
findall(gcf,'String','Amplitude'); axtime = findall(gcf,'String','Time
(seconds)');
axAmp = figure()
findall(gcf,'String','Amplitude'); step(adjusted_PI_sys, t);
set(axtime,'String','Time', PI_comp_sys_step =
'Interpreter', 'Latex', 'Fontsize', step(adjusted_PI_sys, t);
15); set(findall(gcf,'type','line'),'line
set(axAmp,'String','Angular width',1.3);
Position, $\theta$(rad)', axtime = findall(gcf,'String','Time
'Interpreter', 'Latex', 'Fontsize', (seconds)');
15); axAmp =
title(sprintf("Step Response for findall(gcf,'String','Amplitude');
chosen gain, $K = %.2f$", K), set(axtime,'String','Time',
'Interpreter', 'Latex', 'Fontsize', 'Interpreter', 'Latex', 'Fontsize',
16); 15);
set(axAmp,'String','Angular
Position, $\theta$(rad)',
%% PI compensator 'Interpreter', 'Latex', 'Fontsize',
15);
PI_comp = (s + 0.1)/s; title(sprintf("Step Response for
PI_comp_sys = PI_comp*sys; chosen gain (PI Compensated), $K =
%.2f$", K), 'Interpreter', 'Latex',
figure 'Fontsize', 16);
rlocus(PI_comp_sys);
zeta = 0.174;
10.1.2 Labwork 2
wn = 10
sgrid(zeta, wn);
axis([-15 5 -10 10]); clc;
set(findall(gcf,'type','line'),'line close all;
width',1.3); clear ll;
title('Root Locus for PI compensated
system', 'Interpreter', 'Latex', syms s;
'Fontsize', 16);
axIm = s = tf('s');
findall(gcf,'String','Imaginary Axis t = 0 : 0.1 : 30;
(seconds^{-1})');
axRe = findall(gcf,'String','Real num = 1;
Axis (seconds^{-1})'); den = (s+1)*(s+2)*(s+10);
set(axIm,'String','Imaginary Axis', sys = num/den;
'Interpreter', 'Latex', 'Fontsize',
15); figure
set(axRe,'String','Real Axis', step(feedback(sys, 1), t);
'Interpreter', 'Latex', 'Fontsize', orig_sys_step = step(feedback(sys,
15); 1), t);
set(findall(gcf,'type','line'),'line
width',1.3);
K = rlocfind(PI_comp_sys); axtime = findall(gcf,'String','Time
(seconds)');
adjusted_PI_sys = axAmp =
feedback(K*PI_comp_sys, 1); findall(gcf,'String','Amplitude');
set(axtime,'String','Time', axAmp =
'Interpreter', 'Latex', 'Fontsize', findall(gcf,'String','Amplitude');
15); set(axtime,'String','Time',
set(axAmp,'String','Angular 'Interpreter', 'Latex', 'Fontsize',
Position, $\theta$(rad)', 15);
'Interpreter', 'Latex', 'Fontsize', set(axAmp,'String','Angular
15); Position, $\theta$(rad)',
title("Step Response for Original 'Interpreter', 'Latex', 'Fontsize',
System", 'Interpreter', 'Latex', 15);
'Fontsize', 16); title(sprintf("Step Response for
chosen gain, $K = %.2f$", K),
figure 'Interpreter', 'Latex', 'Fontsize',
rlocus(sys); 16);
zeta = 0.174;
wn = 10; %% Lag Compensator
sgrid(zeta, wn);
axis([-15 5 -10 10]) Lag_comp = (s + 0.1113)/(s+0.01);
set(findall(gcf,'type','line'),'line Lag_comp_sys = Lag_comp*sys;
width',1.3);
title('Root Locus for Original figure
System', 'Interpreter', 'Latex', rlocus(Lag_comp_sys);
'Fontsize', 16); zeta = 0.174;
axIm = wn = 10;
findall(gcf,'String','Imaginary Axis sgrid(zeta, wn);
(seconds^{-1})'); axis([-15 5 -10 10]);
axRe = findall(gcf,'String','Real set(findall(gcf,'type','line'),'line
Axis (seconds^{-1})'); width',1.3);
set(axIm,'String','Imaginary Axis', title('Root Locus for Lag compensated
'Interpreter', 'Latex', 'Fontsize', system', 'Interpreter', 'Latex',
15); 'Fontsize', 16);
set(axRe,'String','Real Axis', axIm =
'Interpreter', 'Latex', 'Fontsize', findall(gcf,'String','Imaginary Axis
15); (seconds^{-1})');
axRe = findall(gcf,'String','Real
Axis (seconds^{-1})');
K = rlocfind(sys); set(axIm,'String','Imaginary Axis',
'Interpreter', 'Latex', 'Fontsize',
adjusted_sys = feedback(K*sys, 1); 15);
set(axRe,'String','Real Axis',
figure() 'Interpreter', 'Latex', 'Fontsize',
step(adjusted_sys, t); 15);
gain_adjusted_sys_step =
step(adjusted_sys, t);
K = rlocfind(Lag_comp_sys);
set(findall(gcf,'type','line'),'line
width',1.3); adjusted_Lag_sys =
axtime = findall(gcf,'String','Time feedback(K*Lag_comp_sys, 1);
(seconds)');
figure()
step(adjusted_PI_sys, t); figure(1)
Lag_comp_sys_step = rlocus(sys);
step(adjusted_Lag_sys, t); sgrid(zeta,wn);
set(findall(gcf,'type','line'),'line axis([-15 5 -10 10]);
width',1.3); [k_sys , poles_sys] = rlocfind(sys);
axtime = findall(gcf,'String','Time feedbk_sys=feedback(k_sys*sys,1);
(seconds)'); set(findall(gcf,'type','line'),'line
axAmp = width',1.3);
findall(gcf,'String','Amplitude'); title('Root Locus for uncompensated
set(axtime,'String','Time', system', 'Interpreter', 'Latex',
'Interpreter', 'Latex', 'Fontsize', 'Fontsize', 16);
15); axIm =
set(axAmp,'String','Angular findall(gcf,'String','Imaginary Axis
Position, $\theta$(rad)', (seconds^{-1})');
'Interpreter', 'Latex', 'Fontsize', axRe = findall(gcf,'String','Real
15); Axis (seconds^{-1})');
title(sprintf("Step Response for set(axIm,'String','Imaginary Axis',
chosen gain (Lag Compensated), $K = 'Interpreter', 'Latex', 'Fontsize',
%.2f$", K), 'Interpreter', 'Latex', 15);
'Fontsize', 16); set(axRe,'String','Real Axis',
'Interpreter', 'Latex', 'Fontsize',
figure() 15);
plot(t, gain_adjusted_sys_step, t,
Lag_comp_sys_step);
yline(1, '--'); PD_compensator = s+3;
legend(["Uncompensated", PD_sys = sys*PD_compensator;
"Compensated"], 'Interpreter',
'latex'); figure(2)
title("Step Response"); rlocus(PD_sys);
sgrid(zeta,wn);
axis([-15 5 -10 10]);
[k_PD_sys , poles_PD_sys] =
10.1.3 Labwork 3 rlocfind(PD_sys);
set(findall(gcf,'type','line'),'line
width',1.3);
clc;
title('Root Locus for PD compensated
close all;
system', 'Interpreter', 'Latex',
clear all;
'Fontsize', 16);
axIm =
T = linspace(0,15,1000);
findall(gcf,'String','Imaginary Axis
(seconds^{-1})');
OS = 0.16;
axRe = findall(gcf,'String','Real
zeta = -
Axis (seconds^{-1})');
log(OS)/sqrt(pi^2+(log(OS))^2);
set(axIm,'String','Imaginary Axis',
wn = 10;
'Interpreter', 'Latex', 'Fontsize',
15);
s = tf('s');
set(axRe,'String','Real Axis',
sys = 1/(s*(s+4)*(s+6));
'Interpreter', 'Latex', 'Fontsize',
15);
sgrid(zeta,wn);
feedbk_sys=feedback(k_sys*sys,1); axis([-15 5 -10 10]);
feedbk_PD_sys=feedback(k_PD_sys*PD_s [k_sys , poles_sys] = rlocfind(sys);
ys,1); set(findall(gcf,'type','line'),'line
width',1.3);
figure(3); title('Root Locus for uncompensated
[y_sys,T] = step(feedbk_sys,T); system', 'Interpreter', 'Latex',
%step response of the uncompensated 'Fontsize', 16);
system. axIm =
[y_PD_sys,T] = findall(gcf,'String','Imaginary Axis
step(feedbk_PD_sys,T); (seconds^{-1})');
axRe = findall(gcf,'String','Real
plot(T,y_PD_sys,'DisplayName',sprint Axis (seconds^{-1})');
f('PD compensated'));hold on; set(axIm,'String','Imaginary Axis',
plot(T,y_sys,'DisplayName',sprintf(' 'Interpreter', 'Latex', 'Fontsize',
Uncompensated')); 15);
xlim([0,T(end)]); set(axRe,'String','Real Axis',
grid on; 'Interpreter', 'Latex', 'Fontsize',
xlabel('t(s)'); ylabel('Amplitude'); 15);
legend;
title('Step response for PD figure(2)
compensated and uncompensated'); rlocus(lead_sys);
stepinfo(feedbk_sys) sgrid(zeta,wn);
stepinfo(feedbk_PD_sys) axis([-15 5 -10 10]);
[k_lead_sys , poles_lead_sys] =
rlocfind(lead_sys);
set(findall(gcf,'type','line'),'line
10.1.4 Lab Work 4 width',1.3);
title('Root Locus for Lead
compensated system', 'Interpreter',
clc;
'Latex', 'Fontsize', 16);
close all;
axIm =
clear all;
findall(gcf,'String','Imaginary Axis
(seconds^{-1})');
T = 0: .1: 30;
axRe = findall(gcf,'String','Real
Axis (seconds^{-1})');
OS = 0.30;
set(axIm,'String','Imaginary Axis',
zeta = -
'Interpreter', 'Latex', 'Fontsize',
log(OS)/sqrt(pi^2+(log(OS))^2);
15);
wn = 10;
set(axRe,'String','Real Axis',
'Interpreter', 'Latex', 'Fontsize',
s = tf('s');
15);
sys = 1/(s*(s+4)*(s+6));
lead_compensator =
feedbk_sys=feedback(k_sys*sys,1);
(s+3)/(s+12.6199);
feedbk_lead_sys=feedback(k_lead_sys*
lead_sys = sys*lead_compensator;
lead_sys,1);
figure(1)
figure(3);
rlocus(sys);
[y_sys,T] = step(feedbk_sys,T);
[y_lead_sys,T] = theta_sum_system = -
step(feedbk_lead_sys,T); rad2deg(angle(s)) -
plot(T,y_lead_sys,'DisplayName',spri
rad2deg(angle(s+3)) -
ntf('Lead compensated')); rad2deg(angle(s+6));
hold on; theta_sum_after_adding_zero =
plot(T,y_sys,'DisplayName',sprintf(' rad2deg(angle(s - new_zero)) +
Uncompensated')); theta_sum_system;
xlim([0,T(end)]);
grid on;
theta_required = abs(-180 -
xlabel('t(s)'); theta_sum_after_adding_zero);
ylabel('Amplitude');
legend; new_pole = real(s) -
title('Step response for Lead imag(s)/tan(deg2rad(theta_requ
compensated and uncompensated');
ired));
stepinfo(feedbk_sys)
stepinfo(feedbk_lead_sys) theta_from_lead =
rad2deg(angle(s - new_zero)) -
10.1.5-6 Lab Work 5-6 rad2deg(angle(s- new_pole));

clc; s = tf('s');
close all; sys = 1/(s*(s+3)*(s+6));
clear all; lead_compensator = (s-
new_zero)/(s-new_pole);
T = 0:0.01:15; lead_sys =
sys*lead_compensator;
OS = 0.20;
zeta = - % Uncompensated
log(OS)/sqrt(pi^2+(log(OS))^2) figure(1)
; rlocus(sys);
theta = rad2deg(acos(-zeta)); sgrid(zeta,50);
Ts = 2; %desired Ts axis([-15 5 -6 6])
[k_sys , poles_sys] =
% Desired point to find Ts = 2; rlocfind(sys);
sigma = -4/Ts; set(findall(gcf,'type','line')
wn = ,'linewidth',1.3);
sigma*tan(deg2rad(theta)); title('Root Locus for
s = sigma + j*wn; uncompensated system',
'Interpreter', 'Latex',
% Designing lead compensator 'Fontsize', 16);
new_zero = -5;
axIm = feedbk_sys =
findall(gcf,'String','Imaginar feedback(k_sys*sys,1);
y Axis (seconds^{-1})'); feedbk_lead_sys =
axRe = feedback(k_lead_sys*lead_sys,1
findall(gcf,'String','Real );
Axis (seconds^{-1})');
set(axIm,'String','Imaginary figure(3);
Axis', 'Interpreter', 'Latex', [y_sys,T] =
'Fontsize', 15); step(feedbk_sys,T); %step
set(axRe,'String','Real Axis', response of the uncompensated
'Interpreter', 'Latex', system.
'Fontsize', 15); [y_lead_sys,T] =
step(feedbk_lead_sys,T);
% Compensated plot(T,y_lead_sys,'DisplayName
figure(2) ',sprintf('Lead
rlocus(lead_sys); compensated'));
sgrid(zeta,50); hold on;
axis([-15 5 -6 6]) plot(T,y_sys,'DisplayName',spr
[k_lead_sys , poles_lead_sys] intf('Uncompensated'));
= rlocfind(lead_sys); xlim([0,T(end)]);
set(findall(gcf,'type','line') grid on;
,'linewidth',1.3); xlabel('t(s)');
title('Root Locus for ylabel('Amplitude');
compensated system', legend;
'Interpreter', 'Latex', title('Step response for Lead
'Fontsize', 16); compensated and
axIm = uncompensated');
findall(gcf,'String','Imaginar
y Axis (seconds^{-1})'); stepinfo(feedbk_sys)
axRe = stepinfo(feedbk_lead_sys)
findall(gcf,'String','Real
Axis (seconds^{-1})'); % Plot Ramp response
set(axIm,'String','Imaginary u = T; % input ramp signal
Axis', 'Interpreter', 'Latex',
'Fontsize', 15); e_ss_step_uncompensated = 1 -
set(axRe,'String','Real Axis', y_sys(end)
'Interpreter', 'Latex', e_ss_step_compensated = 1 -
'Fontsize', 15); y_lead_sys(end)

% Plot Step response figure(4);


[y_sys,T] = sgrid(zeta,50);
lsim(feedbk_sys,u,T); %ramp axis([-15 5 -6 6])
set(findall(gcf,'type','line'),'line
response of the uncompensated width',1.3);
system. title('Root Locus for compensated
[y_lead_sys,T] = system', 'Interpreter', 'Latex',
lsim(feedbk_lead_sys,u,T); 'Fontsize', 16);
axIm =
findall(gcf,'String','Imaginary Axis
plot(T,y_lead_sys,'DisplayName (seconds^{-1})');
',sprintf('Lead axRe = findall(gcf,'String','Real
compensated'));hold on; Axis (seconds^{-1})');
plot(T,y_sys,'DisplayName',spr set(axIm,'String','Imaginary Axis',
intf('Uncompensated')); 'Interpreter', 'Latex', 'Fontsize',
15);
xlim([0,T(end)]); grid on; set(axRe,'String','Real Axis',
xlabel('t(s)'); 'Interpreter', 'Latex', 'Fontsize',
ylabel('Amplitude'); 15);
legend; [k_sys , poles_sys] = rlocfind(sys);
title('Ramp response for Lead
compensated and closed_sys = feedback(k_sys*sys,1);
uncompensated');
t = 0:0.01:10;
e_ss_ramp_uncompensated = ramp = t;
u(end) - y_sys(end)
figure(2)
e_ss_ramp_compensated = u(end) [y,t] = step(closed_sys,t);
- y_lead_sys(end) plot(t,y);
xlabel('time(s)');
ylabel('Amplitude');
title("Step response");
10.1.7-8 Lab Work 7-8
legend('Closed loop step
response','Step input')
OS = 0.20; s = stepinfo(closed_sys)
zeta = - step_error = 1-y(end)
log(OS)/sqrt(pi^2+(log(OS))^2);
figure(3)
s = tf('s'); y = lsim(closed_sys,ramp,t);
uncompensated_sys plot(t,y,t,ramp);
=1/(s*(s+3)*(s+6)); xlabel('time(s)');
lead_controller = (s+3)/(s+13.6205); ylabel('Amplitude');
pi_controller = (s+0.8)/s; title("Ramp response");
sys = legend('Closed loop ramp
lead_controller*uncompensated_sys*pi response','Ramp input')
_controller; ramp_error = ramp(end)-y(end)

figure(1)
rlocus(sys);

You might also like