FPV Quadcopter: Filtering in Betaflight







(Betaflight 4.1, I haven't shot it on new settings yet)



Last article - From Ground to FPV Quadrocopter: Introduction



The other day, I decided to upgrade to Betaflight 4.2 and everyone around me is advising to enable filtering with two-way DShot. By the way, it was in 4.1.



First, let's understand a little what filtering is and why it is needed.

By default, Betaflight provides general filtering settings suitable for most models. But to achieve the best performance, filtering can be adjusted differently, as it may be overkill or not enough for a battered drone.



MEMS Gyroscope



Each quadcopter has an FC - Flight Controller, which is essentially a brain. These controllers also have a digital chip, which is often called gyro - gyroscope. It is a sensor that senses movement. It contains a small electro-mechanical device called MEMS (Micro Electro Mechanical System).



There are mechanically resonating "plugs" inside this device. These plugs are located on all three axes (pitch, roll, yaw) and moving (mechanical part) create voltage fluctuations (electrical part).







Voltage fluctuations (fluctuations) are in fact analog waves that are converted into digital information for processing by the flight controller. When we say 8k gyro, it means that 8000 times per second, the analog signal is converted to digital and processed by the controller, the firmware, in this case Betaflight.



Noise



Noise is a term we hear a lot, but what is it? As a rule, we immediately imagine sound noise or noisy environment in the next 23-storey anthill.



The gyroscope and PID controller face a similar problem. Since the gyroscope is located on the flight controller, which is attached to the frame, it experiences noise. Noise can come from: motors, propellers, wind speed, general frame noise, electronics, etc.



PID Controller







The PID Controller is a system that adjusts the position of the quadcopter according to the sticks (your control) or a given position (well, whatever it might be). The PID is tuned by 3 parameters - P, I and D. Unfortunately, in this article we will not consider the PID tuning in detail. If you are a pilot, you already know, and if you are a beginner, there will be a separate article on this topic.



This system works well when the amount of noise is minimal, otherwise we may face problems such as oscillation (vibration) or overheating of motors.



The d term in a PID controller is especially related to noise. D smooths out fast movements, but calculating D in the PID controller significantly increases the noise in the signal. This means that the noise from the gyroscope is significantly amplified by the D term value and therefore we are filtering in two places - the gyroscope and D.



As an example of such an increase, I will show you the following logs:

First graph - gyroscope

Second graph - PID

Third - motors





(these are normal propellers , with a slightly reduced filtering)





(As you can see, vibrations from bad propellers are amplified at the PID controller stage, which leads to excessive stress on the motors, they are literally sausage)



Screenshots from - Blackbox Explorer .



Filtration



The filtering process is to remove excess noise from the signal from the gyroscope. But how much of the signal from the gyroscope do we want to keep, and how much to filter out?



Honestly, I can't tell you in colors, but it so happened that in beta flight, noise, or rather vibrations, are measured in Hz. 1Hz - one rotation per second. This is done for ease of visualization and work with these variables. Also, turbulence is technically called the "rate of change of rotation" - the frequency of rotation change.



The speed of the quadcopter is in the region of 0-30 Hz. Above 30Hz to 80Hz we have a propwash, when the quadcopter shakes from turbulence in its own streams. Information in the range of 0 - 80Hz is important for the PID controller, so we will not touch it.



With PIDtoolbox you can draw these cards:







Low Pass



Filters







As the previous graph shows - the signal from the gyroscope contains information from 0 Hz to 1000 Hz, but we are only interested in the 0-80 Hz range, since this is the actual movement of the quadcopter that the PID controller should know about. So we need a filtering solution to allow low frequencies to pass through the PID controller while attenuating high frequencies, and for that we can use a Low Pass filter.



Low-pass filters allow low-frequency signals to pass through and attenuate high frequencies, which are mostly just noise.



The cutoff frequency is set, and the controller simply reduces signals above that frequency. Attenuation curveallows you not to cut everything under a clean one, and the higher the frequency of the noise, the more its attenuation occurs, smoothly.



Pilots often make the mistake of setting such a filter at the same frequency as the visible noise. For example at 200Hz. Since the filter attenuates noise smoothly, installing such a filter will not give much results. The filter should be set to lower frequencies. Perhaps even at 80Hz.



The lower you install such a filter, the more filtering occurs.


There is one simple thing to keep in mind when setting up filtering. The more filtering, the greater the delay. It is clear that it is in milliseconds and not significant, but for a PID controller it is critical. Since it will start reacting to events later, which means that it will try to align the quadcopter in the past :)



Notch filter



Notch translates as a notch, in fact it looks like this: The







filters throw away some of the noise below and some of the noise above . Since Betaflight 3.1, these filters are dynamic and adjust to different noise levels.







The filters are used in conjunction with Low Pass filters, but they are already used to filter the noise from the motors that are located above.



D term filtering



As mentioned above, D is capable of multiplying noise from the gyroscope, so Betaflight has D filtering. Below on the frets you can see the noise level before and after filtering.







There is no clear understanding in the community whether to heavily filter D or not. But there is a rule of hot motors, the less filtration and the higher D, the more they heat up and may even burn out. But in the opposite direction, we get a delay.



RPM Filter







So, actually, what I started to use new is RPM filtering. It works through a two-way DSHOT protocol that allows the flight controller to know the exact RPM of a particular motor. And based on this data, filtering is applied.





(Your ESC must support double-sided DHSOT)



Firmware for ESC, from 3.7



If the motors are hot, then this is a problem. Hot motors can be a sign that the motors are getting a lot of noise and are trying to respond to vibrations so often that heat is generated.



Motors can get warm for a number of reasons, such as an old frame, bent bells on the motors, imbalanced balance, extra bombs on your drone.



Of course it is better to have, as they say, clean build, and that everything would be new, but you can first try to set up filtering.



To begin with, you can start by increasing the filtering D, taking steps of 20 Hz. Check the temperature after each such step and find your optimal range.



And you should look for it between the temperature of the motors and vibrations. As mentioned above, although filtering is designed to reduce the amount of noise, it can impose some delays and the PID controller may not keep up. And no matter how funny it is, to cause vibrations. But these vibrations do not belong to propwash. This is just an inefficient PID operation.



Recent versions of Betaflight have sliders, try not to change the values ​​of the filters themselves, but try using these "master" sliders.



At the moment I have such settings with RPM filter enabled, maybe I will try to reduce filtering even more:







useful links






All Articles