Dynamic Notch filter can't remove accelerometer noise

I’ve spent a lot of time looking at the ARDUPILOT website about notch filters, but there are a few things I don’t understand. It took me a lot of time to post this, I hope someone who understands can guide me, because it really took a lot of time to figure out this filter.

The following is the step by step I follow the wiki instructions to set the notch filter. Finally, the noise of the gyro can be filtered out, but the noise of the accelerometer cannot be filtered out. The noise of the accelerometer and the noise of the gyro are basically the same frequency. see if i made a mistake in the follow step.

  1. Flight purpose:Measuring Vibration with IMU Batch Sampler
    Pre-Flight Setup:
    INS_LOG_BAT_OPT = 0 to do pre-filter 1KHz sampling
    INS_LOG_BAT_MASK =1 to collect data from the first IMU
    LOG_BITMASK’s IMU_RAW bit must not be checked.

    Flight and Post-Flight Analysis
    Perform a regular flight (not just a gentle hover) of at least 30 seconds
    The flight video is as follows:
    VID 20220927 172956 - YouTube

download the dataflash logs:

Post-Flight Analysis:
The spectrum of the gyroscope and accelerometer can be seen, in which there are two
peaks near 136HZ, which is obviously the vibration caused by the rotation of the

  1. Flight purpose:In-Flight FFT Based Harmonic Notch Setup
    FFT_ENABLE = 1 reboot
    Initial Flight and Post-Flight Analysis,without the harmonic notch being enabled.
    Perform a hover flight of at least 30s in altitude hold
    VID 20220927 175038 - YouTube
    download the dataflash logs : https://drive.google.com/file/d/1nDYAwxkKa8P7O81bdDRLUg-Q1iUw_s5a/view?usp=sharing
    Graph the log element FTN1.PkAvg which represents the FFT’s energy-weighted estimate of the average noise frequency for roll and pitch.

Setting up the FFT parameters can be done automatically using the RCx_OPTION auxiliary function “162” on a transmitter switch. Set the function to a switch on the transmitter. Hover the vehicle, switch it on (high) for 30 seconds, switch back low and land. The parameters will have been setup and switch function removed.
RC12_OPTION=162 ,switch is SA in my radio
You hear FLAP UP and down actually trigger FFT, this sound has not been adjusted in my radio.
Perform a hover flight of at least 30s in Qloiter mode:

Check FFT_parameters in the parameters tree:

download the dataflash logs : https://drive.google.com/file/d/14dziHTY06TtwbYoRDSEzzd6tNdvqOTz9/view?usp=sharing

Fast Fourier Transform the flight record:

With INS_LOG_BAT_MASK still set to = 1 to collect data from the first IMU:Set INS**_LOG_BAT_OPT = 2** to capture post-filter gyro data

Flight at least 30s in Qloiter mode :

download the dataflash logs:
Graph the log frequency spectrum to check Notch Filter Effectiveness:

From the spectrum analysis, it can be seen that the gyro noise has been eliminated, but there are still two peaks on the accelerometer spectrum。Why is this so?

How to understand this passage: Set INS_HNTCH_ENABLE and/or INS_HNTC2_ENABLE = 1,
I have tried, if only set INS_HNTCH_ENABLE=1, the notch filter does not work,
do I have to set INS_HNTC2_ENABLE = 1, will this increase the CPU load?

As you can see from my video, the plane’s heading has been swaying to the left and right. Why do I always want to filter out the noise of the gyroscope and accelerometer, because I want to use the script to automatically adjust the PID later.

FC:F765 wing, firmware:4.2.3

Simply because the Dynamic Notch Filter is not active on the accelerometers, gyro’s only.

Thank you for your reply, shouldn’t the noise from the accelerometer be filtered out?

No, not by the Dynamic Notch Filter. Gyro’s only. So the answer to your post Title is “correct”.

So, does the noise of the accelerometer need to be filtered out, and in what way?

1 Like

As with Copter- INS_ACCEL_FILTER

Perhaps start another post that is concise to the issue you are seeing.

The short answer is:
The gyros are notch filtered because they need to. It increases stability and makes the motors heat up less.

The accelerometers are not filtered by the notch filter because the EKF filter does a better job when using the unfiltered accelerometers data.

It’s not a bug. It’s a feature. The accelerometers are not notch filtered.

This is a 4.3 feature, so if you are using this (great if you are - you are the first person to try it other than me!) we should move this post to 4.3

Thank you for your explanations, it made me a lot clearer.

I used the IN-FLIGHT FFT notch filter to automatically filter out the gyro noise, but I tested it several times this morning, and the effect is not very good. There is still a peak at 155HZ that cannot be filtered out. But the amplitude is much lower。

I looked at the FFT parameters and found that INS_HNTCH_FREQ does not follow FFT_FREQ_HOVER. From the data without the notch filter, it can be seen that the spectrum of the gyro has two peaks, one with a center frequency around 131HZ and the other around 155HZ.

In the case of filtering with IN-FLIGHT FFT, the center frequency of the filter is automatically matched. Is it because only one center frequency can be set, so the IN-FLIGHT FFT cannot completely filter out the double peaks in the gyro spectrum?. Do you have any good suggestions?

In addition, I checked the forum, some people said that IN-FLIGHT FFT filtering will cause too much CPU load and may crash, I plan to change to Harmonic Notch Throttle Configuration Using Data from an In-Flight FFT, but the official documentation is not very good clear.

First the official document says: Land and disarm. The learned value for INS_HNTCH_FREQ and/or INS_HNTC2_FREQ at hover will be in FFT_FREQ_HOVER and the learned value for INS_HNTCH_REF to scale FFT_MINHZ to the learned hover frequency will be in FFT_THR_REF. The values ​​are not transferred automatically to the harmonic notch so you should set them based on the learned values.
For this passage, my understanding is INS_HNTCH_FREQ=FFT_FREQ_HOVER, but the official document says Set INS_HNTCH_FREQ and/or INS_HNTC2_FREQ = FFT_MINHZ
And here it says:
Alternatively, if you wish the hover frequency to be the lowest value for the harmonic notch:
Set FFT_ENABLE = 0 to disable the FFT engine.
Set INS_HNTCH_MODE and/or INS_HNTC2_MODE = 1 to use the throttle-based dynamic harmonic notch.
How to set INS_HNTCH_FREQ ? :joy:

There are also INS_HNTCH_REF and FFT_THR_REF parameters. I have read the official document 10 times, but I can’t understand it. What does this parameter mean?

The official documentation is not detailed enough about notch filters, especially for people who don’t have much electronics experience.

Fortunately, I found your previous introduction:

I sorted out the principle of notch filter filtering, Hope it’s easier to understand,if it is wrong, please correct me

  1. IN-FLIGHT FFT notch filtering,simplest method
    First set to allow IN-FLIGHT FFT by FFT_ENABLE=1,then Then set the maximum (FFT_MAXHZ )and minimum frequencies( FFT_MINHZ )and INS_HNTCH_ENABLE=1 ,INS_HNTCH_MODE=4,
    With this setup, IN-FLIGHT will scan the peaks that appear in the spectrum from low to high frequencies,in my case,there two peak in the spectrum,let’s call peak1 and peak2.It only determines the highest peak, and then places a harmonic filter to filter out this peak. The center frequency of peak1 is 130hz, so the peaks at 130hz and 2*130hz will be filtered out. peak2 is lower than peak1, so it will be ignored by FFT, and FFT can only place one harmonic notch filter, so PEAK2 still exists.

So how to filter out PEAK2? I think one more static notch filter should be placed at 155Hz, which can be set individually by setting INS_NOTCH.

I haven’t tested if this works, or if there is a better way.

I have searched a lot on Google, and have a simple understanding of the parameter INS_HNTCH_REF. The gyro noise is mainly caused by the rotation of the propeller. When the throttle is different, the peak position displayed on the gyro spectrum will move. For example, if you increase the throttle, the peak may go to The high frequency direction, so the center frequency of the notch filter we set is only an approximate value. In fact, during the flight, we want the center frequency of the notch filter to move with the peak to filter out the peak, so how do we Know how to let the notch filter know how to move it? This can be used to tell the notch filter to follow the spikes via the parameter INS_HNTCH_REF,

As for how this parameter (INS_HNTCH_REF) works, I don’t know yet, I hope someone who knows can explain it.

There is also how to correctly obtain the parameter value of INS_HNTCH_REF, because the value obtained through IN-FLIGHT FFT is quite different from the value obtained by hovering the throttle?Which method is better

If you set INS_HNTCH_OPTS=2 the FFT engine will put a notch on each peak it finds (up to a maximum of 3).

If you want to use the throttle notch then you either need to set INS_HNTCH_FREQ=FFT_MINHZ, INS_HNTCH_REF=FFT_THR_REF or set INS_HNTCH_FREQ=FFT_FREQ_HOVER, INS_HNTCH_REF= MOT_THST_HOVER - you should not do both

You said INS_HNTCH_OPTS=2, is it dynamic notch? Shouldn’t it be double notch? However, I just tested three filtering methods, and it is true that setting INS_HNTCH_OPTS=2 has the best filtering effect, but there are still two small spikes. The effect has been achieved. Is there any improvement to achieve better results?

INS_HNTCH_OPTS is a bitmask
So double-notch (bit 0) is the value 1
Dynamic harmonic (bit 1) is the value 2

Dynamic harmonic means a notch per peak

Although there are still two small spikes, the effect is good. I wanted to use a static notch filter to filter out these two small spikes, but I found that there is no static filter parameter. Maybe the new version has canceled it. In MP static Filters are also grayed out there and cannot be selected.

Thank you for all of youranswers, I have learned a lot. This is my first time to tune VOTL, and it is still difficult to adjust Y3. I will open a new topic on how to manually tune y3. I try to put the parameters into the flight video every time I tune. , so that it is convenient for everyone to make suggestions, and it is also easier for future people to learn how to adjust PID

You can use HNTC2 with a MODE of 0 and REF of 1 to get a static notch