System Controls
0°
0.70
0.00
0.0
25
PID Gains
0.0
0.00
0.0
Live Simulation & Response
PID Theory & Tuning Guide
The PID controller's goal is to keep the pendulum balanced by applying a corrective **torque** at the pivot. It calculates an error value (the difference between the target angle and the actual angle) and applies a correction based on P, I, and D terms.
- Proportional (P): Applies a torque proportional to the current angular error. A higher P gain creates a stronger torque to correct the angle. Too high, and it will overshoot and oscillate. Too low, and it won't be strong enough to overcome gravity.
- Integral (I): Accumulates past errors. This term helps correct for any systematic drift or steady-state error, ensuring the pendulum returns precisely to the target angle over time. Too much 'I' can cause overshoot.
- Derivative (D): Applies a torque based on the rate of change of the error. This is the "anticipation" or "damping" term. It counteracts fast movements, preventing overshoot and stabilizing the system. **However, the D term is very sensitive to measurement noise, which can cause the output to become erratic.**
Tuning Strategy for an Inverted Pendulum:
- Start with P and D: Unlike simpler systems, an inverted pendulum often needs a D term to be stable at all. Set I to zero.
- Tune P: Increase P until the system actively tries to balance the pendulum, even if it's shaky.
- Tune D: Increase D to dampen the oscillations. You're looking for a smooth, controlled response where the pendulum settles without overshooting.
- Tune I: Once the pendulum is stable, you can add a small amount of I to correct for any long-term drift away from the perfect vertical setpoint.
Real-World Challenges:
Real systems are never perfect. They have imperfections like:
- Sensor Noise: Use the "System Noise" slider to simulate imperfect measurements. Notice how a high D gain can amplify this noise and make the system jittery.
- Motor Deadband: Real motors require a minimum amount of torque to start moving. If the controller's output torque is below the "Motor Deadband" threshold, it will have no effect. The Integral (I) term is crucial for overcoming this.
- Actuator Saturation (Max Torque): Motors have a physical limit. If the PID controller commands more torque than the motor can deliver, the output is "saturated." When this happens with a large error, the Integral term can grow to a huge value (Integral Windup), causing a massive overshoot when the error is finally reduced.