Program
Program
Program: PI CONTROLLERS
output(i+1)=output(i)+dt×(control signal−output(i))
Where:
control signal = P + I
P = Kp * error(i)
I = Ki * integral
(a)Time=0.0
Error=setpoint-output=10-0=10
P=kp*error=(1*10)=10
Integral initial=0
I=ki*integral=0.1*0=0
Control signal=P+I=10+0=10
Initial output=0
(b)Time=0.1
Error=setpoint-output=10-0=10
P=kp*error=(1*10)=10
Integral =integral+error*dt=0+10*0.1=1
I=ki*integral=0.1*1=0.1
Control signal=P+I=10+0.1=10.1
Output(next)=output+dt(control signal-output)=0+(0.1*(10.1-0)=1.01
Tabular column:
Time P (Kp * I (Ki * Control Signal Output
Error Integral
(s) Error) Integral) (P + I) (next)
0.0 10.0 10.0 0.0 0.0 10.0 0.0
0.1 10.0 10.0 1.0 0.1 10.1 1.01
0.2 9.0 9.0 1.9 0.19 9.19 1.91
0.3 8.09 8.09 2.71 0.27 8.36 2.74
0.4 7.26 7.26 3.43 0.34 7.6 3.22
0.5 6.78 6.78 4.108 0.4108 7.19 3.617
. . . . . . .
. . . . . . .
1 5.41 5.41 7.02 0.702 6.112 4.74
2 …… ……. …… …….. ……… 5.70
PD CONTROLLERS
To manually calculate values and plot Time vs Output for your PD
Controller, follow these steps:
1. Understand the Update Formula:
Your PD controller updates the system output using:
output(i+1)=output(i)+dt×(control_signal−output(i))
where:
control_signal = P + D
Proportional Term → P = Kp * error(i)
Derivative Term → D =( Kd * (error(i) - prev_error)) / dt
(b)Time=0.1
Error=setpoint-output=10-0=10
P=kp*error=(1*10)=10
D=(kd*(error-prev_error))/dt=(0.1*(10-10))/0.1=0
Control signal=P+I=10+0=10
Output(next)=output+dt(control signal-output)=0+(0.1*(10-0)=1
(c)Time=0.2
Error=setpoint-output(next)=10-1=9
P=kp*error=(1*9)=9
D=(kd*(error-prev_error))/dt=(0.1*(9-10))/0.1=-1.0
Control signal=P+I=9-1=8
Output(next)=output+dt(control signal-output)=1+(0.1*(8-1)=1.7
Tabular column
Control
Time P (Kp * D ( Kd * (error(i) - Output
Error Signal
(s) Error) prev_error) )/ dt) (next)
(P+D)
0.0 10.0 10.0 0.0 10.0 0.0
0.1 10.0 10.0 0.0 10.0 1.0
0.2 9.0 9.0 -1.0 8.0 1.7
0.3 8.2 8.2 -0.8 7.4 2.5
EXPERIMENT NO 13
IMPLEMENT A PID CONTROLLER AND HENCE REALIZE
AN ERROR DETECTOR
To manually calculate and plot Time vs Output and Time vs Error,
follow these steps:
1. Understanding the Update Formula
Your PID controller updates the system output with:
output(i+1)=output(i)+dt×(control_signal−output(i))
Where:
Control Signal → P + I + D
Proportional Term → P = Kp * error(i)
Integral Term → I = Ki * integral
Derivative Term → D = Kd * derivative
(a)Time=0.0
Error=setpoint-output(initial)=10-0=10
P=kp*error=(1*10)=10
I=ki*integral=0.1*0=0
D=(kd*(error-prev_error))/dt=(0.01*(10-10))/0.1=0
Control signal=P+I+D=10+0+0=10
Initial output=0
(b)Time=0.1
Error=setpoint-output(initial)=10-0=10
P=kp*error=(1*10)=10
Integral =integral+error*dt=0+10*0.1=1
I=ki*integral=0.1*1=0.1
D=(kd*(error-prev_error))/dt=(0.01*(10-10))/0.1=0
Control signal=P+I+D=10+1+0=11
Output(next)=output+dt(control signal-output)=0+(0.1*(11-0)=1.1
(c)Time=0.2
Error=setpoint-output(next)=10-1.1=8.9
P=kp*error=(1*8.9)=8.9
Integral =integral(above value)+error*dt=1+8.9*0.1=1.89
I=ki*integral=0.1*1.89=0.189
D=(kd*(error-prev_error))/dt=(0.01*(8.9-10))/0.1=-0.11
Control signal=P+I+D=8.9+0.189-0.11=8.97
Output(next)=output+dt(control signal-output)=1.1+(0.1*(8.97-1.1)=1.88
(c)Time=0.3
Error=setpoint-output(next)=10-1.88=8.12
P=kp*error=(1*8.12)=8.12
Integral =integral(above value)+error*dt=1.89+8.12*0.1=2.702
I=ki*integral=0.1*2.702=0.2702
D=(kd*(error-prev_error))/dt=(0.01*(8.12-8.9))/0.1=-0.078
Control signal=P+I+D=8.12+0.2702-0.078=8.31
Output(next)=output+dt(control signal-output)=1.88+(0.1*(8.31-1.88)=2.52
EXPERIMENT NO 14
DEMONSTRATE THE EFFECT OF PI, PD AND PID
CONTROLLER ON THE SYSTEM RESPONSE
n=[1];
d=[1 10 20];
kp_pd=500;
kd_pd=10;
c_pd=tf([kp_pd kd_pd],1);
p=tf(n,d);
t1=feedback(c_pd*p,1);
t=0:0.01:2;
subplot(3,1,1);
step(t1,t);
grid;
title('pd controller');
kp_pi=30;
kd_pi=70;
c_pi=tf([kp_pi kd_pi],[1 0]);
p=tf(n,d);
t2=feedback(c_pi*p,1);
subplot(3,1,2);
step(t2,t);
grid;
title('pi controller')
kp_pid=500;
ki_pid=400;
kd_pid=50;
c_pid=tf([kd_pid kp_pid ki_pid],[1 0]);
p=tf(n,d);
t3=feedback(c_pid*p,1);
subplot(3,1,3);
step(t3,t);
grid;
title('pid controller');
figure(2);
step(t1,t2,t3,'r---');
title('comparision of all the response');
legend({'pd controller','pi controller','pid controller'},'Location','best');
legend('boxoff');
grid;
Output:
System Transfer Function:
G(s)=1/s^2+10s+20
1. PD Controller:
Kd=10 or K_d = 10
CPD(s)=Kp+Kds
=500+10s
TOL(s)=CPD(s)⋅G(s)
=(10s+500)/s^2+10s+20
TCL(s)=TOL(s)/1+TOL(s)
=10s+500/s^2+20s+(520)
2. PI Controller:
Ki=70 or K_i = 70
Controller transfer function:
CPI(s)=Kp+Kis=30+70s
TOL(s)=CPI(s)⋅G(s)
=(30s+70)/s(s^2+10s+20)
TCL(s)=TOL(s)/1+TOL(s)
=(30s+70)/s^3+10s^2+50s+70
3. PID Controller:
CPID(s)=Kp+Kis+Kds
=500+400s+50s
TOL(s)=CPID(s)⋅G(s)
=(50s^2+500s+400)/s(s^2+10s+20)
TCL(s)=TOL(s)/1+TOL(s)
=(50s^2+500s+400)/s^3+60s2+520s+400