Arduino-PID-Library icon indicating copy to clipboard operation
Arduino-PID-Library copied to clipboard

Understanding the Parameters Ki,Kp,Kd

Open TonyWilk opened this issue 7 years ago • 4 comments

This may be helpful to anyone trying to understand what the parameters do...

The output of the PID in the Compute() method is:

      /*Compute PID Output*/
      double output = kp * error + ITerm- kd * dInput;

so, if you print out the values of Kp*error, ITerm and -kd * dInput you can see how each parameter makes up the output value.

Start by using parameters Kp=1.0, Ki=0.0, Kd=0.0 then try Kp=0.0, Ki=1.0, Kd=0.0 and so on.

It is useful to note that the output is just the ITerm when it reaches the setpoint. The PID will always reach the setpoint with only a Ki parameter, but it may take some time. The Kp and Kd parameters are used to speed up getting near the setpoint.

One way to simply do this is... in PID:Compute(), after /* Compute PID Output */ add the following:

     // save each term of the output equation
      dispKp= kp * error;
      dispKi= ITerm;
      dispKd= 0-(kd * dInput);

then use the PID:GetKp(), PID:GetKi() and PID:Kd() to get those values in your main code

Yours, TonyWilk

TonyWilk avatar Apr 10 '17 10:04 TonyWilk

Didn't really understand how to do it. Could someone explain it again? Thanks!

edgsc avatar Sep 20 '17 16:09 edgsc

Try this for an explanation of PID parameters. http://survivingtheworld.net/ScienceComic3.html

patrickstanley avatar Sep 22 '17 18:09 patrickstanley

Really nice =), but my problem isn't understanding the PID parameters, but how to DISPLAY each term.

I ended modifying: dispKp= kp ; dispKi= ki; dispKd= kd;

And calculating on Excel the P Term, I Term and D term contribuitions for the output.

But what I really whished was to be able to show each term only with Arduino code.

edgsc avatar Sep 22 '17 18:09 edgsc

http://brettbeauregard.com/blog/2009/05/graphical-front-end-for-the-arduino-pid-library/

rtek1000 avatar Apr 23 '22 15:04 rtek1000