Merge pull request #4594 from martinbudden/bfa_iterm_dt

Use constant dT for ITerm calcualtion to avoid windup caused by jitter
This commit is contained in:
Martin Budden 2017-11-17 06:33:33 +00:00 committed by GitHub
commit ee92d1ede2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -497,7 +497,8 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
// -----calculate I component
const float ITerm = axisPID_I[axis];
const float ITermNew = constrainf(ITerm + Ki[axis] * errorRate * deltaT * dynKi * itermAccelerator, -itermLimit, itermLimit);
// use dT (not deltaT) for ITerm calculation to avoid wind-up caused by jitter
const float ITermNew = constrainf(ITerm + Ki[axis] * errorRate * dT * dynKi * itermAccelerator, -itermLimit, itermLimit);
const bool outputSaturated = mixerIsOutputSaturated(axis, errorRate);
if (outputSaturated == false || ABS(ITermNew) < ABS(ITerm)) {
// Only increase ITerm if output is not saturated