RTL causing unstable flight after it was flying well

Looking for some advice/help. Today I was flying in loiter with what seemed a decent tune. I tried RTL and the quad became very unstable. Almost as if the gains were way too high. Please see below.

Series of events:
1)Today I ran autotune on my quad. It completed successfully. I went back to loiter then back to autotune for pilot testing. Like the changes so landed disarmed and it said saving parms.

  1. I armed in loiter flew another short flight to get a 30 second hover. Landed disarmed.

  2. Took off in loiter tested roll movements, tested pitch movements, flew a circle. Then I went near my take off location and tried an RTL. Once in RTL it started to shake more and more, I went back to Loiter but it was still getting worse so I set it down. The log is below and once can see the actual roll vs desired roll is much worse after the attempted RTL. Any ideas what would cause this.

Build
Cube Black copter v4.5.7
Here2 GPS
Quad
Motor T-Motor MN4014 330KV
ESC - TMotor F35A Dshot
Prop - 15”
All up weight 3.4kg

Log file is located here.

Parameters are here:

Stable Hover Video before RTL:

Attempted flight after the RTL (taking off in loiter):

It took me some time to analyze the flight, and unfortunately, I couldn’t find a clear reason for the oscillation. Since the flight was long, I considered whether it might be related to the effects of low voltage on motor response. Is this the first time this vehicle has been flown for such a duration?

Since you took off in Loiter mode at the very beginning and did the same later when the vehicle was almost critically stable, I couldn’t find any significant difference except for the battery factor.

By the way, I noticed that the magnetic field variance increased significantly at the end of the flight when the motor started drawing high current due to aggressive control commands. While this is not related to the problem, I suggest using the MAGFit web tool to improve offset calibration, which could be beneficial in general.

1 Like

I initially thought the flight duration was long, but I realized that wasn’t the case. The voltage also wasn’t significantly low, but if the controller margins aren’t well-tuned, voltage drop might still affect the behavior. This is just my last remaining thought, as I couldn’t find a clear reason for the oscillation. : )

Thanks for looking Randy. I have run magfit and on several occasions now have had prearm errors on some flights where the mag field sitting on the ground was 3033. I am using an old here2 gps/compass and wondering if it needs replacing.

Additionally I went back to the field and it flew fine. I reran auto tune and hte P,I terms in the pitch axis were much less. I then flew in loiter for a bit. Then tried an auto mission. I was going to do one more flight and try RTL again but it would not arm due to the mag field again. I do not think it due to motors as it wasn’t even arming.

Would a bad mag field cause the aircraft to oscillate as it tries to figure direction out??

As far as I observed, the GPS accuracy was fine. In my opinion, a bad GPS or compass would primarily affect high-level loops (guidance, position control, or velocity control) rather than low-level ones (angle or rate controllers).

What would an ESC sync issue look like? The motors I am using are TMotors MN4014 navigator series they typically recomend their AIR series esc. I went with their F35A which is more of an FVP racing ESC. Not sure really what makes one for racing vs camera lifting drone. The F35A is rated up to 6S and more than enough amps. I’m only pulling 4.5 to 5 amps per motor. I went with the F35A as I like that it was DShot enabled, lighter and smaller and avoided all the throttle calibration process of the non DShot ones.

Not all the vibration data is recorded but I suspect vibrations are a bit too high as IMU2 is clipping.
See if there’s anything physical you can do to improve vibrations. This is time well spent, and there aren’t parameters to “fix” vibrations.

There’s quite a bit of weight bias towards the front of the copter, see if you can balance it better.


This affects the noise and how the harmonic notch filter is set up too, since currently you’ve got noise peaks at both 50Hz and 60Hz (approximately) due to the two different motor groupings.
If the COG cant easily be fixed you will have to strive to set up DSHOT properly so we can set the notch filter for per-motor notches.

At the moment the notch filter is not even working.
How everything is now (without the physical fixes), these are the correct notch filter settings:

INS_HNTCH_MODE,1
INS_HNTCH_BW,25
INS_HNTCH_FREQ,50
INS_HNTCH_FM_RAT,0.7
INS_HNTCH_HMNCS,3
INS_HNTCH_REF,0.18
INS_LOG_BAT_OPT,4

Set better logging:
LOG_BITMASK,180222

You dont have DSHOT working, so that would be handy to get going and see if you can set up the ESC/DHSOT telemetry too.
Until then, set this:
MOT_PWM_TYPE,0

There’s two options for setting up DSHOT

  1. use the BDSHOT firmware and move the ESC wires to AUX outputs, you’ll have DHSOT with RPM
  2. set BRD_IO_DSHOT and connect the ESC telemetry wire to a serial port RX pin.

Then the harmonic notch filter can use the ESC RPM instead of throttle, plus you have extra data in logs for any diagnostics.
If you get ESC RPM data in the logs then you can set these for the harmonic notch filter:

INS_HNTCH_BW,10
INS_HNTCH_FM_RAT,1
INS_HNTCH_FREQ,40
INS_HNTCH_HMNCS,3
INS_HNTCH_MODE,3
INS_HNTCH_OPTS,2
INS_HNTCH_REF,1

Stability
It seems the motor output oscillations started in RTL and grew to continue in Loiter, as you said. The motor output oscillations only slightly affected the pitch and roll. Since RTL and Loiter are similar with regard to controlling the copter, I suspect this means the instability was not related to the flight mode but maybe the ESCs were overheating or something like that - unsure.
If they are BLHELI32 then set these in the ESCs using the BLHELI32 config app:

  • Low RPM Power Protect = OFF
  • Low Voltage Protection = OFF (rely on the flight controller battery settings)
  • Temperature Protection = 90
  • Motor Timing = Auto

If they are AM32 then there should be similar settings and a slider for the motor KV.

Since you dont have DSHOT working, you should do the ESC calibration as per the link below 9at the bottom)

Then I would go back to fairly standard/working PIDs and accels to see what the copter is like with the correct notch filter settings, and go from there - dont forget the physical fixes first!
Use AltHold and then Loiter for the test flights.

ATC_ACCEL_P_MAX,78000
ATC_ACCEL_R_MAX,78000
ATC_ACCEL_Y_MAX,22500
ATC_ANG_PIT_P,13
ATC_ANG_RLL_P,11
ATC_INPUT_TC,0.20
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

Keep Rate P and I values the same when doing manual tuning. Hopefully if everything gets fixed you wont need any manual tuning.

https://ardupilot.org/copter/docs/esc-calibration.html#semi-automatic-esc-by-esc-calibration

2 Likes

Thanks so much for the detailed response.

I’ll look for vibration related issues. but have things secured pretty well. Part may be the motor I used. It is a fairly large MN4014 at 150g each. Ideally I’d have used 4006 size at 70g each. The copter arm is only 16mm so I wonder if the large motor/arm size is part of that issue.

I can easily work on the balance. From that graph it looks like the rear motors are working harder which isn’t surprising with how I have it balanced. The battery is further back for a payload up front. I was flying without a payload to tune so the front was about 500g lighter up front. I’ll center the flight battery which will help the COG.

Maybe I am using the wrong ESC? I am using TMotors F35a - (https://store.tmotor.com/product/f35a-fpv-esc.html?srsltid=AfmBOorSA0wvbMkzAs9RKo-h2taPx1m8Usm1J9MBvPl45j51X2MBlOAr) .It is supposed to be DShot1200/600/300 and uses BLheli32. Tmotor generally recommends their AIR series for Navigator motors but the F35a seemed like it should be capable. The only wires it has are the main power (red/black) and then a signal (white)/ground(black), I didn’t see any telemetry wire to send a signal back. I’ll look into connecting them to the BLHELI32 config app to set the setting above.

Originally I had the MOT_PWM_TYPE,0 but the motors would not spin until I set that to DShot

My original Notch was set after a hover but I had a payload on so it was probably better balanced.

I’ll report back once I have made the changes. Thanks again!

Good and Bad news.
Spoiler - bad news - crash after some ESC settings so I am still doing something wrong.

THE GOOD NEWS
I balanced the aircraft better and I spent some time getting DShot set up correctly I think. I set the tuning parameters back to what you recommended except ATC_ANG_PIT_P and RLL_P had defaults of 4.5 and 13 was out of range so I went with 4.5. I also turned off the notch filter I had as it was wrong. I did a short hover and the vibrations looked much better. The RCOU (9-12) for the motors was much more equal. I was going to use this for the notch filter.

Log is here 2025-02-04 18-00-36_ShortHoverDShot.bin - Google Drive

THE BAD NEWS
Then I decided to try and get the telemetry working the ESC are on BLHeli 32.9
I set the additional 2 parameters
SERVO_BLH_BDMASK should be 3940 (channel 9,10,11,12)
SERVO_BLH_POLES = 24 The MN4014 motor is 18N24P should be 24
SERVO_DSHOT_ESC was already 1 (Should I have used 3?)
After these changes I did a motor test again. I then went to do a short hover for the notch filter tool. This flight ended very badly. After arming I went to lift off it rocketed up with no control and came down hard.
Log is here: 2025-02-05 16-25-56_Crash.bin - Google Drive

The parameter file with the additional parm changes is here. T650SParms2025-02-05AfterCrash.param - Google Drive

I must not have my esc correct still any recommendations on what I did wrong.

Whenever you have stability issues in Loiter mode (or RTL, which is basically the same Loiter mode), but not in Althold, it is very often due to excessive gains of the Loiter Mode positioning.

PSC_VELXY_D
PSC_VELXY_I
PSC_VELXY_P

I would reduce strongly PSC_VELXY_P and PSC_VELXY_D (like leaving it at 25 % of the original value), the I value I would not touch.

If your overall tuning is not very good, the Loiter mode will “reveal” the issues.

When PSC_VELXY P and D are high this is equivalent to a student pilot who jerks the stick back and force and causes Pilot Induced Oscillations, which can lead to a crash. If the normal Roll and Pitch PIDs are not well tuned, they can not compensate for these Oscillations.

The Oscillations can be seen in Logs as Oscillations of Desired Pitch or Desired Roll.

PS: when you reduce the ATC_ANG_P you make the copter less responsive. If you have issues with oscillations in Loiter Mode, that will usually take these oscillations out, however, if the Alt Hold tune was good, then by reducing the ATC_ANG_P you reduce overall response. So reducing ATC_ANG_P has the same efect as reducing PSC_VELXY_P for the Loiter…

1 Like