Hardware Reference
In-Depth Information
The second part of the code multiplies the error by the gain variable:
Pout = Kp * error;
The proportional statement attempts to lower the error by calculating the error to zero where input = setpoint .
A pure proportional controller, with this equation and code, will not settle at the setpoint, but usually somewhere
below the setpoint. The reason the proportional statement settles below the setpoint is because the proportional
control always tries to reach a value of zero, and the settling is a balance between the input and the feedback. The
integral statement is responsible for achieving the desired setpoint.
If Kp is set too high, the system will become unstable. the gain value when this happens is different for
each system.
Note
The Integral Statement
The I in PID is for an integral; this is a major concept in calculus, but integrals are not scary. Put simply, integration
is the calculation of the area under a curve. This is accomplished by constantly adding a very small area to an
accumulated total. For a refresher of some calculus, the area is calculated by length × width; to find the area under a
curve, the length is determined by the function's value and a small difference that then is added to all other function
values. For reference, the integral in this type of setup is similar to a Riemann sum.
The PID algorithm does not have a specific function; the length is determined by the error, and the width of
the rectangle is the change in time. The program constantly adds this area up based on the error. The code for the
integral is
errorsum = (errorsum + currenterror) * timechange;
Iout = Ki * errorsum ;
The integral reacts to the amount of error and duration of the error. The errorsum value increases when the input
value is below the setpoint, and decreases when the input is above the setpoint. The integral will hold at the setpoint
when the error becomes zero and there is nothing to subtract or add. When the integral is added to proportional
statement, the integral corrects for the offset to the error caused by the proportional statement's settling. The integral
will control how fast the algorithm attempts to reach the setpoint: lower gain values approach at a slower rate;
higher values approach the setpoint quicker, but have the tendency to overshoot and can cause ringing by constantly
overshooting above and below the setpoint and never settling. Some systems, like ovens, have problems returning
from overshoots, where the controller does not have the ability to apply a negative power. It's perfectly fine to use just
the PI part of a PID equation for control, and sometimes a PI controller is satisfactory.
the integral will constantly get larger or smaller depending on how long there is an error, and in some cases
this can lead to windup. Windup occurs when the integral goes outside the feasible output range and induces a lag. this
can be corrected by checking if Iout goes outside the output range. to correct for this, check Iout and reset it to the
bound it exceeded.
Note
 
 
Search WWH ::




Custom Search