How to set KP value of a pid program

Hello, this is my fourth year in Vex and my second year in EDR. I am planning on putting a pid program this year. I have basic understanding of proportion however, I do not exactly understand how to set the value of KP. It would be great if anyone knew.

make a float variable called kP and set it to a value of 1. In the pid task, when you subtracted current from target to get error, you multiply the error variabke by kP to get a motor value and you set all motors in the subsystem to that value. If when you test it there is a lot of overcorrection, reduce kP. If it does not go far enough, increase kP.

Basically trial and error. A good place to start is 1 if using an encoder and 0.0635 with a potentiometer. Increase kP if the system doesn’t get close enough and decrease it if it overshoots.

To determine the appropriate kP you will need to ‘tune’ your PID. The Wiki on PID Controllers has a section explaining tuning https://en.wikipedia.org/wiki/PID_controller (this article is technical, don’t be frustrated if you can only follow parts of it). As others have said manually tuning is good place to start, especially if you are only using P (and not the I or D). The Ziegler–Nichols method is another common way of tuning.

The appropriate value of P will depend on what you are using PID for and other factors like gear ratios, friction, and the resolution of what you are measuring. Generally starting with 1 and tuning from there is usually a safe bet.

Keep in mind that there is no ‘correct’ kP value; the answer is more subjective. Let’s say you are using PID for turning with a gyro. If you want a precise turn that does not overshoot the target, then kP will be small. The tradeoff is that the turn will be slow. Making kP larger will speed it up, to a certain point. If kP is too large then it will be unstable.

I mentioned this resource in another thread about PID tuning: https://www.crossco.com/blog/basics-tuning-pid-loops

See this article I wrote on the RobotC data log function.

Use it to view/graph your error & integral values. Gets you ASAP PID tuning when you can see exactly the effect your changes of Kp, Ki, and Kd have.

Here’s a video I found very useful when I was doing it.