0% found this document useful (0 votes)
153 views6 pages

Pid Controllers Program

The document describes using MATLAB to simulate and analyze the response of a spring-mass-damper system with various PID controllers. It defines the transfer function of the system and runs step response simulations with P, PI, PD, and PID controllers, analyzing the response with each. Root locus plots are also generated to visualize the effect of each controller on the system poles.

Uploaded by

Pramod Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
153 views6 pages

Pid Controllers Program

The document describes using MATLAB to simulate and analyze the response of a spring-mass-damper system with various PID controllers. It defines the transfer function of the system and runs step response simulations with P, PI, PD, and PID controllers, analyzing the response with each. Root locus plots are also generated to visualize the effect of each controller on the system poles.

Uploaded by

Pramod Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

P,PD, PI & PID Control System

Tutorial
Spring-Mass-Damper System

Assuming m=1kg,b=10 Ns/m & k=20 N/m


MATLAB Program

%%Transfer Function For Spring Mass System


G=tf(1,[1 10 20]);
figure(1)
title('Step response without controllers')
step(G);
A=stepinfo(G);

%Proportional Control with Proportional Gain Kp=500


figure(2)
title('Step response with Proportional controller')
Kp=500;
C = pid(Kp)
P=tf(1,[1 10 20])
T = feedback(C*P,1)
t = 0:0.01:2;
step (T,t) _
B=stepinfo(T)

%Proportional derivative Control with Kp=500 & Derivative Gain Kd=10


figure(3)
title('Step response with Proportional Derivative controller')
Kp = 500;
Kd=10;
C = pid(Kp,0,Kd);
P=tf(1,[1 10 20]);
T1 = feedback(C*P,1)
step(T1);
C=stepinfo(T1)

%Proportional Integral Control with Kp=500 & ki=70


figure(4)
title('Step response with Proportional Integral controller')
Kp = 30;
Ki=70;
C = pid(Kp,Ki);
P=tf(1,[1 10 20]);
T2 = feedback(C*P,1);
step(T2);
D=stepinfo(T2)

%Proportional Integral Derivative Control with Kp=500, Kd=50 & ki=400


figure(5)
title('Step response with Proportional Integral Derivative controller')
Kp=500;
Kd=50;
Ki=400;
G=tf(1,[1 10 20]);
C=pid(Kp,Ki,Kd);
T3=feedback(C*G,1);
t=0:0.01:2;
step(T3,t);
E=stepinfo(T3)

MATLAB Program (with subplots)

%%Transfer Function for Spring Mass System


G=tf(1,[1 10 20]);
title('Step response without controllers')
subplot(5,1,1)
step(G);
A=stepinfo(G);

%Proportional Control with Proportional Gain Kp=500


title('Step response with Proportional controller')
Kp=500;
C = pid(Kp)
P=tf(1,[1 10 20])
T = feedback(C*P,1)
t = 0:0.01:2;
subplot(5,1,2)
step (T,t) _
B=stepinfo(T)

%Proportional derivative Control with Kp=500 & Derivative Gain Kd=10


title('Step response with Proportional Derivative controller')
Kp = 500;
Kd=10;
C = pid(Kp,0,Kd);
P=tf(1,[1 10 20]);
T1 = feedback(C*P,1)
subplot(5,1,3)
step(T1);
C=stepinfo(T1)

%Proportional Integral Control with Kp=500 & ki=70


title('Step response with Proportional Integral controller')
Kp = 30;
Ki=70;
C = pid(Kp,Ki);
P=tf(1,[1 10 20]);
T2 = feedback(C*P,1);
subplot(5,1,4)
step(T2);
D=stepinfo(T2)

%Proportional Integral Derivative Control with Kp=500, Kd=50 & ki=400


title('Step response with Proportional Integral Derivative controller')
Kp=500;
Kd=50;
Ki=400;
G=tf(1,[1 10 20]);
C=pid(Kp,Ki,Kd);
T3=feedback(C*G,1);
t=0:0.01:2;
subplot(5,1,5)
step(T3,t);
E=stepinfo(T3)

Matlab Program of PID control with toot locus

%%Transfer Function For Spring Mass System


G=tf(1,[1 10 20]);
figure(1)
title('Step response without controllers')
step(G);
A=stepinfo(G);
figure(2)
title('root locus for spring mass system')
rlocus(G)
grid on

%Proportional Control with Proportional Gain Kp=500


figure(3)
title('Step response with Proportional controller')
Kp=500;
C = pid(Kp)
P=tf(1,[1 10 20])
T = feedback(C*P,1)
t = 0:0.01:2;
step (T,t)
B=stepinfo(T)
figure(4)
title('root locus with proportional control')
rlocus(T)
grid on

%Proportional derivative Control with Kp=500 & Derivative Gain Kd=10


figure(5)
title('Step response with Proportional Derivative controller')
Kp = 500;
Kd=10;
C = pid(Kp,0,Kd);
P=tf(1,[1 10 20]);
T1 = feedback(C*P,1)
step(T1);
C=stepinfo(T1)
figure(6)
title('root locus with proportional derivative control')
rlocus(T1)
grid on

%Proportional Integral Control with Kp=500 & ki=70


figure(7)
title('Step response with Proportional Integral controller')
Kp = 30;
Ki=70;
C = pid(Kp,Ki);
P=tf(1,[1 10 20]);
T2 = feedback(C*P,1);
step(T2);
D=stepinfo(T2)
figure(8)
title('root locus with Proportional Integral controller')
rlocus(T2)
grid on

%Proportional Integral Derivative Control with Kp=500, Kd=50 & ki=400


figure(9)
title('Step response with Proportional Integral Derivative controller')
Kp=500;
Kd=50;
Ki=400;
G=tf(1,[1 10 20]);
C=pid(Kp,Ki,Kd);
T3=feedback(C*G,1);
t=0:0.01:2;
step(T3,t);
E=stepinfo(T3)
figure(10)
title('root locus with Proportional Integral derivative controller')
rlocus(T3)
grid on

You might also like