Tuning a PID Loop

I recently learned about PIDs and have implemented them for our tray, allowing it to slow down as it reaches the target. However, I do not know how to tune the Proportional, Integral, and Derivative. Is there a technique to know your PID has been tuned “perfectly”? Any help would be appreciated!

1 Like

I’ve heard you just play around with the different constants.
But take this with a grain of salt


In general you tune kP, kI, and kD by trial and error - I’d recommend tuning kP by itself first by setting kI and kD to zero (or just using the proportional part by itself, which should work fine in most cases).

If you’re looking for a mathematical model to tune your PID controller (Note: I’ve never tried using a math model for tuning), I’d recommend the Ziegler-Nichols Method but to be honest, just trial and error should be good enough for VRC purposes


Nah man I just trial and error until I feel like it’s good lol

1 Like

More seriously though, start by tuning the P value first, like how others have suggested. However, you want the system to overshoot the set point by a little bit. Then tune D to slow down the system so that it doesn’t overshoot. Finally the I value. This one is tricky since the I component of PID is mainly there to help the system overcome additional external forces that might get in the way (gravity, friction, etc). That’s why you tune I after you get your P and D down. Since it’s a tray that you’re tuning, I suggest adding the full amount of cubes that your tray can support and running it with P and D. If the tray can’t fully go up since the gravity of the additional cubes is too much, then you can start increasing I until then tray has sufficient force to stack the cubes.
Tune P, then D, then after that I


How do you exactly tune the kP and how do you know when it works? I know you need to change the value to any number from 0 to 1 but I can’t tell a difference when the number is changed. My team’s pid loop goes on for forever when I run it and I am unsure how to fix this.