Necessary steps for harmonic notch setup?

Hello,
I have been reading the wiki articles for configuring the harmonic notch filter dynamic and also fft, but I already did 2 sets of test flights, each set with a test flight without the filter enabled and the other with the filter enabled, and when I analyzed the gyro through the FFT option through CTRL-F in mission planner, both graphs were practically identical, even through the ins_hntch_freq was set to the first peak.

below are the logs of the most recent set:
before filter log:
https://drive.google.com/file/d/1JhE6bgxGReRslItwVr57I9k62WiHbmS_/view?usp=sharing
after filter log:
https://drive.google.com/file/d/1qCtZ5G40GWjN5j8w1-qCn9-DAO7c3Z0d/view?usp=sharing

That’s kind of weird. It is working but the PkAvg value is substantially worse than the individual components of the first harmonic. Maybe try setting FFT_SNR_REF to 15 just in case its missing some values because this is too high

Hello,
Thank you for taking the time to answer my newbie doubts. Could you confirm if this process is the correct one?
First I set FFT_ENABLE to 1 and reboot the flight controller. Then I hovered the drone in alt hold for at least 30 seconds then landed and disarmed. I downloaded the log, and analyzed the FTN1.PkAvg and noticed the peak was close to 60 Hz.
Then I enabled the harmonic notch, set the mode, the ref and the frequency and lastly tried another flight.
I will upload the parameters, I noticed that you don’t have access to them with just the log
params.param (17.2 KB)

FYI-The parameters can easily be extracted from the log.

Hi,
I am little confused about the parameters and which is automatically set and which is not when using fft and harmonic notch mode =4. Could you see if this process I understood from the ardupilot.org is correct?

Using FTT to drive the harmonic Notch:

  1. To use FFT, a test flight is necessary. For this, I set the following parameters to the following values:

FFT_ENABLE=1
INS_HNTCH_ENABLE=0
INS_LOG_BAT_OPT=0
MOT_HOVER_LEARN=2

From reading discussions here, it seems INS_LOG_BAT_OPT is needed for log analysis’ purposes, to sample before and after filtering, while the MOT_HOVER_LEARN is needed to get MOT_THST_HOVER, and this one will be used to set INS_HNTCH_REF.

With these parameters set, I do the flight test and try to fly my drone in alt hod for at least 30 segs. After that, I analyze the dataflash log, specifically the FTN1.PkAvg. If I understood correctly, when I enable harmonic notch and set the mode to 4, do I need to manually set INS_HNTCH_FREQ or does it happen automatically? Same question for INS_HNTCH_BW

2-Flight with Harmonic Notch Enabled
So this flight, I understand you need to set INS_LOG_BAT_OPT to post filter sampling you can compare what you get from gyros[0] post filter with what you got pre filter.
I enable the harmonic notch and set the mode to 4. Since the guide does not say to turn off the fft through FFT_ENABLE, I should maintain it enabled , right?
Should I use INS_HNTCH_REF=1 or use the value from MOT_HOVER_LEARN?

With all the parameters set, I do another flight test, and then analyze the logs, looking at the gyro[0] using the fft function from ctrl-f

Ok, so I think you are confusing the requirements of the throttle-based notch and the FFT-based notch. The FFT-based notch is designed to be used without any pre-flight setup and if you are not already using the harmonic notch then it is safe to do so. If you are already using the throttle based notch and have autotuned on that basis then there is a chance that the FFT-based notch will produce worse results causing some instability so would be advised to do a side-by-side comparison before switching to the FFT notch.

So if you do not have a harmonic notch of any kind currently enabled for your tune you can set:

FFT_ENABLE = 1
INS_HNTCH_ENABLE = 1
INS_HNTCH_MODE = 4
INS_HNTCH_REF = 1

and that should be sufficient to get going. When you are flying it is also helpful to configure the batch sampler to see where the noise actually is so that you can compare with where the FFT engine thinks the noise is:

INS_LOG_BAT_MASK=7

When you are happy that the FFT is tracking the noise well you can also look at the post-filter noise to see what is getting through to the control loops:

INS_LOG_BAT_OPTS=2

So what are you saying is if I enable those four parameters, the my flight controller will do all the work of finding the noise and setting other parameters automatically. And to verify if the fft is correctly filtering, I check the data coming out of the control loop through batch sampler

That’s the idea, yes. In reality you will probably need to do some parameter tweaking to get the best that is possible out of it.

ok, I am starting to wrap my head around this. So, the parameters that might need some tweaking are going to be the FTT parameters or some INS_HNTCH parameters too?

Most likely FFT. In particular the engine doesn’t do well with lower frequency vibrations using short windows (for instance if you sample at 2Khz and have a window of 32 the lowest possible frequency you can detect is 2000/32 == 62Hz), if you have the CPU power (e.g. H7) then bigger windows will yield better results

Got it. Talking about CPU power, I know a cube black has less power than a H7, but can it withstand having FFT enabled at all times, or is it better to use FFT one time and setup the throttle based notch?

You can use the FFT, but bigger windows will be a problem. You can probably use a window of 64 but I wouldn’t advise going above that.

One doubt just occurred to me. Why a FFT driven dynamic notch filter is considered better than the other options?

If you have access to ESC telemetry then definitely use that for driving the notch. If you have the patience then setup the throttle notch, but be aware that this is correct for a fixed point in time at a particular temperature and is based on a heuristic that estimates RPM - for some copters this gives great results on others not so much. FFT should give you decent results for little pain, but YMMV. Also on quadplanes FFT is good because there are so many different sources of noise.

So throttle based notch uses a specific frequency as reference and other parameters, and then during during flight tries to predict the noise based on these values while FFT is actively sampling data from gyros and separating the frequencies so that it can find the peak and then filter. Is that it?

Yes, exactly that.

There is a lot more detail here: Good Vibrations with Andy Piper - YouTube

Ok, I will see the video. Last question is the dynamic notch filter dynamic because it can also filter the harmonics from the primary frequency or because in case the primary frequency changes, it can track it?

It’s dynamic because it tracks, it’s harmonic because it filters harmonics of the thing it is tracking

OK, I think now it’s the last question. In the example you gave which 62Hz is the lowest frequency it could detect, then that would be the FFT_MINHZ value?

Could be, but the FFT is not going to work well at all in those circumstances - it detects frequencies in buckets, the lowest frequency is also the size of the bucket - so you would only be able to tell frequencies 62Hz apart which is not really enough to be useful. You would instead need to either decrease the sample rate or increase the window size.