Skip to content

Conversation

@drbitboy
Copy link

[Just a suggestion]

Current approach (re-written to be more concise, although possibly less clear):

I = I + deltaT * Ki * mean_error;
I = (I>limImax) ? limImax : ((I<limImin) ? limiImin : I);

/* Calculate out from P, I, and D, then clamp */
out = P + I + D;
out = (out>limMax) ? limMax : ((out<limMin) ? limiMin : out);

Example where this fails, or at least performs poorly:

  • Assume

    P = 90%; D = 0%; I = 20%; limImax=50%; limMax = 100%;

    /* I < limImax, so no anti-windup is in effect; however ... */

    out = P + I + D; /* => 110%, i.e. out is over-saturated /
    out - (out>limMax) ? limMax : ...; /
    => 100%, out is clamped, but I is not */

New approach:

I = I + deltaT * Ki * mean_error; /* Same /
/
Remove static limiting of I */

/* Same */
out = P + I + D;
out = (out>limMax) ? limMax : ((out<limMin) ? limiMin : out);

/* New - solve for I from [out=P+I+D] above /
I = out - (P + D); /
[I] will not change unless out is being clamped

Current approach (re-written to be more concise, although possibly less clear):

  I = I + deltaT * Ki * mean_error;
  I = (I>limImax) ? limImax : ((I<limImin) ? limiImin : I);

  /* Calculate out from P, I, and D, then clamp */
  out = P + I + D;
  out = (out>limMax) ? limMax : ((out<limMin) ? limiMin : out);

Example where this fails, or at least performs poorly:

- Assume

  P = 90%; D = 0%; I = 20%; limImax=50%; limMax = 100%;

  /* I < limImax, so no anti-windup is in effect; however ... */

  out = P + I + D;                    /* => 110%, i.e. out is over-saturated */
  out - (out>limMax) ? limMax : ...;  /* => 100%, out is clamped, but I is not */

New approach:

  I = I + deltaT * Ki * mean_error;   /* Same */
  /* Remove static limiting of I */

  /* Same */
  out = P + I + D;
  out = (out>limMax) ? limMax : ((out<limMin) ? limiMin : out);

  /* New - solve for I from [out=P+I+D] above */
  I = out - (P + D);   /* [I] will not change unless out is being clamped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant