to filter noise from acc signal more effectively I replaced digital first order low pass filter (LPF) with Chebyshev LPF. This is not my idea; actually it came from AeroQuad software.
Chebyshev LPF is an infinite impulse response (IIR) filter. It has the following characteristics:
- type – II (with ripples in stop band),
- order - 6,
- attenuation - 72dB,
- normalized cut-off frequency – 0.1.
Code: Select all
[b,a]=cheby2(6,72,0.1)
Normalized cut-off frequency of 0.1 means that if one samples acc 200 times per second (200 Hz) then the highest frequency that is present in the signal is 200/2=100 Hz (Niquist frequency) and low pass filter cuts-off all frequencies above 100*0.1=10Hz.
I suggest to use looptime = 5000. Then acc is sampled at 200Hz and filter cuts-offs frequencies above 10Hz.
To turn the filter on, one must set value of the acc_lpf_factor greater then 0 e.g. acc_lpf_factor = 4 (default value). Actual value of the acc_lpf_factor does not matter. If acc_lpf_factor = 0 then the filter is disabled.
It is easy to include chebyshev LPF into feature list, then one can choose between first order LPF (configurable by acc_lpf_factor) and chebyshev LPF. Maybe I’ll do it later.
I am not a filter designer; I am just an amateur programmer . This online book inspired me to try advanced filtering techniques.
The binary (and code) attached is flight tested .