Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update approach to anti-wind-up in PID.c #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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