Oscillate and flip over after switching FC

Increase these to about 6.5 and see if the oscillations settle down in ALTHOLD, if it looks OK try POSHOLD again. Normally I’d use LOITER instead of POSHOLD.
ATC_ANG_PIT_P
ATC_ANG_RLL_P

The shows voltage is dropping as you climb, but especially when the oscillations start.
Either ESC2 has a big problem (voltage hardly changes) or it’s the only one actually operating correctly. I suspect it or the motor or their connections are bad.

Check all ESCs have Low RPM Power Protect turned off, and you might want to also disable their low voltage protection too and let the flight controller look after that. Not that nearly all ESCs show quite different voltages - that could just be a calibration issue, but dont rely on their voltage readings until you’ve verified if they are right or wrong.

ATC_THR_MIX_MAN,0.1 this is quite low, set to 0.5

You should set these and you might start to see battery failsafe messages since the voltage seems to sag under load somewhat.
BATT_FS_CRT_ACT,1
BATT_FS_LOW_ACT,2

Thanks for your input, Shawn. Which log are you looking at there? Here is the ESC voltage readings from the Pos Hold flight:

And here it is from the Alt Hold test:

I’ll change ATC_ANG_PIT_P and ATC_ANG_RLL_P and give it a try. I am not sure I understand how the battery failsafe settings factor into this, can you please clarify? Also, why Loiter over Pos Hold? Does that change stuff when it comes to tuning? I intend for this copter to ultimately fly in Auto.

Did a quick Alt Hold test today after changing the following:

ATC_THR_MIX_MAN,0.5
ATC_ANG_PIT_P,6.5
ATC_ANG_RLL_P,6.5

I couldn’t see any oscillations but I don’t believe I have a trained eye for this anyway. Here are the Roll and Pitch data:


Are those squiggles in the orange trace signs of oscillations? What should the differential be between the blue and orange trace? Less than 0.1 deg? 0.01 deg? I find this all a bit discomfiting because I am not sure what the expected or optimal behavior is.

Log file.

I’ve been doing several short hover tests for manual tuning of the PIDs. There seems to be some improvement in the desired and actual behavior but Loiter is still unstable and showing the same critically oscillatory behavior. See:

I could immediately see it go through amplifying oscillations when I switched into Loiter. Any insight on why this is happening? I haven’t done an Autotune yet.

1.Given this is essentially a rate controller am I supposed to tune/match desired rate to actual rate or desired attitude to actual attitude? So far, I have been doing the latter.
2. Is this safe to proceed to Autotune? I haven’t done these tests yet either.

Log file.

When Loiter starts oscillating and going crazy it’s usually because the position information AND general attitude control is poor. Loiter is trying to hold a position that is constantly shifting, and attitude control is inducing oscillations.

I would set
ATC_RAT_PIT_D,0.0075
ATC_RAT_RLL_D,0.0075
AUTOTUNE_AGGR,0.1
GPS_GNSS_MODE,3
INS_HNTCH_FREQ,50
INS_HNTCH_BW,25
INS_LOG_BAT_MASK,7
INS_LOG_BAT_OPT,0
BAT_FS_ values
FENCE_ENABLE,1 (check your map from in that log)

Do a test flight, see if everything is OK with that, then run your Autotune on pitch and roll.
Just check motor temperatures before flying too much since I’m asking you to raise the Rate D terms bit.

I think you’ll find once Autotune comes up with a good result (and HNOTCH and GPS are all cooperating) that Loiter will be fine.

Thanks. I tried upping the D-term iteratively in steps of 10% but I noticed it was starting to very slightly oscillate at 0.005. That’s when I backed off to 0.0045. Motors were warm not hot. I’ll try that again anyway and see what happens. AFAIK GPS was behaving fine (23 sats in view and ~0.6 HDOP).

OK, then best to leave the D term as you had it.
See if you can make the other changes and get to stage where Autotune will finish.
If Autotune produces bad results it’s almost always because of vibrations and noise.

It could be that your ATC_RAT P and I terms could go lower, and ATC_ANG P terms could go higher.
Best to follow the tuning guide in detail, print it out and cross off each step as you go.

Something like:
ATC_ANG_RLL_P,10
ATC_ANG_PIT_P,10
ATC_RAT_RLL_P,0.10
ATC_RAT_RLL_I,0.10
ATC_RAT_RLL_D,0.0045
ATC_RAT_PIT_P,0.10
ATC_RAT_PIT_I,0.10
ATC_RAT_PIT_D,0.0045
But use the tuning guide to increase/decrease those in stages, watching for oscillations

Did that and compiled it all into a little “slideshow”. See:
PID tuning pitch comparison
PID tuning roll comparison

I went down to 0.11 for P and I and 0.005 for D. Noticed oscillations (very small) then backed off to 0.12 for P and I and 0.0045 for D. ATC_ANG_ terms started to get worse around 8.5 so I backed off to 8.0.

I’ll try the Autotune soon but I am just making sure I cover all my bases before I do so. The last time resulted in a nasty crash.

OK, good work. Some multirotors require special treatment regardless of past experiences

Still weird because it was working fine with default PIDs and default Initial Parameters too with the old Pixhawk 2.4.8. Switching over to the Cube Orange caused all of this.

You could give the VTOL quick tune LUA script a try to get good stable starting points for Autotune.
Autotune does a more complete job of course, but this should get an unstable craft flying quite OK.

Works like magic:

I hadn’t seen this before. It is pretty cool. However, my drone is completely unstable in Loiter at the moment.

I tried looking into SystemID mode and even tried implementing it on my F450. Unfortunately, it only works after the drone has risen to 25-30 m altitude which is too high for me to see what is going on. I ended up stopping it and landing my copter.

Okay, I tried this today on my F450. My F450 was untuned with default PIDs but stable in both Alt Hold and Loiter. This process does work in Alt Hold but the end result was actually far worse than when I started out. My guess is this is still in development and the logic is not fully fleshed out.

I did have feed forward disabled (ATC_RATE_FF_ENAB,0) so not sure if that made things worse.

I think I know what was causing this issue. To anyone still following this thread here is a summary:

  • I have a working T960 drone with Pixhawk running v4.0.5
  • Pixhawk starts showing voltage problems
  • I replace it with Cube Orange >v4.1.xx
  • Drone is completely unstable in both Loiter and PosHold
  • I try to manual tune followed by autotune
  • Crash (ESC desync) :frowning:
  • Build a new drone with original Pixhawk running v4.2.3
  • Same issues in Loiter and PosHold
  • Switch over to v4.0.5 on Pixhawk drone
  • PosHold works fine, just like before
  • Try this on Cube Orange on the same drone
  • PosHold is oscillating but not blowing up to infinity

Admittedly, I have not done an autotune again since the last crash but this points to something that changed in the attitude controller between those versions that caused all this mess. The new versions v4.2.xx work fine on my F450 so somehow this is only a thing on larger frames.

Rather than the firmware version, it’s more of an issue with larger frames and all the problems they can amplify over smaller frames:

  • vibrations
  • flexibility

And these are more problematic to keep under control particularly if they are not carefully selected or well matched

  • motors
  • ESCs
  • props

Each of these points could have a whole big discussion behind it too, so it’s not as simple as replying and saying something like “small frames have vibrations too”

I don’t know, Shawn. Here is a test with the Pixhawk running 4.2.3:


Notice how the envelope of the Pitch and Roll traces tend to infinity – a classic sign of instability.
And here it is running 4.0.5:

It “just works”. Both tests were with default PIDs. I changed nothing else besides maybe some legacy settings and redid the compass cals. It is possible autotune will fix it on the 4.2.xx version, but I have seen posts where it didn’t. All of this works fine on smaller drones so yes, I can only conclude there have been some changes to the attitude controller in versions 4.1.xx and above that are making larger copters unstable.

Logs:
Pixhawk running 4.2.3
Pixhawk running 4.0.5

Thanks - I’ll check those logs to see where the differences come from, if possible for me :slight_smile:

Would be nice if you could. Not sure if this should be reported or what the official channels are for that anyway. GitHub?

4.0.2 Pixhawk1 Hex, looks pretty good with defaults and initial params, using EKF2
4.2.3 Pixhawk1 Hex, looks OK except when in Loiter mode, using EKF3

PSC_ACC_XY_FILT,2 present in 4.0.2 not in 4.2.3 , unsure if this makes a difference, I’ve never changed it.
PSC_VELXY_D,0.5 which is the default is 4.2 and above - only noted because I changed it slightly in my recent build, as per below.

I cant actually pick out what would cause the Loiter oscillations between the two, but something has become more sensitive.

Hi @Leonardthall are you able to take a look? Basically same build with two different firmware versions yet vastly different Loiter behaviour. I’ve seen this a couple of times lately, although not experienced it myself. No appreciable difference between parameters except where noted above.

This is hijacking your thread a bit, but by way of example…
I very recently set up a Quad X8 and it flew well on defaults+initial and some slight PID changes I made before flying. I also pre-configured the HNOTCH based on what I expected to work (and fine tuned it later). It didn’t appear to have this loiter issue at all, in fact it seemed like Autotune wouldnt even be needed. Starting params:
ATC_ACCEL_P_MAX,92000
ATC_ACCEL_R_MAX,92000
ATC_ACCEL_Y_MAX,18000
ATC_ANG_PIT_P,8
ATC_ANG_RLL_P,8
ATC_ANG_YAW_P,5
ATC_INPUT_TC,0.2
ATC_RAT_PIT_D,0.006875
ATC_RAT_PIT_I,0.11
ATC_RAT_PIT_P,0.11
ATC_RAT_RLL_D,0.006875
ATC_RAT_RLL_I,0.11
ATC_RAT_RLL_P,0.11
ATC_RAT_YAW_I,0.036
ATC_RAT_YAW_P,0.36

After Autotune it came up like it was some crazy racing quad - and it could handle it too. There was nothing strange about it and performance was great! I’ve softened these a bit since the Autotune because this is meant to carry a large gimbal and camera. You can see the accels and PID’s came up very high.
ATC_ACCEL_P_MAX,120000
ATC_ACCEL_R_MAX,120000
ATC_ACCEL_Y_MAX,28000
ATC_ANG_PIT_P,22
ATC_ANG_RLL_P,20
ATC_ANG_YAW_P,8
ATC_INPUT_TC,0.23
ATC_RAT_PIT_D,0.008
ATC_RAT_PIT_I,0.18
ATC_RAT_PIT_P,0.18
ATC_RAT_RLL_D,0.008
ATC_RAT_RLL_I,0.2
ATC_RAT_RLL_P,0.2
ATC_RAT_YAW_I,0.09108223
ATC_RAT_YAW_P,0.9108223

One thing I also manually changed with the expectation that Loiter would be very sensitive on this craft was
PSC_VELXY_D,0.3 (you have PSC_VELXY_D,0.5 which is the default)

You can see in this graph there’s nothing wrong with attitude control, even in Loiter - this is after I softened everything too.

In fact I’ve probably got to reduce the accels some more and add some expo or dead zone to the pitch and roll sticks, since the aircraft follows the tiny little spring oscillations of the self-centering sticks when you let them go (even gently)

The motors and props came of an old Quad X8 tarot 650 sport frame with about 2kg of old conventional ESCs and wiring. Now it’s using two 4-in-1 45A BLHELI ESCs with DHSOT600. 6S 12Ahr battery. New frame and FC.

Can you give me the log please? I have seen this too and it would be nice to get to the bottom of it.