mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +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:
parent
98b1b93199
commit
123faebacf
1 changed files with 4 additions and 1 deletions
|
@ -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++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue