Harmonic notch support (ESC, Throttle, FFT)

I’ve been going back and forth on the wiki and this topic and I am confused by some of the instructions. Can someone please clarify some things for me?

When you set the FFT engine on by doing INS_HNTCH_MODE,4 you are essentially doing a real-time in-flight FFT of the gyro and accels. There is an algorithm that tracks the frequency bin which has the highest energy per sweep and saves it as FTN1.PkAVG. However, this value can only be between FFT_MINHZ and FFT_MAXHZ even though the sampling rate is 1 kHz. If for some reason the algorithm fails to track the right frequencies, one can manually plot the FFT using Mission Planner and/or MAVExplorer and set the filter frequencies themselves. They would have to choose the lowest frequency bin which shows a spike and set INS_HNTCH_FREQ to that. Set INS_HNTCH_BW to be the calculated amount from a test flight and the harmonic filter would take care of that and subsequent harmonics.

Is this all correct? If so, why should INS_HNTCH_FREQ ever be set to FFT_MINHZ like instructed in the wiki here? It should always be like so:


Also, are the power spectral density plots in log scale or linear scale?

With the learned values from the FFT you have two options:

  1. INS_HNTCH_FREQ = FFT_FREQ_HOVER, INS_HNTCH_REF = MOT_THST_HOVER in which case the lowest frequency the notch will go to is FFT_FREQ_HOVER so in dynamic flight where you throttle goes below the hover throttle the notch won’t cover the motor rpms.
  2. INS_HNTCH_FREQ = FFT_MINHZ, INS_HNTCH_REF = FFT_THR_REF in which case the lowest frequency the notch will go to is FFT_MINHZ and in dynamic flight the notch will cover the motor rpms.

The reason for using INS_HNTCH_MODE=4 is because the throttle-based notch is an approximation based on our understanding of the physics of the vehicle. Incorrect MOT_THST_EXPO, flying in different conditions to testing. misconfigured hover throttle etc will all make the approximation worse. The FFT by contrast is tracking the actual noise - so where it works it is generally more accurate.

PSD plots from mavfft_isb.py are log by default and can be made linear through the command line. I think mission planner is now using log scale plots.

1 Like

You now have a choice by checking/unchecking the Magnitude box before loading a file. Default (unchecked) is log scale.
Magnitude

Cheers, Andy. If you do INS_HNTCH_FREQ = FFT_MINHZ, INS_HNTCH_REF = FFT_THR_REF, you are also doing FFT_ENABLE,0 which disables FFT. Does this mean that the dynamic notch is still working and modifying its value in each flight? It sounds like that is the preferable option.

Some more questions about the filters themselves:

  1. What amplitude value should we be targeting post-filtering? From your responses in this thread it seems like the filters that Giorgio and Angus implemented didn’t work, but looking at the before and after plots there is significant attenuation in the power spectral densities. See for example:

If the FFTs are in dB scales, then is a few tenths of a dB even significant? For example, 0.2 – 0.4 dB is just 4.7 - 9.6% higher than the noise floor.

  1. Let’s say the fundamental frequency is at 80 Hz with a 40 Hz filter bandwidth. With INS_HNTCH_HMNCS,3 you are attenuating 40*4 = 160 Hz of the 500 Hz bandwidth. Isn’t this dangerous since ~1/3rd of the gyro response is being suppressed?

I don’t see this update yet but can you ensure the units on the Y-axis display correctly?

Update to latest Beta and you will. What’s “correctly”? You are making comparative measurements, pick the scale that best suits.
Same Log different scaling:


I was merely suggesting that the labels on the Y-axis display if the scaling is linear or logarithmic to avoid confusion.

This is all in the wiki. You can have the FFT enabled and still use the throttle notch. You must have it enabled if you want it to drive the notch

I can’t tell you for MP. For mavfft_isb -10db or below is acceptable

No. The Q factor is maintained which is what matters

Sorry, but in my example I meant it to be INS_HNTCH_HMNCS,7 so the fundamental and three harmonics will be attenuated. So there would be a filter at 80, 160, 240, and 320 Hz center frequencies… is that correct? If the Q-factor is maintained doesn’t that mean that everything between 60 and 100 Hz and 120 and 400 Hz would be in the filter stop-band for a total of 320 Hz? Sorry if I have missed something.

First harmonic is the fundamental, so 7 gives you 3 filters at 80, 160 and 240.

The bandwidth is supposed to represent the 3db points, but what you find is that the level of significant attenuation is much narrower than that. If you google around you will see the shape.

Does it not work properly with an auto-tuned copter? My F450 started twitching after I enabled it. These were the settings on it:

FFT_ENABLE,1
INS_HNTCH_MODE,4
INS_HNTCH_FREQ,FFT_MINHZ(80 for this drone)
INS_HNTCH_REF,FFT_THR_REF(0.045 in this case)
INS_HNTCH_OPTS,2

From the before and after data I could see that there was attenuation in the FFT but it made the drone unstable. Log here.
On my T960 with Cube Orange I can’t get it to track the peaks:


Is it because the first two harmonics are very close in amplitude?
image
INS_HNTCH_FREQ was showing up as 80 (default) and the detected bandwidth was default too (40). Params:

INS_HNTCH_REF,1
FFT_MINHZ,40
FFT_MAXHZ,250
FFT_WINDOW_SIZE,256

Log here.

If you use MODE 4 you need to set REF to 1

Thank you. I changed INS_HNTCH_REF to 1 and tried again. It was still twitching. Realized that INS_HNTCH_BW was set to 125 from a previous run and changed that down to 40 and tried again. That fixed the twitching, however the filter effects were minimal from looking at the FFT plots.

Andy: surely you can’t just arbitrarily increase the filter bandwidth even if it is a notch filter, right? There has to be some trade-off somewhere.

Can you send me a log?

Here it is.

FFT is tracking quite well. I think you might do better to set FFT_HMNC_PEAK = 4 to only track X which appears to be less noisy

The more you increase the bandwidth the less the attenuation at the centre becomes

Hello @andyp1per ,

Thank you for keeping the thread alive and also for making the “Good Vibrations” Video !

I had a couple of questions if you have the time :

  1. after Enabling the FFT, setting min and max and give it a hover for the logs, what exactly do we compare to what in order to see if enabling the HNOTCH and setting it to 4 is safe ?

  2. After doing a hover with HNTCH on 4 how do we know we have the correct settings dialed in ? e.g with no HNTCH my first peak of FFT GYRO[0] was 21db~
    after enabling the HNTCH that goes down to .015~ (and i lose the rest of the peaks) . Lowering the INS_HNTCH_FREQ the first peak goes to .0105~ . Are we supposed to make it as low as possible ?

  3. How do you find the correct FFT_SNR_REF value?

  4. I would be very grateful if you could have a look at my logs and tell me if something needs correction or it could be better with the FFT & INS_HNTCH settings .
    i have 3 logs one with NO HNTCH, and two with HNTCH 4 but different INS_HNTCH_FREQ & INS_HNTCH_BW, my hexaX is a 1200mm wheelspan with 20.2" props.
    logsFFT - Google Drive

Best wishes!

  • Look at FTN1.PkAvg in the first instance to see if this tracks the noise peak in the FFT. You can also look at FTN2.PkX/Y to see tracking of individual noise peaks.

  • below -10db is a good thing to aim for

  • Have a look at FTN1.SnX/Y and see whether this stays above what you have configured in FFT_SNR_REF

Hello,

Thank you for your swift reply ,

  1. How do i tell if its tracking the noise peak? i see an FFT peak at 50~, 100~, 150~ and the PkAvg goes from 45~to 105~. the image on https://ardupilot.org/copter/_images/imu-in-flight-fft.png is completely different from mine :


    Checking the FTN2 PkX/Y/Z i see the noise jumping from 50~ to 100~hz

  2. So a value of 25 on FFT_SNR_REF is ok ? what are the consequences of having that lower e.g. 15

  3. logsFFT - Google Drive how do i tell if in the last log (with FFT notch enabled), everything is ok ? and how can i make it better ?

Thank you again,
Best!

X is tracking well - set

INS_HNTCH_OPTS=2
FFT_HMNC_PEAK=4

Thanks once more ,

will try that !