drone:maint:pid_tuning
Differences
This shows you the differences between two versions of the page.
| drone:maint:pid_tuning [11/19/2026 14:12] – created Jon | drone:maint:pid_tuning [11/19/2026 14:16] (current) – Jon | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== PID & Filter Tuning for Drones ====== | ||
| + | |||
| + | **PID (Proportional, | ||
| + | |||
| + | <note warning> | ||
| + | **Motor & ESC Thermal Warning:** Aggressive PID gains (especially high D-term) combined with insufficient filtering can pass high-frequency mechanical noise directly to your motors. Always perform 15–20 second hover and throttle-blip tests after tuning changes, and check motor temperatures by hand—if motors are too hot to touch comfortably (>60°C / 140°F), lower D-gains or increase filtering immediately. | ||
| + | </ | ||
| + | |||
| + | ===== 1. Anatomy of a PID Controller ===== | ||
| + | |||
| + | A PID loop continuously calculates the **error** (the difference between your desired rotation rate from the sticks and the drone' | ||
| + | |||
| + | ^ Term ^ Full Name ^ Primary Function ^ Too Low Symptoms ^ Too High Symptoms ^ | ||
| + | |||
| + | | **P** | Proportional | Immediate muscle/ | ||
| + | | **I** | Integral | Corrects long-term drift caused by external forces (wind, off-center CG). | Nose dips on punch-outs, wandering attitude in wind, poor hold. | Slow, sluggish bounce-back after flips; stiff, robotic feel. | | ||
| + | | **D** | Derivative | Dampens P-term overshoot and cushions sudden movements. | Bounce-back at the end of flips/ | ||
| + | | **FF** | Feedforward | Boosts initial stick response based on how fast the sticks move (not error). | Slight delay between stick movement and aircraft reaction. | Overshoot at the start of flips; twitchy center-stick behavior. | | ||
| + | |||
| + | <note tip> | ||
| + | **The Spring Analogy:** Think of **P** as the stiffness of a spring pulling the drone toward your stick command, **D** as the shock absorber preventing that spring from bouncing wildly back and forth, and **I** as a steady hand holding the drone level against constant wind or weight imbalance. | ||
| + | </ | ||
| + | |||
| + | ===== 2. Understanding Gyro & D-Term Filtering ===== | ||
| + | |||
| + | Before the PID loop can calculate clean motor outputs, the flight controller must scrub mechanical vibrations (frame resonance, bent props, rough bearings) from the raw gyro signal. | ||
| + | |||
| + | ==== Why Filtering Matters ==== | ||
| + | * **Noise Amplification: | ||
| + | * **The Latency Trade-Off: | ||
| + | |||
| + | ==== Common Filter Types (Betaflight / INAV / ArduPilot) ==== | ||
| + | * **RPM Filtering (Bidirectional DShot):** Reads exact motor RPM telemetry from the ESCs and places dynamic notch filters directly on each motor' | ||
| + | * **Dynamic Notch Filter:** Tracks the loudest remaining noise peaks in real time (such as frame resonance) and notches them out automatically. | ||
| + | * **Gyro Low-Pass Filters (LPF1 / LPF2):** Cuts off all frequencies above a set Hz threshold. Moving sliders to the right raises the cutoff frequency (less filtering, lower latency). | ||
| + | * **D-Term Low-Pass Filters:** Dedicated smoothing specifically for the D-term output, which is far more sensitive to noise than P or I. | ||
| + | |||
| + | <note important> | ||
| + | **Filter Before Tuning:** Always optimize your filters **first** before pushing PID gains upward. A noisy airframe will hide bad filter settings behind hot motors and false oscillations, | ||
| + | </ | ||
| + | |||
| + | ===== 3. Pre-Tuning Mechanical Checklist ===== | ||
| + | |||
| + | Software cannot fix a mechanically compromised aircraft. Verify these hardware items before touching firmware sliders: | ||
| + | |||
| + | * [ ] **Propellers: | ||
| + | * [ ] **Frame & Arm Rigidity:** All frame screws, standoffs, and motor bolts are tight with blue threadlocker applied to metal-on-metal threads. | ||
| + | * [ ] **Flight Controller Mounting:** Soft-mounted gummy grommets are seated evenly without pinched wires touching the gyro chip. | ||
| + | * [ ] **Battery Strap & Wiring:** LiPo battery is strapped tightly with zero wobble, and capacitor/ | ||
| + | |||
| + | ===== 4. Step-by-Step Tuning Workflow ===== | ||
| + | |||
| + | Follow this methodical sequence using **Blackbox logs** (or careful line-of-sight/ | ||
| + | |||
| + | ==== Step 1: Establish a Clean Filter Baseline ==== | ||
| + | - Enable **Bidirectional DShot** and **RPM Filtering** (typically 3 harmonics per motor). | ||
| + | - Set the **Dynamic Notch Filter** count to 1 or 2 (with RPM filtering active, fewer dynamic notches are needed). | ||
| + | - Test hover and perform brief full-throttle punch-outs. Check motor temperatures—motors should feel cool to slightly warm. | ||
| + | - //Optional (Blackbox Tuning):// Inspect the Gyro Scaled vs. Gyro Filtered frequency spectrum. Gradually move the **Gyro** and **D-Term Filter sliders** toward less filtering until noise just begins to appear above 100Hz, then back off 10%–15%. | ||
| + | |||
| + | ==== Step 2: Tune Master Multiplier & P/D Balance ==== | ||
| + | - **Increase Master Multiplier (or P & D together): | ||
| + | - **Watch for Bounce-Back: | ||
| + | * If the drone **bounces back** slightly at the end of a sharp roll stop, **increase D** (or lower P slightly). | ||
| + | * If the drone feels **sluggish** or washes out in hard turns, **increase P** (and raise D proportionally to keep it damped). | ||
| + | - **Check Motor Heat:** After each adjustment, fly aggressively for 20 seconds, land, and touch all four motor bells. | ||
| + | |||
| + | ==== Step 3: Dial In I-Term & Feedforward ==== | ||
| + | - **I-Term:** Perform fast forward flight followed by a sudden throttle cut, or fly in gusty wind. If the nose pitches up or drifts off-axis, increase **I-gain** slightly until the attitude stays locked on rails. | ||
| + | - **Feedforward (FF):** Perform rapid stick snaps. Increase FF for sharper, more immediate stick-to-frame connection. Reduce FF if the quad twitches nervously around center stick or overshoots the start of flips. | ||
| + | |||
| + | ==== Step 4: Propwash Handling Optimization ==== | ||
| + | Propwash oscillations occur when descending through your own turbulent air (e.g., pulling out of a steep dive or sharp hairpin turn). | ||
| + | * **Primary Cause:** Excessive filter delay or an under-damped P/D ratio. | ||
| + | * **Fixes:** | ||
| + | - Ensure **Dynamic Idle** is properly configured so motors maintain sufficient RPM authority at zero throttle. | ||
| + | - Reduce unnecessary filter latency (only if motor temps allow). | ||
| + | - Slightly boost **D-gain** or **P/D ratio** on Pitch and Roll. | ||
| + | |||
| + | ===== 5. Tuning Profiles by Drone Class ===== | ||
| + | |||
| + | Different airframe sizes and mission profiles require vastly different baseline approaches: | ||
| + | |||
| + | ^ Drone Class ^ Prop Size ^ Filter Strategy ^ PID Characteristics ^ | ||
| + | |||
| + | | **5" FPV Freestyle** | 5.0" – 5.1" | RPM filter + minimal low-pass filtering for ultra-low latency. | High P & D for crisp propwash control; moderate-high Feedforward. | | ||
| + | | **Micro / Tiny Whoop** | 31mm – 2.5" | Higher filtering required due to high-RPM vibration and flexible frames. | Very high P & I relative to D; high Feedforward for snappy indoor agility. | | ||
| + | | **7" – 10" Long Range** | 7.0" – 10.0" | Lower low-pass cutoff frequencies (more filtering) to block low-Hz arm flex. | High I-term for wind stability; lower D-term and smoother Feedforward. | | ||
| + | | **Heavy-Lift Cinelifter** | 7" – 13" X8 | Heavy low-pass & notch filtering to tame dual-prop turbulence. | High P & I to handle heavy camera payload inertia; cautious D-gains. | | ||
| + | |||
| + | ===== 6. Quick Troubleshooting Reference ===== | ||
| + | |||
| + | ^ Symptom ^ Likely Cause ^ Recommended Adjustment ^ | ||
| + | |||
| + | | **Rapid high-frequency shudder on throttle** | P-gain too high, or loose frame hardware. | Tighten frame/motor screws; lower **P-gain** by 10%–15%. | | ||
| + | | **Bounce-back after sharp flips/ | ||
| + | | **Hot motors + faint high-pitched trill** | Excessive D-term noise reaching motors. | Lower **D-gain** or move **D-Term Filter slider** toward more filtering. | | ||
| + | | **Shaking when descending into own wash** | Filter latency or insufficient D-term damping. | Enable **RPM filtering**, | ||
| + | | **Nose pitches up/down on throttle punch** | I-term too low, or off-center battery CG. | Center battery weight; increase **I-gain** by 10%–20%. | | ||
| + | |||
| + | < | ||
| + | **Rule of Thumb for Tuning:** Change **one parameter at a time**, keep notes (or use firmware presets/CLI diffs) before making major changes, and always prioritize cool motors and clean mechanical builds over chasing aggressive numbers. | ||
| + | </ | ||
| + | |||
| + | ====== Step-by-Step Blackbox Log Analysis Instructions ====== | ||
| + | |||
| + | Follow these exact instructions to record, export, and analyze Blackbox flight logs using **Betaflight Blackbox Explorer** and **PIDtoolbox**. | ||
| + | |||
| + | ===== Part 1: Exporting Your Flight Log ===== | ||
| + | |||
| + | - **Connect to Betaflight Configurator: | ||
| + | - **Open the Blackbox Tab:** Click **Blackbox** in the left-hand navigation menu. | ||
| + | - **Download the Log:** | ||
| + | * //For Onboard Flash:// Click **Save Flash to File...** and save the '' | ||
| + | * //For SD Card:// Click **Activate Mass Storage Device** (or remove the microSD card and insert it into your PC) and copy the latest '' | ||
| + | - **Clear Storage for Next Flight:** Click **Erase Flash** (or delete old logs from the SD card) so your next test flight starts with empty memory. | ||
| + | |||
| + | <note tip> | ||
| + | **File Naming Habit:** Immediately rename your downloaded log file to include the slider values used during that flight (e.g., '' | ||
| + | </ | ||
| + | |||
| + | ===== Part 2: Inspecting Traces & Spectrums in Blackbox Explorer ===== | ||
| + | |||
| + | Use **Betaflight Blackbox Explorer** to check mechanical health, motor saturation, and raw vs. filtered noise frequencies. | ||
| + | |||
| + | ==== Step 1: Load and Configure the Workspace ==== | ||
| + | - Open **Betaflight Blackbox Explorer** and click **Open Log File** (top right) to load your '' | ||
| + | - If your file contains multiple flights (multiple arm/disarm cycles), use the **Log Selector** dropdown in the top bar to pick the specific test flight. | ||
| + | - Click the **Graph Setup** button (top bar) and load a clean workspace layout containing: | ||
| + | * **Graph 1:** '' | ||
| + | * **Graph 2:** '' | ||
| + | * **Graph 3:** '' | ||
| + | * **Graph 4:** '' | ||
| + | |||
| + | ==== Step 2: Check Noise Frequencies (Spectrum Analyzer) ==== | ||
| + | - Hover your mouse over the **Debug [0]** (Raw Roll Gyro) trace and click the **Spectrum / Analyzer icon** (or press **F** on your keyboard) to open the frequency graph. | ||
| + | - Look at the peak frequencies between **0Hz and 500Hz**: | ||
| + | * **Note any sharp spikes below 100Hz:** These indicate frame resonance or loose screws. | ||
| + | * **Check the high-frequency floor (> | ||
| + | - Now open the Spectrum Analyzer on **Gyro [roll]** (Filtered Roll Gyro) and **PID D [roll]**: | ||
| + | * Verify that the sharp motor noise spikes seen in '' | ||
| + | * Check **PID D [roll]**: The area above **120Hz** should be flat and quiet. If you see large peaks above 120Hz on the D-term spectrum, **increase D-term filtering** (move the D-Term Filter slider left). | ||
| + | |||
| + | ==== Step 3: Check Motor Saturation & Balance ==== | ||
| + | - Scrub through the timeline to a **full-throttle punch-out** and a **sharp flip/ | ||
| + | - Inspect the **Motors [1, 2, 3, 4]** graph: | ||
| + | * **Check for Clipping:** If any motor trace hits the flat ceiling at **100% (2000)** during maneuvers, your motors are saturating. Lower your **Motor Output Limit** slightly or use lower-pitch props. | ||
| + | * **Check Trace Thickness: | ||
| + | |||
| + | <note warning> | ||
| + | **Single-Motor Anomaly Check:** Compare the average percentage of all four motors during a level hover. If one motor consistently runs **10%–15% higher** than the others, inspect that arm for a bent motor shaft, damaged prop, twisted arm, or unbalanced battery placement before changing any PIDs. | ||
| + | </ | ||
| + | |||
| + | ===== Part 3: Analyzing Spectrograms & Step Response in PIDtoolbox ===== | ||
| + | |||
| + | Use **PIDtoolbox (PTB)** to turn your test flight into clear visual heatmaps and step-response curves. | ||
| + | |||
| + | ==== Step 1: Import the Log ==== | ||
| + | - Launch **PIDtoolbox** and click **Select File(s)** to load your '' | ||
| + | - Select the desired sub-log number if multiple flights exist in the file, then click **Load**. | ||
| + | |||
| + | ==== Step 2: Generate & Read the Noise Spectrogram ==== | ||
| + | - Click the **Spectral Analyzer** button on the main dashboard. | ||
| + | - Set the columns to compare side-by-side: | ||
| + | * **Column 1:** '' | ||
| + | * **Column 2:** '' | ||
| + | * **Column 3:** '' | ||
| + | - **How to Interpret the Heatmap:** | ||
| + | * Look at the **D-Term** column above **100Hz**. It should be almost entirely **dark blue/ | ||
| + | * If you see **bright yellow or green streaks** above 100Hz in the D-Term column, your filters are too loose—move your **D-Term Filter Multiplier** slider to the left by **0.1–0.2**. | ||
| + | * If the D-Term column is completely dark blue/black all the way down to 80Hz and your motors came down cold, you have headroom to move your filter sliders to the right by **0.1–0.2** for sharper response. | ||
| + | |||
| + | ==== Step 3: Generate & Read the Step Response Curve ==== | ||
| + | - Close the Spectral Analyzer and click **Step Response** on the PIDtoolbox dashboard. | ||
| + | - Ensure your log contains at least **3–4 sharp roll and pitch stick snaps** (PIDtoolbox automatically isolates high-rate stick movements to calculate the curve). | ||
| + | - Inspect the **Roll**, **Pitch**, and **Yaw** response curves against the dashed **1.0 target line**: | ||
| + | * **Latency Check:** Look at the horizontal time axis (in milliseconds). A well-tuned 5" quad reaches **1.0** within **40ms to 60ms**. If it takes >80ms, increase **Master Multiplier** or **Feedforward**. | ||
| + | * **Bounce-Back Check:** If the curve climbs above **1.0** (e.g., peaks at **1.15**) and dips back down, increase the **P and D Gain (Damping)** slider by **0.05–0.1** (or lower Feedforward slightly). | ||
| + | * **Oscillation Check:** If the curve waves up and down multiple times like a sine wave after hitting 1.0, lower the **Master Multiplier** slider by **0.1**. | ||
| + | |||
| + | <note important> | ||
| + | **Log-Based Tuning Loop:** Make **one** slider adjustment based on your PIDtoolbox graphs, flash the change, fly the exact same 30-second test routine, and compare the new Step Response curve directly against the previous log using PIDtoolbox' | ||
| + | </ | ||
| + | |||
| + | |||
| ====== Step-by-Step Betaflight Slider Tuning Workflow ====== | ====== Step-by-Step Betaflight Slider Tuning Workflow ====== | ||
drone/maint/pid_tuning.1795097549.txt.gz · Last modified: by Jon
