1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00

Improve accuracy of dT used to update RPM filter (#14150)

Improve RPM filter accuracy by using the true looprate when updating it
This commit is contained in:
Kevin Plaizier 2025-01-20 13:26:52 -07:00 committed by GitHub
parent 98b1b93199
commit 123faebacf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -121,6 +121,9 @@ FAST_CODE_NOINLINE void rpmFilterUpdate(void)
return; return;
} }
const float dtCompensation = schedulerGetCycleTimeMultiplier();
const float correctedLooptime = rpmFilter.looptimeUs * dtCompensation;
// update RPM notches // update RPM notches
for (int i = 0; i < notchUpdatesPerIteration; i++) { for (int i = 0; i < notchUpdatesPerIteration; i++) {
@ -143,7 +146,7 @@ FAST_CODE_NOINLINE void rpmFilterUpdate(void)
weight *= rpmFilter.weights[harmonicIndex]; weight *= rpmFilter.weights[harmonicIndex];
// update notch // update notch
biquadFilterUpdate(template, frequencyHz, rpmFilter.looptimeUs, rpmFilter.q, FILTER_NOTCH, weight); biquadFilterUpdate(template, frequencyHz, correctedLooptime, rpmFilter.q, FILTER_NOTCH, weight);
// copy notch properties to corresponding notches on PITCH and YAW // copy notch properties to corresponding notches on PITCH and YAW
for (int axis = 1; axis < XYZ_AXIS_COUNT; axis++) { for (int axis = 1; axis < XYZ_AXIS_COUNT; axis++) {