1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

Scaled PID deltaT calculations from us to seconds

This commit is contained in:
Martin Budden 2017-11-19 04:24:40 +00:00
parent a9105e88c4
commit 34b48badb9

View file

@ -410,11 +410,11 @@ void pidController(const pidProfile_t *pidProfile, const rollAndPitchTrims_t *an
const float tpaFactor = getThrottlePIDAttenuation(); const float tpaFactor = getThrottlePIDAttenuation();
const float motorMixRange = getMotorMixRange(); const float motorMixRange = getMotorMixRange();
static timeUs_t crashDetectedAtUs; static timeUs_t crashDetectedAtUs;
static timeUs_t previousTime; static timeUs_t previousTimeUs;
// calculate actual deltaT // calculate actual deltaT in seconds
const float deltaT = currentTimeUs - previousTime; const float deltaT = (currentTimeUs - previousTimeUs) * 0.000001f;
previousTime = currentTimeUs; previousTimeUs = currentTimeUs;
// Dynamic ki component to gradually scale back integration when above windup point // Dynamic ki component to gradually scale back integration when above windup point
const float dynKi = MIN((1.0f - motorMixRange) * ITermWindupPointInv, 1.0f); const float dynKi = MIN((1.0f - motorMixRange) * ITermWindupPointInv, 1.0f);