Sie sind auf Seite 1von 7

Manually Tunning of PID Controller:

Theory:

A PID controller consists of a Proportional element, an Integral element and a Derivative element, all
three connected in parallel. All of them take the error as input. Kp, Ki, Kd are the gains of P, I and D
elements respectively.

The best way to understand something is by simulating it. So I simulated a PID controller in matlab. The
matlab code is provided at the end of this article.

Let me assume a suitable mathematical model for the plant and then go ahead with designing the
controller.

Let the transfer function of the plant be 1 / ( s^2 + 20s + 30 ).

The step response of a system is the output of the system when the input to the system is a unit step.
The open loop step response of the above plant is

num=1;
den=[1 20 30];
Plant = tf(num,den);
step(Plant,r);

xlabel('Amplitude---->');

ylabel('time----->');
title('Plant Function Response');

Fig 1 : Unit Step Response of Plant

It can be seen that the step response output is close to 0.035. The steady state error = 1-0.035 = 0.965.
Thats quite high! Also observe that the settling time is around 3 sec.

Now lets see what is the effect of PID controller on the system response.
Lets see the effect of proportional element on the system output.

Keeping Kp = 10, Ki = 0, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=10;
P_Sys = tf(Kp,1);
OpenLoop=series(P_Sys,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');

ylabel('time----->');
title(P Controller Response');

Fig 2 : P Controller Response by increasing Kp

The output is now 0.25. Much better than the open loop response! (The curve in red shows the open
loop step response of the plant)

Now let me increase the Kp further and observe the response.


Keeping Kp = 100, Ki = 0, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=100;
P_Sys = tf(Kp,1);

OpenLoop=series(P_Sys,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');

ylabel('time----->');
title(P Controller Response');

Fig 3: Reduced Steady state Error P- Controller Response

The output is now 0.77. So its clear now that increasing Kp will reduce the steady state error.

Keeping Kp = 200, Ki = 0, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=200;
P_Sys = tf(Kp,1);

OpenLoop=series(P_Sys,Plant);
ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');

ylabel('time----->');
title(P Controller Response');

Fig 4: Final P- Controller Response

The output is around 0.87. Also observe that the ripples have started appearing in the output. If Kp is
increased further it will only lead to increase in ripples or overshoot. The rise time also has decreased.
Also observe that there is a small steady state error (1 0.87 = 0.13).

Conclusion
Increasing Kp will reduce the steady state error.
After certain limit, increasing Kp will only increase overshoot.
Kp reduces rise time.

Now lets keep Kp fixed. Lets start varying Ki.

Keeping Kp = 200, Ki = 10, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=200;
P_Sys = tf(Kp,1);

Ki=10;
den2=[1 0];
I_Sys=tf(Ki,den2);

PI=parallel(P_Sys,I_Sys);

OpenLoop=series(PI,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');

ylabel('time----->');
title(PI Controller Response');
Fig 5: PI Controller Unit Step Response

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=200;
P_Sys = tf(Kp,1);

Ki=300;
den2=[1 0];
I_Sys=tf(Ki,den2);

PI=parallel(P_Sys,I_Sys);

OpenLoop=series(PI,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');

ylabel('time----->');
title(PI Controller Response');

Fig 6: PI-Controller Response Reduced Setting Time

The output is now close to 0.99. Thats very close to the setpoint. But observe that settling time has
increased.

Keeping Kp = 200, Ki = 200, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);

Kp=200;
P_Sys = tf(Kp,1);

Ki=200;
den2=[1 0];
I_Sys=tf(Ki,den2);

PI=parallel(P_Sys,I_Sys);

OpenLoop=series(PI,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

xlabel('Amplitude---->');
ylabel('time----->');
title(PI Controller Response');

Fig 7: Final PI Controller Reduced Settling Time and Steady State Error.

Observe that rise time has now reduced and steady state error is very small.

Keeping Kp = 200, Ki = 300, Kd = 0 the step response of the system is

num=1;
den=[1 20 30];
Plant = tf(num,den);
step(Plant,r);
hold on;

Kp=200;
P_Sys = tf(Kp,1);

Ki=300;
den2=[1 0];
I_Sys=tf(Ki,den2);

Kd=0;
num3=[Kd 0];
D_Sys=tf(num3,1);

PI=parallel(P_Sys,I_Sys);

PID=parallel(PI,D_Sys);

OpenLoop=series(PID,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

Fig 8: Final PID Controller Unit Step Response

Observe that steady state error is close to 0 now. But increasing Ki has resulted in overshoot.

Further increasing Ki will only increase overshoot.


Conclusion
Ki eliminates the steady state error.
After certain limit, increasing Ki will only increase overshoot.
Ki reduces rise time.

Now lets Keep Ki fixed and start varying Kd.

Keeping Kp = 200, Ki = 300 and Kd = 10.

num=1;
den=[1 20 30];
Plant = tf(num,den);
step(Plant,r);
hold on;

Kp=200;
P_Sys = tf(Kp,1);

Ki=300;
den2=[1 0];
I_Sys=tf(Ki,den2);

Kd=10;
num3=[Kd 0];
D_Sys=tf(num3,1);

PI=parallel(P_Sys,I_Sys);

PID=parallel(PI,D_Sys);

OpenLoop=series(PID,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

Fig 9: PID Controller Unit Step Response(Final Response)

Wow! What a response! Where is the overshoot? It has disappeared. There is a reduction in settling
time as well.

Increasing Kd further will only result in response getting worsened.


Conclusion
Kd decreases the overshoot.
Kd reduces settling time.

So the ideal PID values for our plant is Kp = 200, Ki = 300 and Kd = 10.

The above process is known as manual tuning of PID.

Here is the matlab code used to simulate PID


(The below code is written by me. So please let me know if you find any bugs!)

Program 1:PID Tunning

num=1;
den=[1 20 30];
Plant = tf(num,den);
step(Plant,r);
hold on;

Kp=200;
P_Sys = tf(Kp,1);

Ki=300;
den2=[1 0];
I_Sys=tf(Ki,den2);

Kd=10;
num3=[Kd 0];
D_Sys=tf(num3,1);

PI=parallel(P_Sys,I_Sys);

PID=parallel(PI,D_Sys);

OpenLoop=series(PID,Plant);

ClsdLoop = feedback(OpenLoop,[1]);
step(ClsdLoop,b);

Fig 10: PID Controller Response Manually Tunned.

Das könnte Ihnen auch gefallen