0% found this document useful (0 votes)
10 views11 pages

Auto Lab4

Uploaded by

cherietishak2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

Auto Lab4

Uploaded by

cherietishak2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lab 04: closed –loop performances

PID controller
Date:12/12/2024
Speciality : automatic
Name : Debieche Lina
Group :02
Part A(steady state error):
1.
Code:
Method1 :we give values to k until we error=10%
t=0:0.01:8;
K=672
num=[K 5*K];
den=[1 21 146 336 0];
G=tf(num,den)
r=t;
T=feedback(G,1)
f=lsim(T,r,t)
figure(1)
plot(t,f,t,r)
err=abs(r(end)-f(end))
results:
8

0
0 1 2 3 4 5 6 7 8

err= 0.1000
method2:
numerator = [1 5];
denominator = conv([1 6], conv([1 7], [1 8]));
Kv_desired = 1 / 0.1;
K = Kv_desired * denominator(4) / numerator(2);
disp('Part A:');
fprintf('The value of K for 10%% steady-state error is:
%.2f\n', K);

results:
Part A:
The value of K for 10% steady-state error is: 672.00
Part B(stability and transient response performances):
Code:
shoot=0.05;
ts=4;
ep=sqrt((log(0.05))^2/(pi^2+(log(0.05))^2))
wn=3/ts*ep
p=2*ep*wn
k=wn^2
num=[k];
den=[1 p 0];
G1=tf(num,den)
T1=feedback(G1,1)
stepinfo(T1)
step(T1)
results:
ep =

0.6901

wn =

0.5176

p=

0.7144

k=

0.2679

G1 =
0.2679

--------------

s^2 + 0.7144 s

Continuous-time transfer function.

T1 =

0.2679

-----------------------

s^2 + 0.7144 s + 0.2679

Continuous-time transfer function.

ans =

RiseTime: 4.0518

SettlingTime: 11.5835

SettlingMin: 0.9005

SettlingMax: 1.0500

Overshoot: 5.0000

Undershoot: 0

Peak: 1.0500

PeakTime: 8.3804
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 2 4 6 8 10 12 14 16 18
Time (seconds)

Part C:(PID controller on a DC motor):


Proportional controller only P:(d=0)
Code:
J=3.2284e-6;
b=3.5077e-6;
K=0.0274;
R=4;
L=2.75e-6;
Kp=[1 11 21];
den=[J*L J*R+L*b b*R+K^2 0];
P=tf(K,den);
for i=1:length(Kp)
C=Kp(i);
T=C*P;
G=feedback(T,1);
step(G)
hold on
stepinfo(G)
end
results:
ans =
RiseTime: 0.0055

SettlingTime: 0.1241

SettlingMin: 0.5901

SettlingMax: 1.6406

Overshoot: 64.0578

Undershoot: 0

Peak: 1.6406

PeakTime: 0.0149

Step Response
1.8

1.6

1.4

1.2
Amplitude

0.8

0.6

0.4

0.2

0
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Time (seconds)

Propotional and integral controller PI (d=0):


Code:
J=3.2284e-6;
b=3.5077e-6;
K=0.0274;
R=4;
L=2.75e-6;
Kp=21;
Ki=[100 300 500];
den=[J*L J*R+L*b b*R+K^2 0];
P=tf(K,den);
for i=1:length(Ki)
C=tf([Kp Ki(i)],[1 0]);
T=C*P;
G=feedback(T,1);
step(G)
hold on
end
stepinfo(G)
results:
ans =

RiseTime: 0.0053

SettlingTime: 0.2143

SettlingMin: 0.4074

SettlingMax: 1.7970

Overshoot: 79.7038

Undershoot: 0

Peak: 1.7970

PeakTime: 0.0150
Step Response
1.8

1.6

1.4

1.2
Amplitude

0.8

0.6

0.4

0.2

0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
Time (seconds)

Proportionel integral and derivative controller


PID(d=0):
Code:
J=3.2284e-6;
b=3.5077e-6;
K=0.0274;
R=4;
L=2.75e-6;
Kp=21;
Ki=500;
Kd=0.05:0.1:0.25;
den=[J*L J*R+L*b b*R+K^2 0];
P=tf(K,den);
for i=1:length(Kd)
C=tf([Kd(i) Kp Ki],[1 0]);
T=C*P;
G=feedback(T,1);
step(G)
hold on
end
stepinfo(G)
results:
ans =

RiseTime: 0.0037

SettlingTime: 0.0435

SettlingMin: 0.9103

SettlingMax: 1.0431

Overshoot: 4.3065

Undershoot: 0

Peak: 1.0431

PeakTime: 0.0131

Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Time (seconds)

Case of d=1:

Code:

J=3.2284e-6;
b=3.5077e-6;
K=0.0274;
R=4;
L=2.75e-6;
Kp=21;
Ki=500;
Kd=0.05:0.1:0.25;
den=[J*L J*R+L*b b*R+K^2 0];
P=tf(K,den);
for i=1:length(Kd)
C=tf([Kd(i) Kp Ki],[1 0]);
T=(C+1)*P;
G=feedback(T,1);
step(G)
hold on
end
stepinfo(G)

results:

ans =

RiseTime: 0.0036

SettlingTime: 0.0409

SettlingMin: 0.9039

SettlingMax: 1.0454

Overshoot: 4.5385

Undershoot: 0

Peak: 1.0454

PeakTime: 0.0121
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14
Time (seconds)

You might also like