Detecting Cleanflight PID tuning issues with Blackbox: excess P gain

Almost all quadcopter PID tuning tutorials can be summarized into one sentence: “Increase P until you see oscillations, then lower it”. Plus some thoughts about I and very vague advices about D and that is all. When I got into the hobby, I’ve read all of those tutorials. And I did know more about PID tuning than before that. I even had more questions than before. How to recognize high frequency oscillations, how to recognize low frequency oscillations. Lower P? OK, but how much? And D? How to tune this bloody D? As a result, every time I tried, I ended up with very snappy but shaky quadcopter that maybe responded very quickly to commands, but was very shaky and was making strange noises.

And then came Cleanflight and Blackbox. Live became simpler. What I’ve learned from Blackbox logs is that I wanted high P so much, I had too much of it in the end. Actual oscillations begins before we see or hear them and excess D introduces jello. Blackbox simplified things, but still, logs analysis is something like an art. You have to know what to look for.

Like I wrote above, the most common mistake in PID tuning is excess P gain that leads to oscillations. Those oscillations might not by visible or audible, but gyro will detect them and they will influence control loop, increase power usage, might introduce jello and worsen flight characteristics. So, what to look for?

First, open a log that has everything: low throttle section, hover, hight throttle section, turns, maybe roll or flip. Analyze each axis separately. I like to begin with roll, then go to pitch and finally to yaw. The most useful graph layout is the one where upper section show axis gyro and RC command, and lower one P, I and D for this axis.

blackox, hover, no roll oscillations

Scroll to low throttle section without RC input. If it looks similar to image above, your P is fine for hover. There is some noise in gyro, P and D but it is not moving very much. No high amplitude changes, looks like quad is in a state of balance. It hovers.

But, if it looks like this

excess P gain and roll osciallation on blackbox log

P gain for this axis is most probably too high. There is constant movement on gyro, but RC input is at 0. P jumps up and down, as well as D. At this point you can stop analysis, lower P, and perhaps D, record new log and check what is happening there. If there are no oscillations, you can move further. If oscillations persists, lower P again and record new log.

When there are no oscillations on no RC input and low throttle, next step would be to check what is happening when RC input is applied.

Roll, no roll osciallations, blackbox PID analysis

Look at image above. Roll input is applied, P (and D) does their work and gyro readout follows input. At one point P and D goes negative to slow down roll speed but this is normal. Also gyro readout has some noise, but this is also normal, nothing to worry about. P gain looks fine. Maybe not perfect, but multirotor would be fully flyable. If gyro would not follow input, follow with a big delay or multirotor would be changing attitude into different direction than input, that would mean that P is too low or there is something else very very wrong. But it this case you would not be able to fly.

PID oscillations on RC Input

On image above is an example of oscillations on RC input. Gyro readout is following input, but roll rate is accelerating and slowing down. At one point, it even starts to roll in opposite direction due to overshoot. Once again, P gain is too high. Situation when you do not have oscillations on hover and oscillations on delicate RC input are rare. Usually they appear only on hard stick movement or stick release. And in this case it is about finding balance between both states.

The last step for P tuning for axis would be to check how it looks like on high throttle. By high I mean like 100%. If oscillations would appear there, you have two choices.

  • lower P some more, but that might be not enough and might induce instability on hover,
  • apply TPA (Throttle PID Attenuation) to suppress this state.

Unfortunately, I do not have any log examples that covers this state. Maybe next time. Either way, that is not very different than low throttle analysis. Find a point when oscillations appears, set this value as TPA start point and try to find good attenuation value that suppresses high throttle oscillations.

Here is an example of all three axises readouts:

Roll axis oscillations

Do you see the difference between roll, pitch and yaw? I surely hope so. Roll goes crazy while pitch and yaw are quite steady even when there is pitch RC input.

high_P_oscillations_2

high_P_oscillations_1

This procedure might be time consuming and requires few test flights, but is much better and faster than blind tuning only by feeling. There is hard data you can look at and compare with previous tests. I’m not pretending I’m Blackbox expert. I’m far far away from that. But it’s not magic and everyone can learn it, look for patterns and conclude.

6 thoughts on “Detecting Cleanflight PID tuning issues with Blackbox: excess P gain

    1. Hi,

      I took a look at your log and the way I see it:
      * you have a lot of noise on gyros. Maybe it’s not super huge, but visible. Balance props, check bearings and motors. Specially noise of pitch is visible
      * You fly HORIZON or ANGLE, that makes everything hard to detect.
      * Yes, D term is behaving super ugly in your case. Probably because of noise and vibrations.
      * Try lowering D, I would say by half and lower LPF on gyro and D: set gyro_soft_lpf_hz=50 and set dterm_lpf_hz = 30. You might also try lowering D-gain to 0 for starters and record another log, this time in ACRO mode, not ANGLE or HORIZON.

      But gyro noise problem is something you you should address in first place I’m affraid

      *

      1. Hi, thanks for your help now it’s much better. I cut some D and a bit I… What do you think about that log(if you have time) – https://goo.gl/lCo21z

        It is hoovering nicely, but shaking on descend and forward flight.
        Tomorrow I’ll do some more tests.

        I really love the inav, poshold and rth with landing are working so good

        1. Yeap, this looks better, but still a lot noise in gyros, but at least D-term is not inducing extra noise to motors.

          Shaking on descend is hard to fight, specially is you can not have high D-gain and so much gyro noise. Only slower descend makes sense here.

          I’ve also noticed, that you operate stick in very nervous way: fast deflections to maximum positions. This might be also the reason of shaking. Try slower sticks movements, gentle.

  1. these are the settings in my jjrc jjpro p175, can anyone correct them with stock settings, at least it flew very decent then, now with these settings, it flys really crapy, and also my batterys 3s and 4s last only like 4-5 minites. any way here are existing settings, like I asked if any one has the stock plus improvied settings for jjpro p175 Thx

    name –
    resource BEEPER 1 A12
    resource MOTOR 1 A08
    resource MOTOR 2 A11
    resource MOTOR 3 B06
    resource MOTOR 4 B07
    resource MOTOR 5 B08
    resource MOTOR 6 B09
    resource MOTOR 7 NONE
    resource MOTOR 8 NONE
    resource MOTOR 9 NONE
    resource MOTOR 10 NONE
    resource MOTOR 11 NONE
    resource MOTOR 12 NONE
    resource SERVO 1 NONE
    resource SERVO 2 NONE
    resource SERVO 3 NONE
    resource SERVO 4 NONE
    resource SERVO 5 NONE
    resource SERVO 6 NONE
    resource SERVO 7 NONE
    resource SERVO 8 NONE
    resource PPM 1 A00
    resource PWM 1 A00
    resource PWM 2 A01
    resource PWM 3 A02
    resource PWM 4 A03
    resource PWM 5 A06
    resource PWM 6 A07
    resource PWM 7 B00
    resource PWM 8 B01
    resource LED_STRIP 1 A06
    resource SERIAL_TX 1 NONE
    resource SERIAL_TX 2 NONE
    resource SERIAL_TX 3 NONE
    resource SERIAL_TX 4 NONE
    resource SERIAL_TX 5 NONE
    resource SERIAL_TX 6 NONE
    resource SERIAL_TX 7 NONE
    resource SERIAL_TX 8 NONE
    resource SERIAL_TX 9 NONE
    resource SERIAL_TX 10 NONE
    resource SERIAL_TX 11 A07
    resource SERIAL_TX 12 B01
    resource SERIAL_RX 1 NONE
    resource SERIAL_RX 2 NONE
    resource SERIAL_RX 3 NONE
    resource SERIAL_RX 4 NONE
    resource SERIAL_RX 5 NONE
    resource SERIAL_RX 6 NONE
    resource SERIAL_RX 7 NONE
    resource SERIAL_RX 8 NONE
    resource SERIAL_RX 9 NONE
    resource SERIAL_RX 10 NONE
    resource SERIAL_RX 11 A06
    resource SERIAL_RX 12 B00
    mixer QUADX

    mmix reset

    servo 0 1000 2000 1500 90 90 100 -1
    servo 1 1000 2000 1500 90 90 100 -1
    servo 2 1000 2000 1500 90 90 100 -1
    servo 3 1000 2000 1500 90 90 100 -1
    servo 4 1000 2000 1500 90 90 100 -1
    servo 5 1000 2000 1500 90 90 100 -1
    servo 6 1000 2000 1500 90 90 100 -1
    servo 7 1000 2000 1500 90 90 100 -1
    smix reset

    feature -RX_PPM
    feature -VBAT
    feature -INFLIGHT_ACC_CAL
    feature -RX_SERIAL
    feature -MOTOR_STOP
    feature -SERVO_TILT
    feature -SOFTSERIAL
    feature -GPS
    feature -FAILSAFE
    feature -SONAR
    feature -TELEMETRY
    feature -CURRENT_METER
    feature -3D
    feature -RX_PARALLEL_PWM
    feature -RX_MSP
    feature -RSSI_ADC
    feature -LED_STRIP
    feature -DISPLAY
    feature -OSD
    feature -BLACKBOX
    feature -CHANNEL_FORWARDING
    feature -TRANSPONDER
    feature -AIRMODE
    feature -SDCARD
    feature -VTX
    feature -RX_SPI
    feature -SOFTSPI
    feature -ESC_SENSOR
    feature -FEATURE_ANTI_GRAVITY
    feature RX_PPM
    feature VBAT
    feature MOTOR_STOP
    feature FAILSAFE
    feature LED_STRIP
    beeper GYRO_CALIBRATED
    beeper RX_LOST
    beeper RX_LOST_LANDING
    beeper DISARMING
    beeper ARMING
    beeper ARMING_GPS_FIX
    beeper BAT_CRIT_LOW
    beeper BAT_LOW
    beeper GPS_STATUS
    beeper RX_SET
    beeper ACC_CALIBRATION
    beeper ACC_CALIBRATION_FAIL
    beeper READY_BEEP
    beeper MULTI_BEEPS
    beeper DISARM_REPEAT
    beeper ARMED
    beeper SYSTEM_INIT
    beeper ON_USB
    map AETR1234
    serial 0 1 115200 57600 0 115200
    serial 1 0 115200 57600 0 115200
    led 0 0,15::AI:0
    led 1 7,15::FTW:0
    led 2 15,15::AI:0
    led 3 0,0::C:0
    led 4 0,0::C:0
    led 5 0,0::C:0
    led 6 0,0::C:0
    led 7 0,0::C:0
    led 8 0,0::C:0
    led 9 0,0::C:0
    led 10 0,0::C:0
    led 11 0,0::C:0
    led 12 0,0::C:0
    led 13 0,0::C:0
    led 14 0,0::C:0
    led 15 0,0::C:0
    led 16 0,0::C:0
    led 17 0,0::C:0
    led 18 0,0::C:0
    led 19 0,0::C:0
    led 20 0,0::C:0
    led 21 0,0::C:0
    led 22 0,0::C:0
    led 23 0,0::C:0
    led 24 0,0::C:0
    led 25 0,0::C:0
    led 26 0,0::C:0
    led 27 0,0::C:0
    led 28 0,0::C:0
    led 29 0,0::C:0
    led 30 0,0::C:0
    led 31 0,0::C:0
    color 0 0,0,0
    color 1 0,255,255
    color 2 0,0,255
    color 3 30,0,255
    color 4 60,0,255
    color 5 90,0,255
    color 6 120,0,255
    color 7 150,0,255
    color 8 180,0,255
    color 9 210,0,255
    color 10 240,0,255
    color 11 270,0,255
    color 12 300,0,255
    color 13 330,0,255
    color 14 0,0,0
    color 15 0,0,0
    mode_color 0 0 1
    mode_color 0 1 11
    mode_color 0 2 2
    mode_color 0 3 13
    mode_color 0 4 10
    mode_color 0 5 3
    mode_color 1 0 5
    mode_color 1 1 11
    mode_color 1 2 3
    mode_color 1 3 13
    mode_color 1 4 10
    mode_color 1 5 3
    mode_color 2 0 10
    mode_color 2 1 11
    mode_color 2 2 4
    mode_color 2 3 13
    mode_color 2 4 10
    mode_color 2 5 3
    mode_color 3 0 8
    mode_color 3 1 11
    mode_color 3 2 4
    mode_color 3 3 13
    mode_color 3 4 10
    mode_color 3 5 3
    mode_color 4 0 7
    mode_color 4 1 11
    mode_color 4 2 3
    mode_color 4 3 13
    mode_color 4 4 10
    mode_color 4 5 3
    mode_color 5 0 9
    mode_color 5 1 11
    mode_color 5 2 2
    mode_color 5 3 13
    mode_color 5 4 10
    mode_color 5 5 3
    mode_color 6 0 6
    mode_color 6 1 10
    mode_color 6 2 1
    mode_color 6 3 0
    mode_color 6 4 0
    mode_color 6 5 2
    mode_color 6 6 3
    mode_color 6 7 6
    mode_color 6 8 0
    mode_color 6 9 0
    mode_color 6 10 0
    mode_color 7 0 3
    aux 0 28 0 1700 2100
    aux 1 1 0 900 1200
    aux 2 2 0 1400 1800
    aux 3 13 1 1200 1625
    aux 4 15 1 1650 2100
    aux 5 0 0 900 900
    aux 6 0 0 900 900
    aux 7 0 0 900 900
    aux 8 0 0 900 900
    aux 9 0 0 900 900
    aux 10 0 0 900 900
    aux 11 0 0 900 900
    aux 12 0 0 900 900
    aux 13 0 0 900 900
    aux 14 0 0 900 900
    aux 15 0 0 900 900
    aux 16 0 0 900 900
    aux 17 0 0 900 900
    aux 18 0 0 900 900
    aux 19 0 0 900 900
    adjrange 0 0 0 900 900 0 0
    adjrange 1 0 0 900 900 0 0
    adjrange 2 0 0 900 900 0 0
    adjrange 3 0 0 900 900 0 0
    adjrange 4 0 0 900 900 0 0
    adjrange 5 0 0 900 900 0 0
    adjrange 6 0 0 900 900 0 0
    adjrange 7 0 0 900 900 0 0
    adjrange 8 0 0 900 900 0 0
    adjrange 9 0 0 900 900 0 0
    adjrange 10 0 0 900 900 0 0
    adjrange 11 0 0 900 900 0 0
    adjrange 12 0 0 900 900 0 0
    adjrange 13 0 0 900 900 0 0
    adjrange 14 0 0 900 900 0 0
    rxrange 0 1000 2000
    rxrange 1 1000 2000
    rxrange 2 1000 2000
    rxrange 3 1000 2000
    rxfail 0 a
    rxfail 1 a
    rxfail 2 a
    rxfail 3 a
    rxfail 4 h
    rxfail 5 h
    rxfail 6 h
    rxfail 7 h
    rxfail 8 h
    rxfail 9 h
    rxfail 10 h
    rxfail 11 h
    rxfail 12 h
    rxfail 13 h
    rxfail 14 h
    rxfail 15 h
    rxfail 16 h
    rxfail 17 h
    set task_statistics = ON
    set mid_rc = 1500
    set min_check = 1100
    set max_check = 1900
    set rssi_channel = 0
    set rssi_scale = 30
    set rc_interp = AUTO
    set rc_interp_ch = RP
    set rc_interp_int = 19
    set rssi_invert = OFF
    set input_filtering_mode = OFF
    set fpv_mix_degrees = 0
    set max_aux_channels = 6
    set debug_mode = NONE
    set min_throttle = 1150
    set max_throttle = 1850
    set min_command = 1000
    set 3d_deadband_low = 1406
    set 3d_deadband_high = 1514
    set 3d_neutral = 1460
    set 3d_deadband_throttle = 50
    set use_unsynced_pwm = ON
    set motor_pwm_protocol = ONESHOT125
    set motor_pwm_rate = 480
    set disarm_kill_switch = ON
    set gyro_cal_on_first_arm = OFF
    set auto_disarm_delay = 5
    set small_angle = 25
    set fixedwing_althold_dir = 1
    set reboot_character = 82
    set serial_update_rate_hz = 100
    set beeper_inversion = ON
    set beeper_od = OFF
    set serialrx_provider = SPEK1024
    set sbus_inversion = ON
    set spektrum_sat_bind = 0
    set spektrum_sat_bind_autorst = 1
    set tlm_switch = OFF
    set tlm_inversion = ON
    set sport_halfduplex = ON
    set frsky_default_lat = 0.000
    set frsky_default_long = 0.000
    set frsky_gps_format = 0
    set frsky_unit = IMPERIAL
    set frsky_vfas_precision = 0
    set frsky_vfas_cell_voltage = OFF
    set hott_alarm_int = 5
    set pid_in_tlm = OFF
    set bat_capacity = 0
    set vbat_scale = 110
    set vbat_max_cell_voltage = 43
    set vbat_min_cell_voltage = 33
    set vbat_warning_cell_voltage = 35
    set vbat_hysteresis = 1
    set ibat_scale = 400
    set ibat_offset = 0
    set mwii_ibat_output = OFF
    set current_meter_type = ADC
    set battery_meter_type = ADC
    set bat_detect_thresh = 55
    set use_vbat_alerts = ON
    set use_cbat_alerts = OFF
    set cbat_alert_percent = 10
    set align_gyro = DEFAULT
    set align_acc = DEFAULT
    set align_mag = DEFAULT
    set align_board_roll = 10
    set align_board_pitch = 0
    set align_board_yaw = 270
    set gyro_lpf = OFF
    set gyro_sync_denom = 16
    set gyro_isr_update = OFF
    set gyro_use_32khz = OFF
    set gyro_lowpass_type = PT1
    set gyro_lowpass = 90
    set gyro_notch1_hz = 400
    set gyro_notch1_cut = 300
    set gyro_notch2_hz = 200
    set gyro_notch2_cut = 100
    set moron_threshold = 48
    set imu_dcm_kp = 2500
    set imu_dcm_ki = 0
    set alt_hold_deadband = 40
    set alt_hold_fast_change = ON
    set deadband = 0
    set yaw_deadband = 0
    set thr_corr_value = 0
    set thr_corr_angle = 800
    set yaw_control_direction = 1
    set yaw_motor_direction = 1
    set servo_center_pulse = 1500
    set tri_unarmed_servo = ON
    set servo_lowpass_hz = 400
    set servo_lowpass = OFF
    set servo_pwm_rate = 50
    set gimbal_mode = NORMAL
    set channel_forwarding_start = 4
    set airmode_start_throttle = 1350
    set failsafe_delay = 10
    set failsafe_off_delay = 10
    set failsafe_throttle = 1000
    set failsafe_kill_switch = OFF
    set failsafe_throttle_low_delay = 100
    set failsafe_procedure = DROP
    set rx_min_usec = 885
    set rx_max_usec = 2115
    set acc_hardware = AUTO
    set acc_lpf_hz = 10
    set accxy_deadband = 40
    set accz_deadband = 40
    set acc_unarmedcal = ON
    set acc_trim_pitch = 0
    set acc_trim_roll = 0
    set baro_tab_size = 21
    set baro_noise_lpf = 0.600
    set baro_cf_vel = 0.985
    set baro_cf_alt = 0.965
    set baro_hardware = NONE
    set pid_process_denom = 1
    set blackbox_rate_num = 1
    set blackbox_rate_denom = 1
    set blackbox_device = SERIAL
    set blackbox_on_motor_test = OFF
    set ledstrip_visual_beeper = OFF
    profile 0

    set pidsum_limit = 0.500
    set pidsum_limit_yaw = 0.500
    set d_lowpass_type = BIQUAD
    set d_lowpass = 100
    set d_notch_hz = 260
    set d_notch_cut = 160
    set vbat_pid_gain = ON
    set pid_at_min_throttle = ON
    set anti_gravity_thresh = 350
    set anti_gravity_gain = 3.000
    set setpoint_relax_ratio = 100
    set d_setpoint_weight = 60
    set yaw_accel_limit = 10.000
    set accel_limit = 0.000
    set iterm_windup = 50
    set yaw_lowpass = 0
    set p_pitch = 40
    set i_pitch = 40
    set d_pitch = 23
    set p_roll = 40
    set i_roll = 40
    set d_roll = 23
    set p_yaw = 85
    set i_yaw = 40
    set d_yaw = 20
    set p_alt = 50
    set i_alt = 0
    set d_alt = 0
    set p_level = 20
    set i_level = 20
    set d_level = 100
    set p_vel = 55
    set i_vel = 55
    set d_vel = 75
    set level_sensitivity = 55
    set level_limit = 55
    rateprofile 0
    rateprofile 0

    set rc_rate = 100
    set rc_rate_yaw = 100
    set rc_expo = 0
    set rc_yaw_expo = 0
    set thr_mid = 50
    set thr_expo = 0
    set roll_srate = 50
    set pitch_srate = 50
    set yaw_srate = 0
    set tpa_rate = 0
    set tpa_breakpoint = 1500

Leave a Reply

Your email address will not be published.