Betaflight Filtering 101

There are a lot of resources out there regarding PID tuning, but filtering is a topic closely related to tuning and a source of confusion for many. This article is intended to be a basic introduction to the core concepts of filtering.

This article is written by guest author, Steve Wright from SupaflyFPV.com

Default filter settings in Betaflight are set to be adequate to do the job. But sometimes with particular setups there can be issues, and there are some tips at the end to help these circumstances.

Betaflight is also conservatively filtered in order to be safe for a wide variety of setups, but for maximum performance, filtering can often be reduced. Unfortunately it is never 100% clear if a particular setup can take a high performance, low filtering setup, which is why when I offer custom PID and filter tuning with my frames at SupaflyFPV.com, I also provide a recommended build.

This guide should give enough info for you to start experimenting with filtering on your setup, and although technical, it’s also one of the great things about this hobby to learn about the tech behind it, so I hope you enjoy this filtering 101 introduction…

The MEMS Gyroscope

It is easy to take for granted that our flight controller has a digital chip on there called the gyro that senses movement and that’s that. But that unassuming black box contains tiny electro-mechanical parts – hence the name – MEMS stands for ‘Micro Electro Mechanical System’.

Inside this surface mount package are a series of nano scale resonating forks, a bit like piano tuning forks. A network of these forks are across the 3 different axes of pitch roll and yaw, and they move (the mechanical part) causing tiny fluctuations of voltage (electro part).

The tiny voltage fluctuations are analogue waves, and need to be ‘sampled’ into digital information to be processed in the flight controller main processing unit. So when we talk about ‘8k gyro’, that is the sampling rate of 8000 snapshots per second happening inside the gyro to translate the analogue voltage waves into digital data that can be read and processed by the flight controller and flight firmware (eg Betaflight).

Noise

Noise is a term we hear coming up often, but what exactly is it? When we hear the term ‘noise’, the first thought might be of audible noise we hear with our ears. We might say an environment is ‘noisy’ if there is distracting background noise confusing what we want to hear.

The gyro and PID controller have the same problem. The gyros on our flight controllers find themselves in a noisy environment, attached to frames with four motors driving props at a high RPM and moving through the air at high speed. So in a quadcopter the noise falls into two basic categories: motor vibration noise, and general broadband noise.

The PID Controller

The PID controller is the control system that flight firmware use to correct the position of the quadcopter according to your stick or ‘the setpoint’. It contains a series of parameters: P, the I and D terms we all know and love.

This system works best when fed clear and clean information relevant to the quadcopter movement. Do you prefer to drive through London with a screaming child and angry partner in the car? A lot of noise confuses the control system and can cause problems such as oscillations or hot/burned motors.

The D term of a PID controller has a particularly important relationship to noise in the quadcopter. It is a process which smooths fast movements, but the derivative (D) calculation of the PID controller significantly amplifies the noise in the signal. This means that the gyro noise is substantially amplified by the d term, and is why we have filtering in two places – the gyro – and the D term.

Filtering

Filtering is the name of the process where we reduce the unwanted noise from the gyro signal. Did you ever filter a solution in Chemistry at school, where you got a clean liquid and a crappy residue on the filter paper? This is the same thing, filtering the rubbish out of the gyro signal.

But what part of the gyro signal do we want to keep and what can we get rid of? Quadcopter movement speeds are in the range of 0 – 30Hz, and above 30Hz to around 80Hz we have propwash movements where the quad wobbles fast into turbulent air. Although technically it is the ‘rate of change of rotation’ that is being measured, an easy way to visualise the Hz frequency range is that 1 Hz is one rotation in one second. So this 0 – 80Hz information relating to the movement of the quadcopter is valuable to the PID controller, and we want to keep it and preferably leave it untouched with little or no filtering applied.

In the above image made using PID Toolbox (Credit Brian White) you can see the bright ‘motor band’ which increases in frequency as the motor RPM increases, and surrounding that there is also other patches of general broadband noise.

Low Pass Filters

As the previous graph shows – the gyro signal contains information all the way from 0Hz to 1000Hz but we are only interested in the 0-80Hz range because that is actual quadcopter movement which the PID controller needs to know. Thus we need a filtering solution to allow the low frequencies to pass through to the PID controller, whilst reducing the high frequencies, and for this we can use a ‘Low Pass’ filter.

A low pass filter reduces (attenuates) the high frequencies and its position is set by the ‘cutoff’ point which is close to the corner of the filter. This important ‘cutoff frequency’ point is the number you see in flight control firmware (usually in Hz).

An important consideration for low pass filters is that they ‘roll off’ or ‘attenuate’ the high frequencies, it is not a harsh cut but it increasingly reduces the high frequencies the lower the cutoff number.

A common mistake people make is to see there is noise eg at 200Hz, and then set a low pass filter to 200Hz. This will make almost no difference to the noise problem because the noise will be reduced above 200Hz but not really impact the noise where it is most needed. If you have noise at 200Hz, you would want to set a low pass lower than 200Hz all the way down to perhaps 80Hz, depending on the degree of noise and how much filtering you wish to apply.

A fundamental aspect of low pass filters is: the lower the cutoff number, the more filtering you are doing.

The reason why we don’t just set low pass filters with a very steep cut to get rid of everything above 80Hz is that the more filtering you do, the more ‘latency’ or delay it causes to the data flow.

In the real world you have to find a balance between noise attenuation and latency. The delay caused by filtering is in the milliseconds region but the issue is not that we could feel it on the sticks, but that delay causes the PID controller system to be less efficient at controlling the quad because it will be trying to react to events further and further in the past, the more latency there is in the system.

Types of Low Pass filters

In Betaflight there are two types of low pass filter – PT1 and the Biquad. In FlightOne (previously Raceflight) the PT1 is called ‘Frequency’ filter and the biquad is the biquad.

The PT1 is a gentle filter curve (known as first order, or single pole) which gives less delay and so is regarded to give better performance, but it does not filter the noise as heavily as the biquad. The biquad is steeper creating more filtering but also more latency. Flight firmware generally use a combination of filters and sometimes you can rely on PT1 and sometimes you will need to use biquad filters if you need stronger filtering.

The above image shows the low pass filter section of the Betaflight configurator (part of the PID Tuning area). Under the filter settings are some filter curves from UAV Tech ‘Filter Calc’ (Credit Mark Spatz) to demonstrate the filter shapes with some extra info.

Notch Filters

Another common filter used in flight firmware is a notch filter. Just as it sounds, a notch carves out a notch of the data. With this type of filter you set the centre point set to the noise peak – because the notch is designed to ‘notch out’ the data at this point.

It was common in the past to use notch filters set to the position of ‘maximum’ noise which could be seen in the blackbox analysis using a ‘static’ notch because it sits at the set frequency position at all times.

However since Betaflight 3.1 there is the option of a dynamic notch filter called the ‘Dynamic Filter’ in the Configuration tab. This is a highly effective notch filter now on by default in Betaflight which tracks the motor noise peak and moves up and down in frequency according to a realtime analysis made by FFT

An advantage of notch filters is they have less latency than low pass filters, whilst giving a very strong reduction in noise and the centre frequency (can be seen visually by the depth of the notch). This makes them a very effective way to reduce noise, and the dynamic notch is so good that in fact in my Supafly tunes I am able to reduce or eliminate other low pass filtering which significantly increases the performance of the quadcopter.

D Term Filtering

As mentioned above, D term calculation in the PID controller significantly increases the noise levels from the gyro, and sending unfiltered D term to the motors would quickly cause them to get very hot and most likely get smoked.

The image above shows spectrographs from PID Toolbox with the D term where its noise has been amplified.

Compare the left spectrograph image with the first gyro noise image above and it is clear how much the noise is amplified, and why it requires filtering. You can also see the result of the filtered D term above, and in that case there is a lot of signal that is mostly in the 0Hz to 80Hz range as it should be with the frequencies above now totally reduced by the low pass filtering.

The amount of filtering you have on D term impacts the amount of D gain you can use in your tuning (the D parameter in the Betaflight configurator PID tab). There is currently a debate about whether it is better to have less filtering, and less D gain – or more filtering and more D gain to counteract propwash but in my experience it is always a balance.

One thing is clear though – too much D gain and too little filtering will result in hot or even smoked motors. Generally a Biquad filter is the minimum sensible amount of filtering with the frequency around 100Hz down to 80Hz if you have hot motors…

Filtering In the Real World

Let’s now look at a few real world scenarios that can arise and how filtering could help.

Hot Motors

The general consensus is warm motors are fine, but when it becomes too hot to touch, that is a problem. Hot motors can be a sign that a lot of noise is getting to the motors and they are trying to respond to the information so fast it creates heat.

This could be for a number of reasons such as a banged up, unbalanced or old motors, and ultimately I would recommend mechanically smooth and clean setups, but filtering can fix issues before you have to pay up for new gear.

Considering that the D term calculation amplifies the noise so much, I would recommend starting with the dterm filtering. The easiest way to reduce motor heat is to lower the dterm low pass filter cutoffs in 20Hz steps. Remember that you want to avoid going lower than 80Hz, so if your starting settings have two dterm filters once you have one in the region of 100Hz you can start with the higher filter to bring that down if you still have hot motors again in 20Hz steps.

Hover test to check the temp each time. If one of the d term filters is set to PT1 you can also change it to a Biquad, which will also increase the filtering. It is better to have less filtering and a clean quality setup, but increasing filtering doesn’t have a ‘dramatic’ impact in performance, so if the main goal is to keep flying and avoid shelling out for more gear, don’t worry too much about increasing the filtering to fix issues.

Motor Oscillations

Motors should run smoothly and consistently, but if the sound has a sort of wobble in pitch or the quad is even subtly vibrating/shaking then you may have a behaviour called ‘oscillations’ which basically means there is a positive feedback loop in the PID control system oscillating back and forth at a high rate.

This can originate from PID tuning, and it is not uncommon for people to embark on a vigilante mission to try to tune their quadcopter when they don’t fully understand the impact of the P or D term causing oscillations based on tuning, so first check that you haven’t increased either of these tuning parameters beyond where they should be on all axes.

The quickest way to establish if it is PID tuning is by returning to default tune. If on default you still have oscillations, it is probably caused by old/bashed up motor vibration (mechanical noise) or electrical noise from dodgy ESC (electrical noise). I always recommend running a low ESR capacitor to smooth electrical activity, but you can also use filters in the flight firmware to reduce the impact of motor vibrations on the PID controller.

In this case you would want to increase filtering on the gyro by reducing the low pass filters in 20Hz steps but stopping at the 80Hz point. It may also help to reduce the d term filtering so I recommend starting by reducing one gyro low pass filter, then turning to the d term low pass filter and reducing the lower filter up to 80Hz as necessary.

If you do not notice a change when you have reduced gyro filtering up to 80Hz and switched filters to biquads, then it might be you have an unreasonably noisy electrical system, or your motors are beyond redemption… a quick note – always check you don’t have anything pressing/stressing the flight controller if you have mid throttle oscillations…

Reducing Filtering for Performance

Reducing filtering increases the performance in Betaflight, due to reduced latency. I have also found in my own testing that the flight feel improves with less filtering. More filtering results in a stiffer stick feel, with less resulting in a smoother flowing flight characteristic.

In fact, I believe that, plus conservative PIDs accounts for a large amount of the difference people feel when they test other flight firmware. Betaflight is set up conservatively with a lot more filtering than other flight firmware and this is for good reason – the user base is around 250,000 – far more than any other flight firmware and so it serves a huge variety of setups.

The dynamic notch in Betaflight is highly effective, and in reality, very often the stock Betaflight filtering can be reduced as a result. Reducing filtering means preferably removing low pass filters so you only have one PT1 or no low pass filters on the gyro, and either two PT1 filters on the dterm or a single Biquad.

However, this should be done carefully, because it can result in hot or smoked motors. Take care when doing this, and first hover test then check the motors to see if they are getting hot. Watch out for grinding sounds, or resonance coming from the motors if you reduce the filtering substantially…..If you don’t want to take any chances, but experience a high performance tune, you are welcome to try a Supafly build. The feedback I get from customers on the website are genuine reactions to the difference in feel and performance of a well tuned and properly filtered build…

I personally feel that a properly tuned quadcopter shouldn’t be limited to those people who have been flying for the years it takes to genuinely understand tuning. This is why I feel strongly about helping others experience this because in my opinion it is way better than flying stock and results in a more confidence, better flying and more overall enjoyment of the hobby. One way is by making my own frames that do the job well with recommended build and tuning, but I hope this article with it’s basic overview can encourage others to explore filtering options whatever flight firmware they are using.

Conclusions

In this article we have had a basic introduction into filtering. We learned about the types of noise from the gyro, and about the different types of filters used to control this noise. This info is essential basics, and in the next article we can explore the latest Betaflight 4 filter developments and how to get the best out of them…Thanks for reading if you got this far and I hope you found the article useful and informative.

6 thoughts on “Betaflight Filtering 101

  1. Mark Spatz

    Lower values are MORE filter for Lowpass Filters. For Notch filters, wider values are MORE filtering (200 ctr and 100 cutoff is more filtering then 200 center and 150 cutoff). In all cases, more filtering is more latency; know as gyro signal Phase Delay, which is bad. There is no free lunch. So it is all about striking the right balance. You want just enough filtering for your rig but not an ounce more. Of course, if your rig has less raw mechanical/electrical vibration, you can reduce filtering. If it has more, you need to increase filtering. So focus on keeping a clean mechanical is key for good performance cause you don’t need to drown your setup with too much filtering to try to cover up. That said, you want to tune filters on reasonably used props so you have a good balance.

    If you have to add filtering above what is in the BF default, that is a sign that you have mechanical/electrical issues you should focus upon vs. adding even more filtering.

    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.