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

Commits on Mar 21, 2021

  1. Update approach to anti-wind-up in PID.c

    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
    drbitboy committed Mar 21, 2021
    Configuration menu
    Copy the full SHA
    6159a75 View commit details
    Browse the repository at this point in the history