The Basics of PID Control

Understanding Proportional, Integral, and Derivative Control.

THIS WEBSITE WAS DESIGNED USING A.I LLMs, ALL INFORMATION IS WRITTEN BY ME!

What is PID?

PID stands for Proportional, Integral, and Derivative.

PID is a method of, normally autonomous, control over motors that creates more dynamic movement as compared to the rigid velocity/voltage control students are likely used to.

Why and When should you use PID?

PID is more accurate than regular coding when it comes to fast movement. This can be useful for robots given the limited time of autonomous periods.

Interactive Example

Here's a cool website that shows PID in action!

🎮 Try the PID Simulator

How does PID work?

PID takes information from either the Motor encoder (data coming from the smart motors), a rotational sensor, or both and applies different values to that number in order to dynamically change the speed of the motor as it approaches the specified goal.

Comparison between PID and traditional motor control methods [Comparison.jpeg - Image would be displayed here]

Comparison between PID and traditional motor control methods

What does coding with PID look like?

It wouldn't be in the spirit of VEX to show a full coding example, but pseudocode is fine! The most important part of PID coding is the equation that makes it all possible.

Comparison between PID and traditional motor control methods [Equation.jpeg - PID equation would be displayed here]

The fundamental PID equation

PID Implementation Steps

Setup Phase

  • Reset motor position to 0
  • Set motor velocity to 0
  • Spin motor forward
  • Set Previous_error to 0
  • Set all variables used in code to 0

Main Control Loop

Error Calculation: Error = (Goal - Current Position)
Constants: Set Kp, Ki, and Kd values
Proportional: P = Error
Integral: I = Total Error + Error
Derivative: D = Error - Previous_Error
Output: Kp × P + Ki × I + Kd × D
Set Motor velocity to Output
Previous Error = Error

How do you find the PID constants?

You need to adjust the PID constants Kp, Ki, and Kd for every different system of your robot you are using PID Control on.

1

Adjust Kp (Proportional)

First, adjust Kp until it just barely overshoots the target.

2

Adjust Kd (Derivative)

From there, adjust Kd until it slows down just before the goal.

3

Adjust Ki (Integral)

Finally, Ki can be adjusted until your robot reaches the goal as quickly as possible without over or undershoot.

⚠️ Important Note

If Kd is too high, you will see fast jitter as the motor moves towards the goal.