How to set PID values

We are working on coding our PID controller (this year is our first time using it) and we are planning on setting Ki and Kd to zero, and then “tuning” Kp. How can we determine the other variables’ value? We are completely at a loss for what to do or what to look at to calculate them.

I would go through PID Control in WPILib — FIRST Robotics Competition documentation. but a starting point is keep increasing P until u get oscillation and then add D to reduce it.

1 Like

There is a lot of options here - from guessing and checking to trying to determine the transfer function of your mechanism. It really depends on your skill level.

Starting with kP is a good idea, mainly because it is the most intuitive, it will scale your output proportionally to your error. Start with a very small value. In general, kP shouldn’t be greater than 1/(max error) because this would attempt to drive your output to max power. This is relative of course to how you normalize your inputs/outputs, but unless you are doing something special, make sure you follow this rule.

My preferred method of tuning is to keep a small kP, and slowly dial it up until I am close to my goal but not quite there. Then I slowly increment kI. The reason I do this is because it can be shown mathematically that any value of kI will drive your steady state error to 0. This does not mean that you should choose kI poorly, as there is a variety of stability issues you can cause with a big kI.

I don’t use kD very often, but this is more preference. As legoguy1000 mentioned, you can basically do the “opposite” of my approach - tune kP until a little overshoot and then up kD to decrease it.

My last note is that if you are feeling sophisticated, take a look at the WPIlib docs, specifically the sysid tool.


Even more specifically, spend time with the interactive tuning examples.

They’ll go through the traditional methods of how to tune “to-taste”, and where I at least recommend most beginners start at.

System identification or first-principals approaches are better in some ways as next steps, but don’t help build intuition as quickly as getting hands on and figuring out what to do manually the first time.

<dodges tomatoes>


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.