Need Help with Throttle Based Notch Filtering

Hi All
I have a 12s quad X Config, 24inch prop and using Tmotor Alpha Esc

I did a flight just to determine how to set throttle based notch filtering, i am confused on how to set it up since I see 4 Peaks in the pre filtered gyro graph.

I have done the following settings before doing a hover flight in Altitude flight mode.

INS_ACCEL_FILTER = 10hz
INS_LOG_BAT_OPT = 4
INS_LOG_BAT_MASK = 1
FFT_ENABLE = 1
FFT_MINHZ = 25
FFT_MAXHZ = 300
INS_HNTCH_ENABLE = 0
INS_HNTC2_ENABLE = 0

How do I configure the notch filter? Do I need both the notch filters running for this big drone?

I have attached the flight log here

Also how can I update the date and time for my log files? Like the date is fine but if I fly the drone lets say at 4pm the log time is 2am.

The anon .log file doesnt work in the FFT grpahing section unfortunately.
You could PM me the .bin file if you like.

But I can see in parameters the in-flight FFT has picked up the wrong frequencies

FFT_BW_HOVER,150
FFT_FREQ_HOVER,172.3007

Based off your prop size and other settings I would set:

FFT_ENABLE,0
INS_HNTCH_ENABLE,1  //  set this then refresh params to see the rest
INS_HNTCH_MODE,1
INS_HNTCH_REF,0.26
INS_HNTCH_FREQ,38
INS_HNTCH_BW,19
INS_HNTCH_FM_RAT,0.7

My spreadsheet estimates some of those values, so you can confirm them in the FFT graphs.
Send a screenshot of the Gyro graphs (pre and post) - be sure to select “Magnitude” at the bottom left before loading the .bin file.
The pre-filter graph is Gyro0 and the post-filter graph will be Gyro3

Hi Shawn
Thanks for your input!

I’ve provided the log file now, sorry about that!

Hi Shawn, I’ve read so many threads where someone shares a log and says they have this or that problem and you are always able to suggest a list of pid and notch parameter values to suit their new copter. Can i ask how you arrive at the appropriate values and is there a guide or a doc or spreadsheet or something that people could use to find the appropriate values themselves. It seems unfair that you always have to provide the magic numbers for every different airframe being built each day all over the world…
Otherwise keep up the good work and thanks for all the assistance :+1:

Thanks for the .bin log file.
You can see the peak we need to target is around 44 Hz and the width is about 17Hz , so we were fairly close with the estimate earlier. And there is clearly 3 harmonics.

image

So apply all the settings I gave previously, but adjust these settings

INS_HNTCH_FREQ,44
INS_HNTCH_BW,22
INS_HNTCH_HMNCS,7

In that log you had a couple of sudden jumps in altitude (up then down) when the GPS units switched over the primary role. See the yellow line on this graph.

And see their Lat/Long position across the ground is quite different too - blue and green lines.
The red line is where the EKF calculates it should be given ALL the inputs.

So what I would do is set these to limit the number of constellations for reliability, and choose to stay with the primary GPS unit unless it has a bad issue, instead of letting them swap over just anytime.

BRD_BOOT_DELAY,3000
GPS_AUTO_SWITCH,4
GPS_GNSS_MODE,65
GPS_GNSS_MODE2,65

The default PIDs are not helping you much, but it’s good that you can get it in the air and fly well enough to collect good data. Let me know if you want help with the attitude control - I can see a few changes I would make before the next flight.

I do like to help - it can be a fine line between just giving someone a few pointers like “read this, read that…” so they can learn themselves - or giving them ALL the parameters they will probably need to get going without destroying their hard earned $ before it even gets off the ground. I find once I give a few parameters it’s hard to stop at just that, in case they believe that’s ALL they need to do :slight_smile:
The smaller copters can be interesting to keep checking logs and changing params where the novice user wouldnt be up to that stage yet, but if it was a reasonable bunch of parts and suitable steps followed a copter should fly well enough without anyone else’s intervention.

What I see these days that pushes me to provide ALL the parameters or suggestions that I can is:

  • Lots of people are starting with bigger copters with very big props - this could be very expensive and it could be very dangerous.

I dont want to discourage them from Ardupilot by allowing their copter to destroy itself if I can help it. I feel the need to provide as much detail as possible.

To be honest I’m a bit worried about all the large carbon fibre props out there in the hands of beginners. When you’ve seen a large motor and prop being tested in a steel cage, and the prop breaks loose and cuts clean through the cage, cuts through other nearby items and only stops against very solid steel (that also gets damaged) - and the prop is still almost in one piece - I guarantee everyone will be standing much further back in future, and doing more bench testing, research and tuning before calling their copter a going concern.

What I want to do is settle on a slightly different set of default PIDs that will give a steadier first flight across a wider range of copters, than the default PIDs we have now. I’m collecting logs and copter details, but it’s still unclear if this aim is even possible.
The PIDs I suggest sometimes come from what I’ve seen on similar copters, and sometimes from the attitude control in the supplied log, or a merge of the two.
Occasionally the attitude control can be so messy that you just have to guess and see what happens - there’s always a level of anxiety with this type of recommendation since it is someone else’s copter and $$

Until then here’s a link to my sheet that was the basis for the Initial Parameter calc in MissionPlanner, and itself is just based on Leonard Halls tuning guide. So I havent really invented anything, but brought a few things together into one place. I have recently added an estimate section for throttle-based HNOTCH

1 Like

Thanks for sharing your updated spreadsheet! Do you think we’ll see the Notch Filter settings added into initial parameter settings tool in Mission Planner?

Hi Allister,
I’ve thought about adding some HNOTCH settings into Initial Params, but not too seriously yet.
It is probably achievable and maybe worth-while. I would say it needs a caveat or explanation to go along with it about checking logs and FFT graphs to ensure it’s working correctly, or changing over to another system like FFT or ESC/RPM based HNOTCH. Some settings would have to be checked and adjusted after first flights.

1 Like

Hi Shawn

Thanks for helping me out with this!

Just to summarize, before next flight I need to make the following changes:

FFT_ENABLE,0
INS_HNTCH_ENABLE,1 // set this then refresh params to see the rest
INS_HNTCH_MODE,1
INS_HNTCH_REF,0.26
INS_HNTCH_FREQ,44
INS_HNTCH_BW,22
INS_HNTCH_FM_RAT,0.7
INS_HNTCH_HMNCS,7
BRD_BOOT_DELAY,3000
GPS_AUTO_SWITCH,4
GPS_GNSS_MODE,65
GPS_GNSS_MODE2,65

This week looks doubtful for me to conduct a test flight, weather doesn’t look good!

I’ve also pulled out the motor from the quad to run some bench thrust test.

I’ve found that my motors are pretty much operating at 65% and above throttle just to maintain hover, the bench test data also shows that only as to meet the quads Thrust to weight ratio.

Once the weather is all good i’d get airborne again with these parameters and do a quick hover flight in altitude mode.

I have few more doubts

  1. Since I have 3 harmonics, do I need to also setup HNTC2?

  2. I never got any audio message on mission planner when the GPS primary changed, how do you decided which GNSS constellation is good for a given geographic location?

  3. Is it better to perform autotune and then set notch filter or the other way around, what values do you recommend for the attitude control?

Thanks for sharing your excel sheet!!

Appreciate the help!

Yes, you can make all those changes in one hit.

  1. No, there is usually no need for the second notch filter. The first notch filter can handle the harmonics.
  2. The region does matter a little, but also the GNSS units capabilities. Only recent GNSS units will do Galileo for example, and most wont do more than 2 constellations at once without issues.
  3. Best to set up the HNOTCH properly before running Autotune. This gives Autotune the best chance to work effectively with less noise. Hopefully test flights have also identified and resolved any major instability.

I’ll test it out next week and update you on the progress!

Thanks!

Dear @xfacta

I finally got a chance to do a quick flight yesterday with the following parameter changes, I did a loiter flight with some maneuvering,

Log below

FFT_ENABLE,0
INS_HNTCH_ENABLE,1 // set this then refresh params to see the rest
INS_HNTCH_MODE,1
INS_HNTCH_REF,0.26
INS_HNTCH_FREQ,44
INS_HNTCH_BW,22
INS_HNTCH_FM_RAT,0.7
INS_HNTCH_HMNCS,7
BRD_BOOT_DELAY,3000
GPS_AUTO_SWITCH,4
GPS_GNSS_MODE,65
GPS_GNSS_MODE2,65

There is an improvement in the post gyro filter and also the GPS is working out well. I am not sure if this is good or I need to do some more tweaking!

I am still not able to understand the following

  1. How do you determine which frequency to filter out? In the log that was initially shared there were a total of 4 distinct peaks.

  2. How did you determine that there are 3 harmonics?

  3. is there a better way to see the data plot of notch filtering else where because on mission planner its a little difficult to pinpoint the values.

  4. Lets say I have 4 identical drones, would they all have the same notch filtering values or is it better to individually find test fly them and determine them?

  5. To determine the notch filtering value we do an FFT setup initially, what should be the min HZ and max HZ to be set, are they dependent on number of rotors, prop size, with and without payload?

What do you recommend I do know, Shall I proceed ahead with manual tuning or auto tuning?

Appreciate the help!

Z axis vibrations are bit of an issue, or at least getting higher than your really want them. If you can do some more work to reduce Z axis vibrations that will pay off in the long run.

This is the graph from that flight, and you can see the actual copter movements down around 10Hz and below, and the base frequency to be targeted at about 44Hz. The other two big peaks or areas are the harmonics.
image

I ran this log through the new filter review tools and was able to better target the base frequency and harmonics with some slightly adjusted settings (listed below). The vertical black lines are where the deepest point of the notch will be. This new method has proven to filter noise so well that PIDs work better or need less adjustments (so far)
In this graph the estimated post-filter noise is practically nothing.

INS_HNTCH_REF,0.25
INS_HNTCH_FREQ,40
INS_HNTCH_BW,20
INS_HNTCH_HMNCS,11

Looking over your attitude control I think you could increase the Angle P’s and decrease the Rate PIDs as a better starting point.

ATC_ANG_PIT_P,6
ATC_ANG_RLL_P,6
ATC_RAT_PIT_D,0.00275
ATC_RAT_PIT_I,0.11
ATC_RAT_PIT_P,0.11
ATC_RAT_RLL_D,0.00275
ATC_RAT_RLL_I,0.11
ATC_RAT_RLL_P,0.11
LOG_BITMASK,180222
PSC_ACCZ_I,0.72
PSC_ACCZ_P,0.36

Start in Stabilise and AltHold modes, try to only use Loiter once tuning is a bit better - and it’s easier to tell what’s going on.

  1. the base frequency to target is almost always the first peak of a higher frequency than about 20Hz, and the following peaks (higher frequencies) are the harmonics.
  2. in MissionPlanner FFT graphing tool, select “Magnitude” at the bottom left before you load the log.
  3. MissionPlanner works well, for FFT work but the new Filter Review Tool is better because it shows the results of changes you make without doing additional flights.
  4. If the copters all are created equal then apart from the Accel, Gyro and Compass calibrations, you can transfer over just about all other settings (the list can be trimmed down a lot though, dont copy everything!) including the filter settings. You would test fly to check everything works as expected.
  5. The short answer is yes. The long answer is FFT min Hz needs to be lower than the expected minimum frequency. The max Hz value likely doesnt need much change. When using a dynamic HNOTCH the INS_HNTCH_FREQ also needs to be lower than the minimum expected frequency, since the “dynamic” input can scale the frequency (and bandwidth) UP from there, but not down.
    The actual frequency will depend on the takeoff weight and how hard the motors and props have to work (RPM) and a whole lot of other variables.

Here’s a link to my spreadsheet, included is a rough estimate of the INS_HNTCH_FREQ based on prop size.