PT1 element and normalised acc/mag readings.

PT1 element and normalised acc/mag readings.
test flown with the unusual cleanflight defaults.
dTerm = delta * Kd / dT;

baseflight assumes a constant time and you could write:
dTerm = delta * Kd_new;

multiwii sums up the last 3 dterm values and divides the sum with 32.
there is no time involded.

if you like, then use:

delta *= (1.0f / dT);

the problematic part is the ugly coding.
one instruction to much.
  delta /= dT;
is more efficient ;-)
pid controlers start to fail when the jitter increases:

delta *= (1.0f / dT);

https://www.google.ch/search?q=pid+controller+jitter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de:official&client=firefox-a&channel=np&source=hp&gfe_rd=cr&ei=z0eXU5voG8HW8gfh8oDgDA

pick up a few pdf's for reading.
the good news is, you can write a function to compensate for jitter.
the bad news is - it uses even more cpu cycles and as a result jitter 
increases.

in the mean time i would write:
         // calculate PT1 element on deltaSum
         deltaSum = lastDTerm[axis] + (dT / (RC + dT)) * (deltaSum - 
lastDTerm[axis]);
         lastDTerm[axis] = delta;
         DTerm = ((int32_t) deltaSum * pidProfile->D_f[axis]) >> 5; // 
32 bits is needed for calculation
         // cf: DTerm = constrainf((deltaSum / 3.0f) * 
pidProfile->D_f[axis], -300.0f, 300.0f);

but still no direct inclusion of the time.
the current version use a dterm value which is to high.

cleanflight keeps the copter in the air.
but it flies not yet really good.


Am 10.06.2014 00:02, schrieb luggi:
>
> In src/flight_common.c:
>
> > @@ -124,17 +129,19 @@ static void pidBaseflight(pidProfile_t *pidProfile, controlRateConfig_t *control
> >          delta = gyroRate - lastGyroRate[axis];  // 16 bits is ok here, the dif between 2 consecutive gyro reads is limited to 800
> >          lastGyroRate[axis] = gyroRate;
> >
> > -        // Correct difference by cycle time. Cycle time is jittery (can be different 2 times), so calculated difference
> > -        // would be scaled by different dt each time. Division by dT fixes that.
> > -        delta *= (1.0f / dT);
>
> you clearly don't understand how a pid works ? or am i missing something ?
> the derivative term is time dependent...
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/hydra/cleanflight/pull/19/files#r13567694>.
>