0% found this document useful (0 votes)
18 views7 pages

Lab4 108 CS P

this the lab of control system

Uploaded by

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

Lab4 108 CS P

this the lab of control system

Uploaded by

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

YOUSAF FA20-BEE-108-P LAB#4

LAB # 4: Design of Proportional-Integral-Derivative (PID) Controller using


MATLAB

 Objectives:
 To Design PID Controller for different systems.

 In-Lab Experiments:
 Mass-Spring-Damper Model
clc
close all
clear all

%%
M = 1;
B = 10;
K = 20;
Kp = 350; %propotional
Kd = 50; %derivative
Ki = 300; %integral
%%
num = [1];
den = [M B K];
system = pid(Kp, Ki, Kd)
System=tf(num, den)
subplot(211)
step(System)
legend('step responance')

s = series(system, System);
sys = feedback(s, 1);
subplot(212)
step(sys)
steady_error = abs(dcgain(1-sys))
stepinfo(sys)
legend('step responance')

1|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

 Simulink

clc
clear all
close all

M = 1;
b = 10;
k = 20;
F = 1;

2|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

 Task 2
clc
close all
clear all
%%
m = 0.111;
R = 0.015;
g = -9.8;
L = 1;
d = 0.03;
J = 9.99e-6;
Kp =100;
Ki = 120;
Kd = 250;
%%

3|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

num = [-(m.*g.*d)];
den = [L.*(J./(R.^2)+m) 0 0];
sys1 = tf(num, den)
sys2 = pid(Kp, Ki, Kd)
s = series(sys1, sys2);
system = feedback(s, 1)
step(system)
grid on
legend('step responance')
stepinfo(system)
steady_error = abs(dcgain(1-system))

 Simulink

4|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

 Post lab 1
clc
close all
clear all
%%
Kp = input ('Enter the value of Kp = ');
Ki = input ('Enter the value of Ki = ');
Kd = input ('Enter the value of Kd = ');
%%
C = pid(Kp,Ki,Kd);
num = [Kd Kp Ki];
den = [0 1 0];
PID = tf(num , den);

5|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

num1 = [400];
den1 = [1 48.5 0];
Tf1 = tf(num1 , den1)

figure
step(Tf1)
grid on
legend('step responance')
OTF = series(PID , Tf1)
OFTF = feedback(OTF , 1)

figure
step(OFTF)
stepinfo(OFTF)
grid on
legend('step responance')

 Post lab 2
clc
close all
clear all
%%
Kp = input('Enter the value of Kp = ');
Ki = input('Enter the value of Ki = ');
Kd = input('Enter the value of Kd = ');
%%

C = pid(Kp,Ki,Kd);
num = [Kd Kp Ki];
den= [0 1 0];
PID = tf(num , den);
B=10;
K=20;
J = 9.9.*(10.^-9); L=1;
R = 0.015;
num2 = [K];350
den2=[J.*L ((J.*R)+(B.*L).*(B.*R)+(K.^2))];
TF = tf(num2 , den2)

6|CONTROL SYSTEMS LAB REPORT


YOUSAF FA20-BEE-108-P LAB#4

figure
grid on
legend('step responance')
step(TF)
OTF = series(PID,TF)
OFTF = feedback(OTF,1)

figure
step(OFTF)
grid on
legend('step responance')
Info = stepinfo(OFTF)
err = abs(dcgain(1 - OFTF))

7|CONTROL SYSTEMS LAB REPORT

You might also like