Proposal: D-term pre-differentiation LPF to reduce noise amplification (Betaflight-inspired) #11463
19379353560
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
In the current INAV multirotor PID controller, differentiation is applied directly to the raw gyro signal:
Differentiation amplifies high-frequency noise by a factor of
f_loop / f_cutoff— at 1 kHz loop rate this is roughly 9×. The downstream PT2 then has to suppress that amplified noise, which limits how high D gain can be set before oscillation.Proposed Fix
Add an optional PT1 pre-filter applied before differentiation, similar to how Betaflight filters gyro data before computing the D-term derivative:
The added latency is negligible for the position/altitude loop (bandwidth < 5 Hz). For the attitude loop, 0.6 ms is an acceptable trade-off given the noise reduction.
Implementation
I have implemented this in a fork: https://github.com/19379353560/inav
Key changes:
pidState_t: addeddtermLpf2State(PT1) andpreviousFilteredGyroRatedTermProcess(): pre-filter path activated whendterm_lpf2_hz > 0pidInitFilters(): initializes pre-diff filter from configdterm_lpf2_hz(default 250 Hz, 0 = disabled / stock behavior)Happy to submit a PR if there is interest. Would appreciate feedback from the team on whether this approach fits the INAV architecture.
Beta Was this translation helpful? Give feedback.
All reactions