Cleanflight low pass filters part 2
Quite a lot things changed in the world of low pass filtering since my previous port on this topic was published. So, here is the updated guide to Cleanflight LPF filters:
gyro_lpf
gyro_lpf
is the most important low pass filter for gyroscope readouts. First of all, it is not part of Cleanflight, but is done by gyroscope itself. Cleanflight only initializes gyro with desired cutoff frequency. Allowed values are:
- OFF
- 188HZ
- 98HZ
- 42HZ
- 20HZ
- 10HZ
When OFF
is selected, gyro offers fastest possible sampling rate (8kHz, new data every 125us) and smaller possible delay. But, it is extremely prone to any vibrations. Any noise from motor or propeller will be visible in gyro output. All other values of this filter allows gyro to provide new data every 1000us (1kHz).
42Hz is lowest 'flyable' cutoff frequency. It does not makes sense to go lower, since signal delay will be too big and filter will attenuate frequencies that are important from 'flight' point of view. So, 188Hz, 98Hz and 42Hz are the ones that are interesting for us. Exact value depends on propellers, motors, balancing, bearings state, frame rigidness and few other aspects. Let's say, that 250mm or smaller frames can use 188Hz, 450mm and bigger frames should use 98Hz or 42Hz.
gyro_soft_lpf
gyro_soft_lpf
is a second state of gyro readout filtering before they are introduced to PID controller. One might ask: why two filters? After all, gyro_lpf
does the same thing. Yes, it does the same thing. But using 2 LPFs in this case has some advantages. gyro_lpf
can not be tuned. It's either: off, 188Hz, 98Hz, 42Hz. But what if, for example, main source of gyro noise is at about 90Hz? Cutoff at 98Hz would be pretty useless. One would have to use 42Hz, loosing a lot of usable frequencies and having to suffer from noticeable (from PID controller point of view) delay. This is why fully configurable second stage of LPF was added.
gyro_soft_lpf
should be kept below gyro_lpf
, and below frequency of main noise source. Usually between 50 and 100Hz. Frequencies below 50Hz are too important for stable flight to attenuate them. On the other hand, everything above 100Hz is useless and can be cut off.
pterm_cut_hz
This software LPF filter was removed and is no longer available.
dterm_cut_hz
Here, let me just quote my previous post:
(..) D term of PID controller, since it is trying to look into a future, can be a source of huge noise and vibrations. After all, looking into a future is always a tricky business. This is why D term can change with totally different frequency than gyro input and there is a very good reason to limit D term change. Too see how excess D noise can affect gyro traces take a look at my Blackbox tutorial.
(...) Rule of thumb is: smaller and more rigid frames allows for higher D term cutoff frequency and 42Hz is a good place to start. Bigger frames might require lower cutoff frequency and 10Hz is lower boundary.
If only frame and noise level allows, D term cutoff frequency should be kept as high as possible. This allows D term to reacts faster to changing flight conditions and can greatly improve UAV behavior in prop wash and rapid maneuvers.
I'm Paweł Spychalski and I do things. Mainly software development, FPV drones and amateur cinematography. Here are my YouTube channels: