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

I have the following ESC settings.

I did Autotune again, the values for pitch increased considerably, for roll stayed the same:

I did another test flight with new Autotune values, as expected, it is unstable in horizontal flight and on verge of loosing control on descent especially in Loiter Mode, but slightly better than the previous Autotune flight.

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

Again, there were moments where Loiter Mode produced “Pilot” induced oscillations (PIO), where FC requests desired roll which changes quickly and out of phase with real roll and which basically “rocks the boat” towards complete loss of control (can easily be seen on the ATT graph towards the end of the flight). I am not sure if there are any parameters for Loiter Mode adjustment, but it could be a good idea to implement them for modification by the user, because in my particular case, Alt Hold is about twice as safe as Loiter.

After that I did again AUTOTUNE, and this time, the roll axis PIDs also increased:

I have not done a test flight with the new parameters, but from the looks of it, it would improve handling, but it would not be better than I have achieved using manual trial and error method…

So I think I can not do anything else, I do not see where the problem could be.

Yes, one can try to change the Notch Filter to RPM probably, but still I have my doubts that it would do any good. I am not sure if ESC PWM could have an impact, going down to 24 KHz maybe, but not sure at all.

When flying straight, one can hear that the motor sound sometimes drops down for an instant considerably, but the copter does not change significantly its attitude. Maybe the inertia of the props is somehow too big, and the copter continues on autorotation, like a helicopter, I do not know. On the other hand, the step response from 0 to 1.0 on previous flights was about 0.1 seconds, which I assume is a good value for this copter size.

The PIDs required for a stable flight seem to be quite different for hover and descent. When descending, I have a current of about 8…10 A, for hover 12 A, when climbing 14…16 A. The copter is always very stable when climbing.

Just one thing, I have ESC brake turned off, not sure if this could have some impact? But usually the brake start working when the PWM is zero, but in this case, the motors never turn off, so no brake would be applied anyway.

So I am here without any further ideas.

I will try two more things: I will use MediumHigh Timing instead of MediumLow, and also fly with 2000 grams instead of 2500 grams. In both cases I will do an Autotune to see if it affects the PID values. I somehow begin to suspect that at low RPM/Low power setting the motor torque is much lower, i.e. it possibly accelerates much slower than at higher RPM.

Had a lot of wind (15…25 km/h), so not sure if it was meaningful. Medium high setting increase current by about 5 %.

Autotune did not save somehow the values…
from .bin file they seem to be:

0.0925 0.006 14
0.0493 0.0071 35

Almost not flyable.

Tried flying at 2000 grams. The wind died and the Autotune gave me this:

Seemed to be rather stable in all flight phases. Will try to log data to get Step Response for the different flight phases.

I did two test flights and in both something happened with logging. For the second short flight I got the log, but the data necessary for Step Response was not there, and when I checked dropped messages, there were 1.5M… But MP opened the file and the attitude seems to be included.

But basically, when flying with 2000 grams, the copter behaved very well in all phases, including descent and including descent in Loiter Mode.

When flying with 2250 grams, the copter behaved similarly, EXCEPT FOR LOITER MODE IN DESCENT, where again there were PIOs brought about by the FC.

My preliminary conclusion is that something prevents correct setting up at higher weights. However, the motors have a lot of extra power, the Hover Throttle is around 0.2, so the copter should easily be flown and set up up to 4 kg.

Any Ideas as what to do?

I decided to restart manual tuning for a slightly lower weight, but I think I will be going in circles…

I was very surprised at the step responses which obtained with autotune PIDs…

Descent at 2250 grams, roll:

Í checked the hover, and climb, the graps llok very similar, i.e. there were no differences between climb and hover, like it was before with 2500 grams

OK. I think I have solved the problem, or at least I arrived at PIDs which work very well…

I have one suspect which was preventing from properly setting up the PIDs - Motor timing. I tried MediumLow, MediumHigh, and finally Medium.

After that the step response became much more stable to different flight phases, altitude, and to a lesser extent, weight, i.e. there were no noticable differences in graphs for the different parameters, like altitude, climb, descent, fly forward or hover. I am not 100% sure it is due to motor timing, but there is a good chance it ws one of the most important factors.

The strange thing for me is that higher timing, MediumHigh, which should provide a much more responsive motor, did not seem to change significantly the overall respnse compared to MediumLow.

During the day I havee manually tuned the copter for 1950 grams and for 2450 grams.

Best PIDs for 1950 grams:

Best PIDs for 2450 grams:

I was trying very hard to down the copter in AltHold mode, jerking the stick like crazy in different flight phases, in climb, descent, hover, flight forward, with climb or descent. Overall feeling was almost perfect.

I still have issues with LOITER/POSHOLD mode. It is much less stable in vertical high rate descent (at 4.2 m/s). When descending with slight forward motion, the stability is much better.

I decided to reduce some values in the hope that they would affect the LOITER behaviour:

PSC_VELZ_P 2.5, was 5.0
PSC_VELXY_P 1 was 2
PSC_VELXY_I 0.5 was 1
PSC_VELXY_D 0.25 was 0.5

Overall, the impression is that it improved LOITER behaviour.
Descent up to 1.5 m/s - stable
Descent 1.5 …2.5 m/s - some slight wobble, but OK
Descent 2.5 …4.3 m/s - more wobble, seems still OK, but worrysome.

Hey, good news!

Usually with Arucopter you have the same P and I rate values, but if it works it works.

Also you should try to settle on one set of PIDs that work for a variety of weights, or the minimum weight really, then just change the ACCEL values down to suit increased weight.

  • new ATC_ACCEL_P_MAX = ATC_ACCEL_P_MAX x (min_TOW / max_TOW)
  • new ATC_ACCEL_R_MAX = ATC_ACCEL_R_MAX x (min_TOW / max_TOW)
  • new ATC_ACCEL_Y_MAX = ATC_ACCEL_Y_MAX x (min_TOW / max_TOW)

or you can just guess a bit, the ATC_ACCEL values are not that sensitive to single digits and decimal places, and can usually be rounded to the nearest thousand or hundred.

I was looking at the graphs, and usually there was a soft overshoot to 1.1 with the line then tending to go down to 0.85, I though that since the I term is the “slow” acting stabilizer, I pushed it up compared to P term, and the line seems to have become better, stabilizing at 0.95. One the other hand, if I tried to pump up both P and I, there was a point where oscillations began to show up.

I will try to play around with ACCEL values, and in fact the PIDs which I obtained for 1950 grams produced step response maybe 10…15 % lower for 2450 grams (like it was reaching 1.05 falling back to 0.95 with 1950 grams, and became 0.95…0.85 with 2450 grams. So most probably that was very flyable. On previous occasions I was getting like 0.5.

Next few days I will run some higher altitude tests (in fact, today I tried flyint at 1000 meters with 1950 grams, and the step response was exactly the same as at altitude of 0 meters.

Roll: Some of the many, I do not remember which…

Pitch:

This one to me is almost perfect Roll response (in my noob understanding):

I have to try high altitude flights, then I will try to push up a little bit PIDs even more till I start get oscillations.

I-term is the slow acting stabiliser, as you say, but I view it as more long term than each and every attitude change. I think of it more as a modifier for some external effect like weight imbalance or wind. (it does actually act with every attitiude change, that’s just my interpretation - I’m OK with being corrected). As such it’s usually kept as the same value as P-term. Arducopter acts slightly differently and is tuned differently to Betaflight for example.

D-term is probably what you want to adjust to keep the P-term in check. Be careful with D though → going a fraction too far can have exponentially bad results. Check motor temperatures, and you can hear a mechanical sound from the motors if D-term is too high and there’s high frequency oscillations.
D-term is typically 1/16th to 1/20th of P-term, but this is only a rough guide, like a starting point if you had to guess, and not a real rule. Yaw is a different bucket of worms but much less critical than pitch and roll.

I have heard the D-term screeching during the setup, and you could see like two or three oscillations on some of the graph which I believe were due to the D-term too high. It seems that increasing I term requires less D-term than increasing P term.

Overall, it seems that I term still makes the response somewhat sharper, so increasing I term seems to change the reponse in the 0,2…0.5 second range, but the wobble during the descents is also rather low frequency, so it could well be that the I term would still be fast enough to help in the overall stabilization.

It is only the descent which is by far the most complicated. It could be that it is due to the very big props (relative to the weight), and prop wash destabilization is therefore much higher. But I am not sure. With 13 props the setup was much easier, they were much more forgiving.

Thanks a lot for the help!!!

I am still having issues.

I have discovered that with the settings I have, I get in some conditions rather high frequency oscillations which probably are due to high D-term. They have amplitude of 1º and 7 Hz, very stable. They seem to occur during high speed descent and slow forward flying at about 30 km/h.

I am not sure if they are dangerous. However, if I try to reduce the PIDs, like when I changed D term from 0.09 to 0,07, and PI from 140 to 120, the overall feeling was that instability during decents became worse.

On this graph you can see that oscillations appear and die at certain speed (and always in descent):

I tried to reduce the MAX ACCEL from 70000 to 40000, that moved the speed at which oscillations tend to occur during descent from around 35…40 to 50…60 km/h.

There seems to be like some resonance frequency. Now, the frame is extremely sturdy, you can not twist arms at all, so I doubt that this comes from the frame rigidity.

PS: Did a Liion battery test flight (6S4P Samsung35E, with capacity decreased by 10 % due to old age), slow flying at about 30…35 km/h gives the best hover time, it stayed in the air for 67 minutes, with some 5 % energy left, so it has a max hover time of 70 minutes and a range of 40 km. when flying slowly. With new batteries that would increase to about 75 minutes… It is not bad, but I expected more. I think that RCTimer motors suck, I will order SunnySky 3508-700 and will try from there once more. I somehow have a feeling that the problems I have are partially related to motors, and their response. It could be that if I use higher RPM smaller props, I will get a more stable response. The higher Kv mogtors are usually slightly less efficient, but my guess is that Sunnysky 700 kV will outperform by far the RCTimer 350 kV motors.

Not sure if I should try setting the
ATC_RAT_RLL_SMAX
ATC_RAT_PIT_SMAX

OK. Did some more tests.

It seems that ATC_RAT_XXX_SMAX does indeed help to reduce oscillations. Just to remind, my main issue was that I was getting 7 Hz oscillations when copter was both descending fast and flying forward slowly. These oscillations were not present at all when climbing or flying level.

However, I had to experiment a lot, I started with a value of 100, and had gradually reduce it to about 2.0 now (going like 100,25,16,12,9,5,4,3…). From 3.5 an effect could be felt. First, there is a parameter, PIDR.dmod which indicated that the SLEW RATE limitation is taking effect, when it takes effect, it goes down from 1.0 to 0 or intermediate values.

I think the documentation in ardupilot of this feature is virtually non-existent and should be redone.

The PIDR.dmod began to go down exactly when I was going down and developping oscillations:

I still get oscillations, they seem to be somewhat reduced in amplitude and seem to appear and disappear (before, they were very constant and regular). The results above were produced with SMAX = 1.95 for both pitch and roll, although I have more problems with Pitch oscillations:

I am not sure whether to leave it as is, or to TRY AND REDUCE FURTHER THE OSCILLATIONS WITH THE RISK OF OVERDAMPENING OVERALL RESPONSE.

As is now, I get the SMAX dampening during only 3 % of the time, but also when I do violent maneuvers, i.e. rocking the stick from side to side.

HIGH I VERSUS P RATIO
Another thing I tested out was very high I to P ratio. I noticed this post:
Analytical Multicopter Flight Controller PID Optimization where manually tuned PIDs had a ratio of 0.2 P 1.0 I

Especially with pitch I had some issues with step response (it was either too low or producing oscillations). So from PI 0.17 0.17 I went to PI 0.16 0.35. The response seems to have become much better:

I expected that such a high I would produce oscillations, but it was not the case.

ANY COMMENTS ON BOTH OF THESE ISSUES WOULD BE GREATLY APPRECIATED!!!

1 Like

Final test I ran was to reduce the MOT_THST_EXPO

I reasoned that my problems occurr at low current/low power settings, and the expo steepens the power response curve at low power settings, basically, in my understanding, increasing PIDs, so by reducing the expo, I would be reducing the PIDs during descent and the concurrent oscillations.

I had MOT_THST_EXPO as 0.67
I tried two values: 0.5 and 0.36
At 0.5 it was pretty obvious that the oscillations were reduced, and handling improved.
At 0.36 I began to experience instability in descent in LOITER mode.

I think that I will leave the value at 0.55

Overall, I think that all my tests, parameter mods point to one thing: there is something very flawed in the copter I have and I try to correct and optimize as best as possible the setup, and it does become better, but still, something is amiss here, and I can not understand exactly what. Still, I have my strong doubts about the motors and their response, but not sure at all.

This is the step response for descent (20 seconds), clear oscillations present, and compare it to previous graph with overall step response (3 minute flight) (both step responses are with the same PIDs, same flight):

OK. Did some test flights at altitudes 2400 … 4000 meters, and also hover test at 2400 m in very gusty wind (gusts 30…40 km/h). The copter behaved seemingly well. Discovered several unexpected (to me) details:

The pitch step response increased with altitude. I expected the contrary to happen. It could be that at higher RPM the motor response is better, but I am not sure.

The current/power needed to fly did not increase overall at altitude, I would say that it could have become slightly more efficient. It is very difficult to judge because there were too many envirnmental factors, like wind, possible updrafts/downdrafts. That goes against what ecalc suggested. However, ecalc also promised an increased efficiency at 0 altitude when going from 13 inch to 16 inch prop (about 15 % better efficiency, which did not happen at all).

Thanks for the updates.

Likely true - I see with very big props that operate at low RPM with little or no payload are always terrible for attitude control. A smaller prop size would be better for all but the maximum payload in a lot of cases.

I will analyze the data and post later some graphs. The response is not that straightforward. I have two flights, both at high altitude, one in windy, gusty conditions, there the response is very clear. the other, in rather calm, not so clear. I will try to seprate the level flight and descent.

The flight in windy condition had a part where I was in Loiter mode in very gusty situation, and that part showed a step response much stronger… I do not understand why, because as I understand it, the step response is not dependent on the extrenal conditions,

This is overall pitch response from a flight in windy condtions, 2400-3900 meters>

Flying at 3600…3800, loiter mode, alt hold mode, flying around:

Hovering in Loiter Mode in extremely gusty conditions at 2400:

Descent from 3900 to 2400 m:

One can clearly observe a slight increase in the overall step response with altitude (you can compare to the previous post, where the step response for 120 meters altitude is given, with exactly the same PIDs).

Extremely surprising to me is increased step response for Loiter Mode in hover.

I have data from another flight at 3000 meters (flying around, hovering, etc), with less turbulent wind. There surprisingly the step response seems to be lower:

If someone wants to take a look:
https://www.ecoterrenos.cl/Flight3900new.bin
https://www.ecoterrenos.cl/Flight3000.bin

Important is the fact that PIDs for pitch have 0.16 0.35 0.007, i.e. I to P ratio is 3:1!

I’m not sure what happened but those logs just end like there was a failure, but I’m sure you would have mentioned that.

Anyway, since you are at high altitude I would highly recommend getting a better flight controller with more IMUs and will support temperature calibration. Doing the IMU temperature calibration would be a great help to this copter.
It wouldnt surprise me if you are chasing these PIDs in circles because of changing IMU temperature. Unlike other flight controllers that start off cool and heat up over time, yours starts warm and cools during flight.

Can you also check the copter is level across the tops of the motors by packing under the landing gear, and in MissionPlanner, Accel Calibration, press “Calibrate Level”. You might want to put the copter outside to cool right down (like it does inflight) before doing that.

Various parameters:
These could be larger numbers if actually required.

ATC_RAT_PIT_SMAX,50
ATC_RAT_RLL_SMAX,50

But usually only required with ESCs that dont respond well, and big props.

Definitely set:
BATT_FS_CRT_ACT,1
and ensure the critical voltage level is correct, then change the sensitivity with BATT_LOW_TIMER

You’ve got DSHOT selected but probably not working, and no ESC data coming back :frowning:
You have BLHELI_S ESCs so load the bluejay firmware on them to gain bidirectional DSHOT functionality.
There’s a few more settings involved that you dont have set:

SERVO_BLH_BDMASK,15
SERVO_DSHOT_ESC,2

Then we can set the notch filter to work from the ESC RPM :slight_smile:

NEXT
My feeling is to leave the step graphs and fast logging and go back to basics first.
Assuming you get the ESC RPM working too, I would set:

ATC_RAT_PIT_D,0.006
ATC_RAT_PIT_I,0.12
ATC_RAT_PIT_P,0.12
ATC_RAT_RLL_D,0.006
ATC_RAT_RLL_I,0.12
ATC_RAT_RLL_P,0.12
INS_LOG_BAT_MASK,1
INS_LOG_BAT_OPT,4
LOG_BITMASK,180222

Fix all that up, then just do an ordinary flight in AltHold and Loiter. Do some ascents, descents and turns.
Let’s see that log.

Thank you for your time!

I will do that shortly…

Just a few comments:
All flights were with very soft landing, not sure why you think that there was a failure.

I will buy different flight controllers but it will take about three weeks until I will get them, probably Matek with H7 processor because I want to dabble with LUA scripts; when I started with copters, I had no idea what is needed. IMU redundancy is defintively a good thing. Computing power, I doubt it, except for the scripts.

The temperature falling is simply due to the altitude, i.e. the FC is quite exposed to air, so at 4000 it is natural to get much colder air and with that cold FC temperature.

As you suggested before, I have already loaded BlueJay 21.0, I had doubts about how to set up the bidirectional data. Also, not sure how to check if RPM data is coming in.

The ATC_Rat_XXX_SMAX: I have tried different values before, at about 2.2… 2.4 they indeed dampen excessive oscillations, lower values (like 1.7) produce instability. A value of 50 does not do anything at all. I am checking the PIDR.dmod, and it begins to change from about 4.0 downward.

I will also redo the IMU calibration, but most likely it will be OK. The level difference between props (prop tip against prop tip) is less than 6 mm.

If I may summarize what changes really improved handling/feel:

  • MOT_THRUST_EXPO 0.55 from 0.67 Reduced considerably oscillations on descent
  • ATC_RAT_XXX_SMAX 2.2 Supresses excessive oscillations on descent, but does not eliminate them, i.e. it surpreses oscillations, the oscillation may reappear, but then will be dampened again. In some cases it seems to reduce more aggresive response (like when you move stick violently from side to side).
  • High I to P ratio: seems to improve step response without causing/aggravating oscillations
  • High PI overall: seems to improve handling especially on descent and especially in LOITER mode, but causes stable 7Hz 1º oscillations which do not progress.

I verified the files, indeed there was an issue with the uploaded files (one was trunkated).

https://www.ecoterrenos.cl/Flight3900new.bin