Post

Filters and PID tuing in Betaflight

Filters and PID tuing in Betaflight

How I tune filters and PIDs in Betaflight using PIDtoolbox pro (a musthave)

radio

  • ADC Filter OFF
  • global functions -> GF1 ON Lua Script bfbkgd for time sync from radio’s RTC to the betaflight flight controller

quad

  • must have a capacitor
  • must have new props installed, all screws tightened, no dangling antennas or XT60

ESC

  • ESC tuning
  • https://esc-configurator.com or https://am32.ca, or locally
  • for 2,5-inch and smaller set PWM frequency to 48 kHz, for larger quads set it to 24 kHz
  • set type to 2S+ if it is not 1S FC, disable temperature protection
  • motor settings in am32 must be set close to the actual ones. manual protocol selection DSHOT

Betaflight preparation

  • backup previous config (dump and diff all showdefaults), flash the latest version of Betaflight using online app or locally
  • load ELRS profile, racing preset
  • load defaults: tune + filters profile, if available for the current BF version
  • enable bidirectional dshot, set correct dynamic idle value is based on the prop size/pitch, here and here
  • the two pidsum_limit can be used to set PID authority to 100% from 50% default (do not change this after PID tuning).
    1
    2
    
    set pidsum_limit = 1000
    set pidsum_limit_yaw = 1000
    
  • if MCU has enough compute power, set ESCs to DSHOT600, set pid_process_denom = 1 and disable gyro low pass 2
  • motor_poles must be set correctly (usually 12 for small motors and 14 for large motors)
  • set blackbox to 2 kHz

Filters

  • https://www.youtube.com/watch?v=E3s5XYk3M74
  • UAVTech’s workspace for blackbox viewer is here
  • adjust
    1
    2
    3
    
    set rpm_filter_weights = 100,20,20
    set rpm_filter_fade_range_hz = 0
    set rpm_filter_q = 500
    

PID

  • https://www.youtube.com/watch?v=sqT4MACi3d8
  • https://www.youtube.com/watch?v=ehvQm8Rqrzk
  • set angle to 100
  • the process
    • on the default PIDs, record hover
    • use blackbox explorer and PIDtoolbox to adjust the filters
    • set ff and dmax to zero, iterm gain to 0.2
    • in angle mode, record wiggle with dterm gain 0.6-1.8 step 0.2, set the best curve without overshoot (to have a headroom for mm)
    • in angle mode, record wiggle with master multiplier 0.6-1.8 step 0.2, choose loweset latency, compare roll and pitch latency and adjust roll:pitch balance
    • in acro mode, record iterm gain 0.5-2 step 0.5, choose the lowest latency between setpoint and gyro
  • if there is a slow bounceback after a roll or a flip, lower I term gain
  • iterm https://www.youtube.com/watch?v=Sq_DFjmvVDE

after tuning

  • turn on anti-gravity, voltage sag compensation (depends on vbat_warning_cell_voltage), thrust linearization
  • set motor_output_limit = 90 for a 5-inch

problems

references

  • https://oscarliang.com/fpv-drone-tuning/
  • https://oscarliang.com/pid/
  • https://www.youtube.com/playlist?list=PLFPBjpbd5xKQAzyblBStGKYtNdP9FCpRe
This post is licensed under CC BY 4.0 by the author.