Skip to main content

Section 1.4 Fundamentals of PID Control

A Proportional-Integral-Derivative (PID) Controller is the most widely used closed-loop control algorithm in robotics. It continuously measures an error \(e(t)\)β€”the difference between the desired setpoint \(r(t)\) and the actual measured value \(y(t)\text{:}\)
\begin{equation*} e(t) = r(t) - y(t) \end{equation*}
It then calculates a control signal \(u(t)\) combining three distinct mathematical actions:
\begin{equation*} u(t) = K_p e(t) + K_i \int_0^t e(\tau) \, d\tau + K_d \frac{de(t)}{dt} \end{equation*}
To understand how these three terms work together, imagine driving a car toward a red light at a stop light:
Figure 1.4.1. A PID controller combines proportional, integral, and derivative responses to drive a system toward its desired setpoint.

Subsection 1.4.1 Breakdown of the Car Analogy

To connect the math \(u(t) = K_p e(t) + K_i \int_0^t e(\tau) \, d\tau + K_d \frac{de(t)}{dt}\) to driving a car toward a red light:
  • Error \(e(t)\text{:}\) The remaining distance between your car and the stop light.
  • Proportional Term (\(K_p \cdot e(t)\)) β€” Present Error: Pushes the brake or gas proportional to how far away you are. If you are far away, press hard on the gas; as you get closer, ease off.
  • Integral Term (\(K_i \int e(\tau) \, d\tau\)) β€” Past Accumulation: Accounts for persistent past error. If a slight uphill slope prevents the car from reaching the stop line despite \(K_p\text{,}\) error accumulates over time, gently building up extra throttle to nudge the car to the exact setpoint.
  • Derivative Term (\(K_d \cdot \frac{de(t)}{dt}\)) β€” Future Trend: Looks at how fast the error is changing (your approach speed). If you are closing in fast, \(\frac{de(t)}{dt}\) is strongly negative, applying resistance (braking) early to prevent overshooting the stop line.

Subsection 1.4.2 Interactive PID Simulator

Adjust the tuning gains (\(K_p\text{,}\) \(K_i\text{,}\) and \(K_d\)) to see how the system output responds to a step change in setpoint.

Subsection 1.4.3 The Proportional Term (P) β€” "How far am I right now?"

  • Formula: \(K_p \cdot e(t)\)
  • Concept: Reacts strictly to the present error. The farther you are from your target, the harder the system pushes.
  • Real-Life Example: You are driving toward a stop line 100 meters away. When you are far away (100 m error), you press the gas pedal down hard. As you get closer (10 m error), you ease off the pedal proportional to the remaining distance.
  • Robotic Limitation: If your robot encounters physical resistance (e.g., floor friction or gravity on an incline), the motor force generated by \(K_p \cdot e(t)\) eventually drops below the friction threshold. The robot stops before reaching the goal, leaving a persistent steady-state error.

Subsection 1.4.4 The Integral Term (I) β€” "How long have I been stuck?"

  • Formula: \(K_i \cdot \int_0^t e(\tau) \, d\tau\)
  • Concept: Sums up past errors over time. If an error persistsβ€”no matter how smallβ€”the integral accumulator steadily grows to push the system harder.
  • Real-Life Example: Imagine trying to hold a car steady on a steep hill using just the throttle. If you stop slightly short of your target mark because gravity is holding you back, the integral term notices: β€œWe’ve been 0.5 meters short for 5 seconds now!” It ramps up extra engine torque to climb those last few centimeters and eliminate the gap completely.
  • Robotic Limitation: If \(K_i\) is tuned too high, it can accumulate too much momentum (called integral windup), causing the system to shoot past the goal before catching itself.

Subsection 1.4.5 The Derivative Term (D) β€” "How fast am I approaching?"

  • Formula: \(K_d \cdot \frac{de(t)}{dt}\)
  • Concept: Predicts future error by looking at the current rate of change. It acts as an automatic brake when approaching the goal quickly.
  • Real-Life Example: Even if you are 20 meters away from the stop line, if your speedometer says you are moving at 90 km/h, common sense tells you to slam on the brakes now to avoid crashing through the intersection. The derivative term measures this rapid closure rate (\(\frac{de}{dt}\)) and exerts an opposing counter-force to smooth out your arrival.
  • Robotic Advantage: Dampens oscillations and prevents the robot from violently overshooting its target position.

Subsection 1.4.6 Summary of PID Roles

Term Focus Real-Life Analogy Main Benefit Main Risk
P (Proportional) Present How hard you press the gas based on distance Fast initial response to reach target Steady-state error under friction
I (Integral) Past Adding throttle on a hill when stuck short of target Eliminates steady-state error completely Overshoot & instability if over-accumulated
D (Derivative) Future Pressing the brake early when closing in too fast Dampens overshoot & smooths stopping Amplifies high-frequency sensor noise

Subsection 1.4.7 Section 1.4 Interactive Exercises

Subsubsection 1.4.7.1 Exercise 1.4.1: Tuning Proportional Gain (\(K_p\)) & Integral Gain (\(K_i\)) Simulation

Below is a 1D simulation of a robot attempting to reach \(x_{\text{goal}} = 10.0\) meters using proportional control (\(K_p\)) subject to steady friction.
Task:
  1. Run the code with KP_VAL = 0.5 and KI_VAL = 0.0. Notice how physical friction halts the robot around \(x \approx 7.0\) m, leaving a persistent steady-state error.
  2. Increase KP_VAL to 1.5 and 3.0. Notice how a stronger proportional force pushes closer to the goal but starts overshooting.
  3. Reset KP_VAL = 0.5 and set KI_VAL = 0.2. Watch how the integral term builds force over time to drag the robot all the way to 10.0 m.

Reading Questions 1.4.8 Reading Questions

Check your understanding

1. Exercise 1.4.2: PID Term Matching Conceptual Check.

Which component of a PID controller acts like a "brake" to dampen overshoot and oscillation by resisting rapid changes in error state?
  • Proportional Term
  • Incorrect. The proportional term produces control output directly relative to current error magnitude, which often causes overshoot if set high.
  • Integral Term
  • Incorrect. The integral term accumulates historical error over time to eliminate steady-state offsets.
  • Derivative Term
  • Correct! The derivative term measures the rate of change of error (\(\frac{de}{dt}\)) and acts as a dampener to prevent overshoot.
  • Feedforward Term
  • Incorrect. Feedforward is an open-loop estimation element, not part of standard error-feedback PID terms.
You have attempted of activities on this page.