mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Added explanation as to why fixed dT is used in PID calculation. (#5737)
This commit is contained in:
parent
6e44173f86
commit
8e152f3259
1 changed files with 5 additions and 1 deletions
|
@ -614,7 +614,11 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
|
||||||
// no transition if relaxFactor == 0
|
// no transition if relaxFactor == 0
|
||||||
float transition = relaxFactor > 0 ? MIN(1.f, getRcDeflectionAbs(axis) * relaxFactor) : 1;
|
float transition = relaxFactor > 0 ? MIN(1.f, getRcDeflectionAbs(axis) * relaxFactor) : 1;
|
||||||
|
|
||||||
// Divide rate change by deltaT to get differential (ie dr/dt)
|
// Divide rate change by dT to get differential (ie dr/dt).
|
||||||
|
// dT is fixed and calculated from the target PID loop time
|
||||||
|
// This is done to avoid DTerm spikes that occur with dynamically
|
||||||
|
// calculated deltaT whenever another task causes the PID
|
||||||
|
// loop execution to be delayed.
|
||||||
const float delta = (
|
const float delta = (
|
||||||
dynCd * transition * (currentPidSetpoint - previousPidSetpoint[axis]) -
|
dynCd * transition * (currentPidSetpoint - previousPidSetpoint[axis]) -
|
||||||
(gyroRateDterm[axis] - previousGyroRateDterm[axis])) / dT;
|
(gyroRateDterm[axis] - previousGyroRateDterm[axis])) / dT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue