Filters in Betaflight

This guide explains the different software filters in Betaflight, which are used to attenuate noise in the system. I will also show you a simple way to configure the filters for better performance.

More Tutorials:

Why Do You Need Software Filters?

Gyro sensor data can be noisy and might require software filters to clean up for better performance. Because noise can exist at any frequency, you need to enable the right filters, and tweak them in order to reduce noise more effectively.

You quad might fly just fine without filters, so you might not need to worry about it. Filters are useful for those really noisy builds, as well as for perfectionist pilots to squeeze every bit of performance in their quads.

Before playing with filters, make sure you are already soft mounting FC or even motors to minimize the amount of physical noise reaching the Gyro sensor. Adding capacitors can also help reduce the amount of electrical noise reaching the gyro.

A Simple Introduction to the Filters in Betaflight

The two main types of filters used in Betaflight are “Lowpass filter” (LPF) and “Notch filter”. There are also other terminology I want to cover related to Betaflight filters.

Lowpass Filter

Lowpass filters allow low frequency signal to pass through, and attenuate high frequency which is mostly just noise and not needed for our flight controllers.

You set a cut-off frequency, and the flight controller will simply reduce signals higher than this frequency. The attenuation curve is a slope, meaning the higher the signal frequency, the more it is attenuated.

Notch Filter

Notch filters are great for rejecting noise at a very specific frequency band. Notch filters are usually more effective for reducing motor noise than LPF, but more manual tuning might be required to determine the bandwidth and center frequency.

Dynamic Filter

Dynamic Filter is a feature you can enable in Betaflight.

These filters usually do a good job keep noise out if you tune and set the filter parameters properly. But there are times when oscillations and noise occur at an unexpected frequency, for example, bent props, or deteriorating motors. This is where Dynamic Filter comes in.

In a nutshell, the dynamic filter is an algorithm that can detect the frequency of the noise, and it can use notch filter to reduce it automatically.

The main downside of Dynamic filter is the increase of CPU load. On F3 flight controllers, you would have to lower your looptime from 8KHz to 4KHz or lower in order to run Dynamic Filter.

The Evolution of Filters in Betaflight

As we know, noise can make our quad oscillates. There are digital filters in Betaflight that remove the motor vibration from the PID loop, so it can focus on the actual movement of the quad.

How does this filter work? Well, the movement of the quad is of low frequency, but the noise from the motors are of higher frequency. So that’s simple right? We could just use a low pass filter to get rid of all the high frequency signal, that includes noise.

Low pass filters is like “turning down the volume of the high frequency signal”, while it definitely helps, it’s not as effective as we want it to be and there are some drawbacks. So notch filters are introduced. The good thing about them is that they can target a specific frequency, i.e. the frequency and harmonics of the motor noise.

Wanna know more about notch filter and low pass filter?

First of all, we have to determine the frequency of motor noise. We could look at Blackbox logs, determine the frequency of the noise, and enter these values in Betaflight. This is known as the static notch filter.

It’s basic and simple, but it’s not ideal as the noise frequency could change during flight – i.e. with motor RPM (throttle) and how badly the prop is bent from crashes. And when you change props, the noise frequency could change too. We don’t have all day to troubleshoot with blackbox!

So later Dynamic Filter was introduced, which are better than static notch filters because Dynamic Filter can determine the noise frequency from gyro data, and use that to tune our notch filters dynamically during flight. There are 3 separate notch filters covering all three axes, X, Y and Z.

However the detected frequency is an average of all four motors, that’s not as effective as we hope it’d be because one motor could be spinning faster or slower than others, hence the noise frequency could be different across all the motors.

This is where RPM Filter excels at, our ESC can just tell the flight controller what the RPM is for each motor. Instead of wasting time and processing power doing all the calculations, we can just get motor RPM without any delay. We can now target each of the motor frequency separately, and cover all 3 axes at the same time, making it a total of 12 notch filters running at the same time.

Although there are now more filters running simultaneously, the processing power requirement is actually lower than Dynamic Filter since we don’t have to “reverse engineer” the noise frequency from gyro data, therefore it’s more efficient than dynamic filter.

Filter Stages in Betaflight

In Betaflight, Gyro data has to go through a series (or stages) of filters before they reach the PID controller. You can choose to turn on or off any particular filter, and to tweak them individually to your requirement.

Raw Gyro Data
Gyro LPF
Gyro LPF 2 (Stage 2)
Dynamic Notch Filter
Gyro Notch 1
Gyro Notch 2
D Term LPF
D Term Notch
PID Controller

I will go into a bit more detail how you should set each of them.

Gyro LPF

You are given the option of PT1, BIQUAD and FIR.

These are the different low pass filter algorithms. In a nutshell, , BIQUAD is better at noise suppression than PT1, but PT1 has less latency than BIQUAD. Don’t worry about FIR because PT1 and BIQUAD are more popular.

You probably want to run PT1 whenever possible, but if you have hot motors, switch back to BIQUAD. Less latency can translate to more responsive quad, and less prop wash oscillations.

The Biquad filter uses two-sample averaging. It takes the PT1 lowpass filter we already have, and cascade with another filter on top of it. Having two filters you get more filtering, and you get a much sharper cutoff curve, but takes longer to complete.

The same applies to both Gyro and D Term LPF.

You can turn the LPF off by setting the frequency to 0, but it’s not recommended unless you know what you are doing.

Stage 2 LPF

The Stage 2 Lowpass filter is called BIQUAD RC + FIR2, which replaced Kalman filter in recent BF version. It’s known to have even lower latency than PT1. If you turn this on you can try turning off Gyro LPF (Stage 1) for maximum performance gain.

Notch Filters

There are two notch filters for the Gyro to target two separate frequencies, you can turn one off, or both off if you want.

Default values are set at 200Hz and 400Hz, these work pretty well on most builds where the motor noises are. But ideally you should really play with blackbox and find out the exact motor noise frequency in your quad.

Dynamic Filter

There is also the Dynamic Filter feature in Betaflight, which can continuously analyze your gyro data to locate signal noise frequency in the 200-400Hz spectrum and get rid of it. The best part is there is no tuning needed.

If you use Dynamic filter, you can turn the other two gyro notch filters off, which we strongly recommend as it’s effective and easy to do.

Before messing with filters…

By setting filters incorrectly can cause your quad to oscillate and your motors to overheat, so leave them at default if you don’t feel like you are ready.

If you do want to continue, make sure you only change one filter setting at a time. Test it by flying it for at least 20-30 seconds after every change, pay attention to noise and oscillations and check motor temperatures right after landing. If your motors are getting noticeably hotter, you need to stop and back up.

You can burn your motors or ESC if not careful.

Simple but Effective Filter Settings

This is a simple filter setup that can get you started playing with them. You might want to tweak them to work better for your particular build.

Steps

  1. Enable “Dyanmic Filter” feature, and disable Gyro Notch filter 1 by setting frequency to 0
  2. Disable Gyro Notch filter 2 (by setting frequency to 0)
  3. Change D term lowpass filter (d_lowpass_type) to PT1, I think this should be fine on most of the quads out there. Anyway, to make sure, fly your quad around for 30 seconds, see if motors are hot
  4. Set Stage 2 LPF to 90 and disable Gyro LPF
  5. If your quad is super clean and well tuned, you might even be able to disable “D term notch filter” too, but it’s very risky so I don’t personally recommend it

I can’t stress it enough, make sure to fly around and check motor temperature after each change. Stop and go back one step if motors are too hot :)

Happy flying.

4 thoughts on “Filters in Betaflight

  1. Tyler

    My motors were getting hot, all I did was lower my d term filters, and Bam cool as could be.. I probably don’t understand this as much as you, but thought I’d share my experience. Good luck

    Reply
  2. Ruben John

    Oscar,

    I face a conundrum. If I do the filter process as described above …when I hover motors are just fine..Barely any heat. But when I start banging my sticks around LOS they start to heat up a LOT !!!! very uncomfortable….
    In fact I can put everything back to normal and the same symptoms exist. I’ve even lowered pids. Checked motor screws and they are fine. This is a brand new build with new props and motors. FC is soft mounted.

    Reply
    1. Oscar Post author

      you shouldn’t just hover but really fly your quad like you normally would. Your situation probably suggest you have oscillation at mid/high throttle. My suggestion is fall back to original filter setting until you can sort out the oscillation, or just leave it be :)

      Reply

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

Are you Robot? *

For prompt technical support, please use our forum IntoFPV.com. I check blog comments weekly.