Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

PID control is a feedback method used in robotics to make motors, arms, drivetrains, and sensors reach a target value smoothly. This cheat sheet helps students connect the formulas to real robot behavior such as overshoot, steady-state error, and oscillation. It is useful when tuning autonomous robots, line followers, balancing robots, and mechanisms that need precise motion.

A PID controller compares a desired setpoint to a measured process value and calculates an error. The control output is the sum of proportional, integral, and derivative actions: u(t) = Kp e(t) + Ki ∫e(t)dt + Kd de(t)/dt. The proportional term reacts to current error, the integral term reacts to accumulated error, and the derivative term reacts to how fast error is changing.

Good tuning balances quick response, stability, and low steady-state error.

Key Facts

  • The error is e(t) = setpoint - measured value, so the sign of the error determines the direction of correction.
  • The full continuous PID formula is u(t) = Kp e(t) + Ki ∫e(t)dt + Kd de(t)/dt.
  • The proportional term is P = Kp e(t), and increasing Kp usually makes the robot respond faster but can increase overshoot.
  • The integral term is I = Ki ∫e(t)dt, and it helps remove steady-state error by adding correction based on accumulated error.
  • The derivative term is D = Kd de(t)/dt, and it helps reduce overshoot by reacting to rapid changes in error.
  • A common discrete PID update is u = Kp e + Ki sum(e)Δt + Kd (e - previous error)/Δt.
  • Integral windup occurs when sum(e) grows too large while the actuator is saturated, so many systems clamp or limit the integral term.
  • A stable PID loop needs a consistent sample time Δt because changing Δt changes the size of the integral and derivative terms.

Vocabulary

Setpoint
The target value the robot is trying to reach, such as a desired speed, angle, distance, or position.
Process value
The measured current value from a sensor, such as encoder position, gyro angle, or motor speed.
Error
The difference between the setpoint and the process value, calculated as error = setpoint - process value.
Control output
The command sent to an actuator, such as motor power or servo position, after the PID terms are combined.
Gain
A tuning constant such as Kp, Ki, or Kd that changes how strongly a PID term affects the output.
Overshoot
A response where the robot passes beyond the target value before settling back toward it.

Common Mistakes to Avoid

  • Using error = measured value - setpoint without checking motor direction is wrong because it can make the controller drive farther away from the target.
  • Raising Kp too much is wrong because a fast response can become oscillation if the robot keeps overcorrecting around the setpoint.
  • Ignoring Δt in the integral and derivative terms is wrong because the controller output changes when the loop runs faster or slower.
  • Letting the integral term grow without limits is wrong because integral windup can cause a large delayed correction even after the robot reaches the target.
  • Adding derivative control to noisy sensor data without filtering is wrong because the derivative term can amplify sudden measurement jumps.

Practice Questions

  1. 1 A robot arm has a setpoint of 90 degrees and a measured angle of 74 degrees. What is the error if error = setpoint - measured value?
  2. 2 A motor speed controller has Kp = 0.4 and error = 25 rpm. What is the proportional output P?
  3. 3 A discrete controller has e = 8, previous error = 5, and Δt = 0.1 s. What is the derivative estimate (e - previous error)/Δt?
  4. 4 A robot reaches the target but keeps oscillating around it. Which PID terms might you adjust, and why?