PID Simulator

📖 Overview

Interactive PID controller simulator created by Joshua Bardwell to simulate a single drone axis and build an intuitive feel for how each gain and physics parameter affects flight dynamics and Blackbox traces.

🛠️ How to Use (Tuning Approach)

  1. Zero Out Gains: Turn P, I, D, and FF to 0 to observe an uncontrolled system.
  2. Find P Limit: Raise P until the follower responds to setpoint moves. Note how P-only causes overshoot and undamped ringing.
  3. Add D to Damp: Raise D to act as a brake, damping overshoot and locking in the line.
  4. Set I for Bias: Add CG (disturbance) to simulate wind or an off-center battery. Raise I to correct steady-state drift.
  5. Snappiness with FF: Raise Feedforward to eliminate latency during fast stick inputs.

📊 Understanding the Scope (Blackbox Log)

  • Setpoint (Red): Target stick position.
  • Follower (Blue): Simulated gyro rotation of the quad.
  • Error (Yellow): Gap between Setpoint and Follower.
  • Step Response Metrics:
    • Rise Time: Time taken to climb from 10% to 90% of setpoint.
    • Overshoot: Bounce percentage past the setpoint.
    • Settle Time: Time required for oscillations to lock within 2%.

⚙️ Physics & Environmental Parameters

  • Mass: Weight of craft. Higher mass slows response and demands higher P/D gains.
  • Drag: Air resistance acting as natural damping.
  • Delay: Loop and ESC latency. Higher delay severely destabilizes the loop!
  • Noise: Gyro vibration amplified by high D-term gains, generating motor heat.

💡 Key Insights: Core Concepts (P, I, D, & FF)

  • P (Proportional): Reacts to the present. Drives the follower toward the setpoint. Excess P causes ringing, overshoot, and rapid oscillations.
  • I (Integral): Reacts to the past. Corrects persistent offsets (like unbalanced CG or side winds) by accumulating force over time.
  • D (Derivative): Reacts to the future. Dampens acceleration and decelerates the follower as it approaches the setpoint. Excess D amplifies high-frequency noise, heating up motors.
  • FF (Feedforward): Reacts to stick velocity. Instantly adds force during stick movement to eliminate gyro latency, dropping to zero when stick stops.