Tuning PID for multiple flight phases, TOW and altitudes on a 16 inch copter

I am struggling with setting up a larger copter (3 kg) with 16 inch props…

I started a similar topic in Ardupiloot configurator, but was not able to progress at all there, so I decided to post a new topic here.

I have got several issues, some which may be related to my particular setup and built, and some may have uncovered underlying ardupilot problems.´

So to cut the story short, after long trial and error, I was able to setup PIDs which made the copter quite flyable with some caveats (I will come back to this point later), but they are almost the double of the PIDs obtained by Autotune.
The problem which seems not to have been solved in arducopter is this: I have made several flights with different weights and at two different altitudes. I analyzed the logs with Ardupilot PID tool, and got the following:

Step response for Pitch at 2450 grams:

Step response for Pitch at 3150 grams:

The first graph is basically a very flyable setup, I need to work out a slight tendency to have minor oscillations.

The second graph can be flown, but is quite unstable. So the PID values which are fine for a certain weight make the copter almost unflyable when the weight is increased by just 27 %.

This is a minor problem, because you can adjust the PIDs on ground based on the expected battery weight.

I continued with looking the step response at different altitudes. I have two sets, one for absolute altitude of 140 meters, and the other for 800 meters, i.e. a delta of ony 650 meters or 8 % of air density change.

Here I got the following:

Pitch Response at 140 meters:

Pitch Response at 800 meters:

Roll Response at 140 meters:

Roll Response at 800 meters:

One can observe that overall, the step response went down by about 10 %, i.e. from 1.15 to 1.05 or something close to that. That is for a change in density of only 8 %. Now, if I flew at 0 meters and 5000 meters, there would be a pressure difference of about 50 %.

And for the time being I do not know how the step response would change, but if the change would be linear to the pressure change, it could easily result in step response being way too low, close to 0.5 (like when increasing the weight from 2450 grams to 3150 grams). That would make the whole thing unflyable.

So my first big question, how can one compensate for altitude? I believe ardupilot compnesated for the battery voltage, but why not altitude? Ardupilot seems not to provide an automatic way to adjust PIDs with altitude change. This basically would preclude flying at different altitudes without modifying manually before each flight, and if in a given flight there is a large altitude difference, then basically this would make the ardupilot unable to control the copter.

I would like to get some input on this point…

Now to the issue of setting it up. Experimentally, by trial and error I obtained PID values which make the copter quite flyable, but far from perfect. However, these values (P,I,D) are about the double what Autotune does. For this flight,
Autotune gave me for instance for pitch:
0.05 0.05 0.005
I set it up as:
0.115 0.115 0.008

The main problem I had is that with Autotune values the copter is stable in hover, and very unstable during descents, and somewhat unstable during forward flying at higer speeds.

I decided to look at the step response for different phases of flight but for a given set of PID values (0.115 0.115 0.008), and discovered the following:

Pitch Step Response for hover:

Pitch Step Response ascending and flying forward at moderate speed:

Pitch Step Response descending 2 m/s and flying forward at moderate speed 30 km/h:

What I deduce is that PID values for hover are a little bit too high (clear overshoot, and small oscillation), but for descent/ascent are a little bit too low (clear undershoot to no more than 0.85).

I am a noob in copters, but I feel that the problem with setting up this copter is due exactly to this very clear difference in behaviour for different flight phases.

I AM REALLY AT COMPLETE LOSS HOW TO SOLVE THIS… ANY HELP WOULD REALLY BE APPRECIATED!!!.

A .bin log file would be handy.
What ESCs do you have? If you havent already do everything you can to use DSHOT and get the ESC telemetry data working.

The fact that Autoune produces very low PIDs says to me there’s a noise and filter issue.

Since we dont have all your existing parameters, make sure you have a working voltage sensor and the correct battery failsafe levels and actions set, then set all these for a staring point:

ATC_ACCEL_P_MAX,71600
ATC_ACCEL_R_MAX,71600
ATC_ACCEL_Y_MAX,21600
ATC_ANG_PIT_P,6
ATC_ANG_RLL_P,6
ATC_ANG_YAW_P,4.5
ATC_INPUT_TC,0.2
ATC_RAT_PIT_D,0.006
ATC_RAT_PIT_FLTD,14
ATC_RAT_PIT_FLTT,14
ATC_RAT_PIT_I,0.12
ATC_RAT_PIT_P,0.12
ATC_RAT_RLL_D,0.006
ATC_RAT_RLL_FLTD,14
ATC_RAT_RLL_FLTT,14
ATC_RAT_RLL_I,0.12
ATC_RAT_RLL_P,0.12
ATC_RAT_YAW_D,0.005
ATC_RAT_YAW_FLTE,2
ATC_RAT_YAW_FLTT,14
ATC_RAT_YAW_I,0.05
ATC_RAT_YAW_P,0.5
ATC_THR_MIX_MAN	0.1
INS_ACCEL_FILTER,10
INS_GYRO_FILTER,28
INS_LOG_BAT_MASK,1
INS_LOG_BAT_OPT,4
LOG_BITMASK,180222
MOT_THST_EXPO,0.67

and do a test flight and send us a link to the .bin log file.

Thanks a lot for your help! I will post immediately all the information I have.

ATC_ACCEL_P_MAX,60000
ATC_ACCEL_R_MAX,60000
ATC_ACCEL_Y_MAX,9500
ATC_ANG_PIT_P, 9
ATC_ANG_RLL_P, 9
ATC_ANG_YAW_P,5
ATC_INPUT_TC,0.15
ATC_RAT_PIT_D,0.008
ATC_RAT_PIT_FLTD,14
ATC_RAT_PIT_FLTT,14
ATC_RAT_PIT_I,0.10
ATC_RAT_PIT_P,0.10
ATC_RAT_RLL_D,0.008
ATC_RAT_RLL_FLTD,14
ATC_RAT_RLL_FLTT,14
ATC_RAT_RLL_I,0.10
ATC_RAT_RLL_P,0.10
ATC_RAT_YAW_D,0.025
ATC_RAT_YAW_FLTE,1
ATC_RAT_YAW_FLTT,14
ATC_RAT_YAW_I,0.11
ATC_RAT_YAW_P,1.1
ATC_THR_MIX_MAN 0.4
INS_ACCEL_FILTER,10
INS_GYRO_FILTER,28
INS_LOG_BAT_MASK,0
INS_LOG_BAT_OPT,0
LOG_BITMASK,2766847
MOT_THST_EXPO,0.71

I have finished the table above, these were my values I had setup before.

I am using SpeedyBee 4 x 1 60 A ESC and F405 controller. The timing is set to “MediumLow”. ´The motors are HP3510-350 kV

The battery is 8000 mah 6S Lipo, the total weight now is 2500 grams.

I can order different FC and ESC, but it would take a while before I get it.

Just for your information, I have lost one very similar copter during the first serious mountain flight, so I do not want to repeat…


About noise and filtering:
The copter I have lost, was quite similar to this one, and it had much higher vibration values (Vibe X,Y) due to too slender arms. However, the Autotune produced much better results. There I used Sunnysky 3508-380 motors wth 13 x 5 prop. But the ESC and Fc were the same.

Notch Filter:

All posted here is as was set up before…

I will do immediately a test flight with the new parameters and post the .bin file (in about an hour)… Again, thanks a lot for the help offered!!!

Upload a .bin log to some fileshare service like dropbox, onedrive or similar, then provide a link to the file here.

Hi again,

I think I got the file and I have uploaded it…

https://www.ecoterrenos.cl/00000017.BIN

You had INS_HNTCH_REF,0 which means basically the notch filter does nothing.
Use these settings:

INS_HNTCH_FREQ,45
INS_HNTCH_BW,20
INS_HNTCH_ATT,40
INS_HNTCH_REF,0.16
INS_HNTCH_FM_RAT,0.70
INS_HNTCH_HMNC,3
INS_HNTCH_OPTS,0

With the harmonic notch filter, quite often less is more and we set just what is required to do the job. These settings will produce this result:

Also set these:

ATC_THR_MIX_MAN,0.5
BATT_FS_CRT_ACT,1
BATT_FS_LOW_ACT,2

Give that a test fly then try Autotune on pitch and roll axis.

You should load the BlueJay firmware on that ESC and change to use bi-directional DSHOT so you have the RPM data, and there’s other reliability reasons to use DSHOT too.
You would also have to load the “bdshot” firmware for your flight controller and make a few minor parameter additions. The harmonic notch filter could also be set to use the motor RPM.

Thanks for the suggestions. I will do that ASAP.

I was thinking about Bluejay, did not want to brick the ESC, now I got 2 extra spare ESCs (all same type from SpeedyBee). One reason I did not want to get the __32 ESCs is because Bl_Heli_32 seems not to be supported anymore.

Do you see any other cause which may produce this behaviour during the descents? I mean, the autotune may do a better job with filter, but still I feel there is a lot of difference in behaviour in hover flight and descent.

I could also mount the FC on foam, which with previous copter reduced the Vibe X,Y values by about 50 %, but I am not sure if it is needed.

The previous copter was set up for altitude of 140 meters, then taken to 2500 meters, and when descending, lost its “footing”, most probably due to insuffucient PIDs…

BLHELI32 still works OK, even though it’s no longer supported or under development. For example there’s no reason to stop using BLH32 ESCs while they keep working and are not faulty.
The way forward is to buy ESCs with AM32 pre-loaded.
Bluejay should work OK on your ESCs and plenty of people around here use it.

The thrust expo can be a contributor to that instability during descent, as can PIDs. Let’s hold off making more changes until we see what Autotune can do with PIDs now that the filter should be working OK.

Your vibrations are not too bad. You might be able to make improvements with prop balance, but it’s not critical.

@Michail_Belov Your test procedure of the ArduPilot Methodic Configurator was flawed. Had you used it and tested correctly you would not have these notch filter issues.

The same applies to

ATC_THR_MIX_MAN,0.5
BATT_FS_CRT_ACT,1
BATT_FS_LOW_ACT,2

Thanks again for the help. I was really thinking that I am in a dead ally… I was going in circles.

As far as the BATT_FS, I am used to flying long range “on edge” (fixed wing), so visual battery monitoring is kind of second nature…

The ATC_THR_MIX_MAN was initally set to 0.4 before and I was planning to increase it…

With notch filter I had my doubts how to set it up, but let us see if the problem is really due to filtering.

Thrust expo:

I have MOT_ARM at 0.09 and SPIN at 0.12 MOT_ARM could probably be lowered to 0.06 even 0.05 (I tried these out before), and from that, SPIN
could be reduced to 0.09. I do not have slightest idea if that is an issue.

I looked in the log and your motor outputs weren’t going near minimums, so MOT_SPIN_MIN was OK before, at least not too high. It’s important to set MOT_SPIN_MIN high enough so props wont stall or get turned backwards by wind or falling through propwash, but not so high the minimum is hit too much during normal flight.
MOT_SPIN_ARM is nice to have as low as possible so you can see the props turning and possibly even confirm spin directions as part of your pre-flight checks. MOT_SPIN_ARM isn’t involved in flight.
Changing MOT_THST_EXPO can mean that you have to retest and reset MOT_SPIN_MIN at least.

Many fall into the trap of “I’m just testing and dont need battery failsafes now” or “I monitor the battery voltage myself” which takes away an important function of the flight controller → saving itself when the unexpected happens (you became busy or distracted, battery went bad, and so on).

1 Like

Hi Shawn, again!

I did Autotune flight, unfortunately, the results are exactly the same as on all previous Autotunde flights… EXCEPT the Error to rate achieved is about half of what previous autotunes were suggesting (Before it was around 14…18, now 4 and 10). Almost zero wind now, less than 7 km/h.

I will make a short test flight now to upload a .bin file, but…

After that I will try to update the ESCs to BlueJay

Autotune flight:
https://www.ecoterrenos.cl/00000017.BIN

Test flight with Autotune PIDs (scary):
https://www.ecoterrenos.cl/00000018.BIN

We do not need. Bin files from the autotune process. We need flights to test the nitch performance and to test the results after the autotune.

Only the second flight is useful

OK. Thanks, ANyway I have uploaded both already.

Just in case (probably not needed at all), the ESC settings I have:

If LOW RPM protection was on, the motors would spin very slowly and never increase RPMs. I have tried flying also with timing “MediumHigh”, I would say that no difference could be observed, neither in behaviour, in motor temperature, or current consumed for hovering.

Correct ESC settings are vital for muticopter proper operation, especially when weight and ambient air pressure change.

Please re-do autotune now that you disabled low rpm protection

Sorry, you did not understand. When protection enabled, the motors turn at a a maximum RPM rate of 120…180 RPM, when trying to accelerate, even using the motor test feature of the MP, the motors do not turn faster.

I had to disable it from the first day.

I have now flashed the ESCs with BlueJay PWM 48 Khz and version 21.0, and I am setting it up for new tests…

I have recalibrated the ESCs (using DShot300 option on calibration menu),
I have set:
SERVO_DSHOT_ESC 2
SERVO_DHOST_RATE 1