Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
Alexander Youngblood edited this page Apr 6, 2019 · 5 revisions

The Fundamental Concept of PID

At its most basic, PID is a method to reduce change a number to a setpoint. It is employed in systems that have irregular output that is imperfect in some way. For example, a thermostat told to heat until a certain number of degrees cannot account for the leftover heat in the heating mechanism, which will cause the room to heat slightly further. A PID system would use the error from the setpoint (target temperature - current temperature) and produce an output for the thermostat to act upon. There is an excellent paper explaining the topic in depth here.

Kp, Ki, and Kd explained:

The PID controller uses three parts, the proportional, the integral, and the derivative, each of which are a function of the error. It calculates its output by adding up the result of each.

Proportional: The proportional is the main power behind the output. P is proportional to the error. The result is P times error. As you near your target, the error begins to decrease, and so does the proportional value. Essentially, the output lowers as it nears the target.

Integral: Integral takes the total amount of error over time. The result is I times total error. It acts as a booster so the measured error can get to its target faster. It is most important for countering steady-state error, which is essentially when the system is putting out power but it isn't making progress towards the target. (Such as friction holding the robot back).

Derivative: D takes the derivative of the proportional. The result is D times difference in error over difference in time. As P decreases as it nears the target, the derivative has a negative value. This is means that D will be subtracting from P and reducing the overall output. If error is dropping at a very high rate (i.e. the robot is nearing the target at significant speed), D is like "oh no, you're gonna overshoot" and subtracts the output so the robot doesn't put in too much power. The higher P, the higher D, so D is an effective "dampener" for the robot.

Finally, PID outputs all three results added together. When tuning, you want to start with just a P value to see how much power the robot needs to make it to the target quickly. Then, you should add D in order to make sure the robot doesn't overshoot and oscillate too much. Since we want our robot to be fast and efficient, we want P to be as high as possible so the robot gets to its target in the smallest amount of time (WITHOUT BREAKING THE ROBOT)! Make sure to increase D as you increase P so that it reaches the target smoothly. Then, add I (should be a small value!) just in case there is steady-state error. This will make the robot put in even more power, so be ready for that. The document linked above also contains a more precise guide for tuning PID.

An excellent video that explains the concept behind PID, and another good video that explains PID with cars.

Clone this wiki locally