I can't fly my quadcopter, because my motors oscillates badly after the activation of Harmonic Notch filters

Hi Mr Swawn,
Thanks for all your help and the settings.
I did some test flights today and their results were very encouraging!!!
I performed a total of 3 flights and their log files are shown below:

In this flight, I used all your parameter settings. The copter was quite stable in Stabilize and Althold flight modes. In Loiter mode, I think that the aircraft behaviour was a bit strange, but quite safe.

In this flight, I used your parameter settings, except:
INS_HNTCH_FREQ =100 (= FFT_FREQ_HOVER for my aircraft)
INS_HNTCH_BW=50
INS_HNTCH_REF=0.3 (percentage of throttle required for my aircraft hovering)
The aircraft behaviour was similar to the previous case.

Finally, in this flight, I used your parameter settings, except:
FFT_ENABLE=1
FFT_FREQ_HOVER=100
FFT_BW_HOVER=40
FFT_ATT_REF=15
FFT_HMNC_FIT=10
FFT_HMNC_PEAK=0
FFT_MAXHZ=300
FFT_MINHZ=25
FFT_NUM_FRAMES=0
FFT_SAMPLE_MODE=0
FFT_SNR_REF=20
FFT_THR_REF=0.35
FFT_WINDOW_OLAP=0.75
FFT_WINDOW_SIZE=256
INS_HNTCH_ENABLE=INS_HNTC2_ENABLE=1
INS_HNTCH_FREQ=INS_HNTC2_FREQ=100
INS_HNTCH_BW=INS_HNTC2_BW=50
INS_HNTCH_MODE=INS_HNTC2_MODE=4 (FFT setup)
INS_HNTCH_FM_RAT=INS_HNTC2_FM_RAT=1
INS_HNTCH_REF=INS_HNTC2_REF=1
In this case the aircraft could not take off safely, due to high oscillations.

In the log files, I noticed that the RCOU have improved significantly!!!
Also, all the vibrations are normal, especially in Stabilize and Althold flight modes.
In Loiter mode, I think that some improvements are required.

From the first log listed of the good flight, just adjust these

ATC_THR_MIX_MAN,0.5

To relax the position controller a bit and Loiter might settle down, these are just half of default values so it is easy to put back later if you need the more strict position control.
These wont change stability or cause oscillations, so very safe

PSC_POSXY_P,0.5
PSC_VELXY_D,0.25
PSC_VELXY_I,0.5
PSC_VELXY_P,1.0

And to just fix up the harmonic notch filter a bit

Option 1 - the basic adjustment

INS_HNTCH_FREQ,55
INS_HNTCH_BW,30

Option 2 - slightly more advanced

INS_HNTCH_FREQ,55
INS_HNTCH_BW,20
INS_HNTCH_OPTS,16  // triple notch

Both need to have logs checked after a test flight.
In Option 1 the wider bandwidth could cause a slight delay that shows as fractionally worse attitude control. If attitude appears good then it’s not a problem.
Option2 would be the preferred option provided the CPU is not overloaded and the bandwidth is not too wide. Check in logs for PM.Load , presently between 400 and 460. A Cube Orange should be perfectly OK. Option 2 could probably use a couple of test flights with more narrow bandwidth values to check how narrow you can go and still filter all the noise. This option will have less lag and wont affect stability.

PIDs will need a bit of work too, so increase this logging before the next test flight
LOG_BITMASK,180223
and lower the rate PIDs just a little bit

ATC_RAT_RLL_P,0.11
ATC_RAT_RLL_I,0.11
ATC_RAT_RLL_D,0.004
ATC_RAT_PIT_P,0.11
ATC_RAT_PIT_I,0.11
ATC_RAT_PIT_D,0.004

There’s still some sign of motor mount twist in the RCOUT.
See if you can get the motors aligned better so the props all spin on exactly the same plane.
If you set all the props so they are around in a circle (or square with a quad), all the tips near each other.
Check from the side view, see if all the tips line up, you should be able to easily see if any props are on an angle.
image

From a process controls perspective, adjusting the derivative action of the PID controller makes perfect sense. The gain and integral don’t rapidly result in instability, but a derivative “D” in the PID can.

Technically, what you’re doing is open-loop tuning and testing. There are codebases that can log this and then take the flight data and then generate updated tuning constants for the PID controller. Try reducing the D in the PID and see if that helps as well. You an start by eliminating it, go to zero. Then move up from there.

My background is in electrochemical engineering and real-time controls with some ophav experience with Martin Jetpack group in NZ.

Sounds like you’re on the appropriate message board. @electrostasis

Does ardupilot have an autocalibration system to review the logs and re-tune the PID on drones based on flight data with open-loop tuning - this is where you perturb the system in air and let it oscillate either it dampens (self) or goes critical and pilot has to take back control of the craft.

It’s called Auto Tune:
Auto Tune

I made a few more flights with the Shawn’s settings. However, I didn’t notice significant difference in my aircraft’s behaviour.

In this flight, I used all the Shawn’s settings. The copter had similar behaviour with the previous flights. Also, I noticed that RCOU values are normal, but the attitude control still needs some work.

In this flight, I used al the Shawn’s settings. Also, I set LOG_BITMASK=180223.

In the log file, I saw you set ATC_RAT_RLL_FLTE to 100Hz. Is it intended to?
Moreover, I think ATC_THR_MIX_MAN should be set to 0.1 before tuning and ATC_RATE_FF_ENAB should be 1 to verify the tune.

Thank you for replying.
I want to tune my aircraft professionally, so I followed step by step all the stages, before using Autotune (according to the official website).
I think that the copter was flying well, but the noise from the motors was affecting the attitude control of my aircraft.

This image refers to the output of Motor1, in the first flights (the copter was pretty stable).

This image refers to the output of Motor1, in the last flights (the attitude control was really bad).

Comparing the 2 images, I believe that now the attitude control still remains bad, but the outputs of the motors are more consistent.

I noticed it now too. The parameter ATC_RAT_RLL_FLTE should be equal to 0.
About the parameter ATC_THR_MIX_MAN, I used the Shawn’s value.

About the notch filter, should we target 51Hz rather than 55Hz?
It seems to me that you still have some noise at the rate:

And the noise is not eliminated significantly

This is a problem of my construction, which can’t be solved. I use the following folding arms, which have some gaps in the plastic parts (their holes are not exactly 3mm, just like the bolt):

Folding frame ZD550 ZD680 ZD850 zd1100 accessories aluminum alloy folding parts 20mm 25MM folding machine arm Z20 (tarot-rc.com)

Can you suggest me some additional settings for my aircraft, but I will try them in about 10 days (I’m on vacation now).
If I activate the second harmonic notch filter, will the rest of the noise be eliminated?

The folding arms should be fine provided there is no free play when they are locked in place, and the fold down not up.

1 Like

It’s good that all the motor output oscillation is gone.

There’s still some motor mount twist - see if you can get that sorted out and it will help the harmonic notch filter and subsequent tuning.

ATC_RAT_RLL_FLTE must be a typing error and should definitely be 0

I had asked for ATC_THR_MIX_MAN,0.5 because vibrations are low and there doesn’t appear to be a risk of fly-away. It’s safe to leave this in place.

As per bigboy061293s suggestions and data let’s change the harmonic notch filter a bit

INS_HNTCH_FREQ,50
INS_HNTCH_BW,25
INS_HNTCH_OPTS,0

This should be suitable and if you fix the motor mount twist the peaks in FFT will be narrower and HNOTCH will work better. No need to enable the seconds notch filter.

I know this is a bit of a hassle, but can we see another test flight with these simple changes before we dive into changing PIDs any further. There’s a lag in PID to attitude that I’d like to see if it’s resolved by removing the triple notch and correcting ATC_RAT_RLL_FLTE.
My suspicion is with that lag we would never be able to get the PIDs correct.
Just take off in AltHold and do some gentle pitch and roll, if everything is OK try Loiter too.

Ok, I will try the new settings in the next week and I will publish the new log files!!!

Hi everyone,
I tested the new settings. The copter still needs some work in attitude control!!!

One more log file from my quadcopter.

The hover throttle doesnt appear to be learning, I would set
MOT_THST_HOVER,0.32
and also

BARO_PRIMARY,1
BRD_BOOT_DELAY,3000
GPS_AUTO_CONFIG,1
GPS_GNSS_MODE,5 or 65
INS_ACCEL_FILTER,10
MOT_SPIN_MAX,0.95

Until this is more stable and easily flyable, I would disable the rangefinder
RNGFND1_TYPE,0
and undo any EK3 changes
It’s returning what looks like a good smooth altitude, but that is not matching with GPS or Barometer altitude at all. It seems to be causing altitude oscillations and may be interfering with that hover thrust learning. The current rangefinder params will remain there in the background for later when you enable it again, you just wont be able to see them while the rangefinder is disabled.

Let’s see a log with those changes. Start with Stabilise mode and then AltHold - that hover thrust may need some throttle stick adjustment until it settles on a correct value - be prepared to use Stabilise again if you have to.
If everything is going OK then try Loiter.