Update 8/31/2016 – The Betaflight guys have made this process a lot more user friendly by adding in new GUI options in both Betaflight Configurator and Betaflight Blackbox Configurator. Make sure you update your apps to get these features! To learn more, check out our article on configuring Betaflight here!
Update 4/3/2017 – Some of the names of the selection boxes have changed in Blackbox Explorer. I’ve updated this article for these changes.
Introduction to Notch Filters
Proper filtering of data from the gyroscope is critical to having a smooth flying quad. This is because the gyro senses many things besides deviations from the attitude specified by the pilot. The most notable of these is vibrations from the props and motors. The flight controller software needs to know how to detect and ignore these oscillations so that it can focus on keeping the quadcopter flying smoothly in the manner directed by the pilot.
The easiest type of filtering to implement is the low pass filter. This type of filter reduces the effect of vibration above a certain frequency in the data feed that goes into the flight control software. Variations of low pass filters have been implemented in Betaflight for some time now and are also packaged with most gyros – such that they are turned on for use in Cleanflight and other flight control software as well.
The next level of filtering you can add is called a notch filter. This filter targets a very specific band of vibration and greatly reduces (attenuates) the effect of it on your flight control software. The primary benefit of the notch filter is it will further reduce the noise floor of your gyroscope, allowing better dampening. This means that you can tune propwash oscillations out of your quadcopter better than without the notch filter. A secondary benefit of the notch filter is allowing you to run flexible props that have harmonic vibration problems. We ran into just such a prop with the DAL 6045 tri-blades in our DAL review article. YouTube user Robogenesis made a great video showing how airmode works on soft props before and after notch filters were added:
Credit: Robogenesis on YouTube.
Betaflight introduced a configurable notch filter in the Betaflight 3.0 release. Unfortunately it needs to be tuned to be used, so it is left off by default. Assuming you have a dataflash chip on your flight controller, configuring the notch filter on your quad is actually a simple process. This article will show how you can enable and use the filter to improve your flight performance.
When to configure your notch filter
The notch filter will affect your PID tuning. Therefore, to have the best tune, it is best to set-up your notch filter before tuning your quad. That being said, if your quad is un-flyable with lots of vibrations on Betaflight defaults, I’d get that sorted out first. My suggestion, since PIDs really don’t matter for this process, is to just keep halving your P values on all axes until you can cruise around with your quadcopter without any oscillations.
You can add a notch filter onto a tuned quadcopter. You will not have to re-tune anything and it will improve your performance. However, if you do choose to re-tune after adding the notch filter you can probably eek out some additional gains in the P or D values.
You’ll need a few things installed before you can activate your notch filter:
- Betaflight 3.0 on your quadcopter.
- Blackbox logging capability on your quadcopter.
- Betaflight Configurator on your computer (required for Betaflight 3.0 and later)
- Betaflight Blackbox Explorer on you computer (the old Cleanflight Blackbox Explorer will not work!)
You will tune the notch filter by gathering some data via Blackbox. Follow these instructions to get your quad setup so you can gather that data:
- Enable Blackbox if it is not already enabled. This is generally done in the “Configuration” tab.
- Clear out your Blackbox logs in the Blackbox tab.
- Set the Blackbox rate to 1kHz in the Blackbox tab.
- Enable notch filter debugging by going to the CLI tab and typing in the following commands:
Tuning the Notch Filter
Once you have your Blackbox logger set-up per above, go out and fly. You only really need about a minute of flight time, but more can help. Try to get a variety of flight conditions, including an extended period of hovering, idling on the ground and some tight turns and flips/rolls if you are comfortable with them. Now, unplug the battery and plug the quad back into your computer. Follow these instructions to get your notch filter going:
- Download the Blackbox logs from your quad (Blackbox tab).
- Launch the Betaflight Blackbox Explorer and open the saved log.
- Click “Graph setup” in the lower right hand corner of Blackbox Explorer.
- Clear out the default fields by pressing all of the “Remove” buttons in the resulting dialog until there is nothing left.
- Click “Add Graph” and pick “Custom Graph”.
- Click “Add Field” and pick “Debug Notch”:
- Click “Save Changes” to add the fields to your graph. For those that are curious, these fields are displaying the data coming from your gyro before any filtering is applied.
- Click the “View Spectrum” icon adjacent to “gyro_raw[pitch]” in the graph legend (right pane). This will cause a spectral analysis chart to show up.
Click the icon circled in red. The text has changed since this screenshot was taken but should read “gyro_raw[pitch]”.
- Expand the spectral chart to fill the full screen by pressing the expand button. You will see a chart like this:
You don’t need to understand this chart or know how to read it. The answer you are looking for is already processed by the app and displayed after “Max motor noise”. In this case, the quad’s pitch axis is at 432Hz. You should note that there are also noise bumps at ~200Hz and 300Hz.
For those that are curious: What you are looking at is the magnitude of all oscillations seen by your gyro. The bumps at 200Hz, 300Hz, 400Hz are harmonics of the vibration caused by either the motor or props of this quadcopter. They are what we are looking to eliminate with the notch filter. Ideally you want to see very small or non-existent bumps on this chart past 100Hz. This pitch trace actually looks pretty good.
- Lets look at the roll axis for this quadcopter. Click on the spectrum button for gyro_preNotch[roll]:
Now that’s a dirty trace! There is a ton of noise here between 190Hz-500Hz. In this trace you see the max noise was detected at 297Hz.
- Now that you’ve looked at the graphs for your quad, it is time to decide how to set up your notch filter. You want to set it at a point that has the largest combined noise between the pitch and roll axes. In my quad, that corresponds to 297Hz – which has the highest noise in the roll axis and has a sizeable bump in the pitch axis too. If this confuses you, just pick the “Max motor noise” figure on the noisiest axis.
- Go back into Betaflight configurator and launch the PID Tuning tab.
- Click “Filter Settings”
- Enter the number corresponding to your max noise into the “Gyro Notch Filter Frequency (Hz)” field:
That’s technically it. You should have a tuned notch filter set-up on your quad. Go out and fly to try it out! Or, you can test that it worked with the following instructions.
Testing the Notch Filter
Alright now that you applied the notch filter, perhaps you want to see what – if anything – it is doing. No problem, you’ll just have to basically repeat the whole process from above:
- Clear out your quadcopter’s Blackbox logs.
- Go out and fly some more. Do the same routine you did last time.
- Hook the quad back up to your computer and download the logs.
- Open up Betaflight Blackbox Explorer and load the logs.
- Set-up the debug graph like you did last time.
- Check out the spectral analysis for each value. Remember, debug and debug are the raw values, while debug and debug are the corresponding values with the notch filter applied. If you see any improvement from 0->1 or 2->3, your notch filter is working!
I only recently applied the notch filter to my quad after a couple of weeks of flying Betaflight 3.0. The difference for my quad was hugely noticeable. Betaflight 3.0 already had the most precise yaw control I’ve ever flown with – this quad now has the best propwash handling I have ever flown with as well. It is an absolute pleasure to fly. Given how easy this process is, I can’t recommend it enough.
Here are my traces with the notch filter applied so you can see how big of a difference it makes:
That’s a huge difference in noise! Happy flying gents!
Ready to setup more awesome software features? Check out our quadcopter software setup guide here!
All of this information and more was gleaned from the Betaflight 3.0 release notes: