Using Arduino PID library - Reseting integrals

Hello

I'm using the PID library found here: http://playground.arduino.cc/Code/PIDLibrary

Is there some way to easily reset the integrals when using this library?

Can you please provide an example of what you want to do ?

Christoffer:
Is there some way to easily reset the integrals when using this library?

You can use this trick to force both Output and ITerm (the integral term) to 0.0:

PID.SetOutputLimits(0.0, 1.0);  // Forces minimum up to 0.0
PID.SetOutputLimits(-1.0, 0.0);  // Forces maximum down to 0.0
PID.SetOutputLimits(PIDMinimum, PIDMaximum);  // Set the limits back to normal

You have to do it in two steps because if Min >= Max the call does nothing. This trick only works in AUTOMATIC mode.
Since you have the source code you could always add a method to reset ITerm. Typically you would set it to the latest Output value.

johnwasser:
You can use this trick to force both Output and ITerm (the integral term) to 0.0:

PID.SetOutputLimits(0.0, 1.0);  // Forces minimum up to 0.0

PID.SetOutputLimits(-1.0, 0.0);  // Forces maximum down to 0.0
PID.SetOutputLimits(PIDMinimum, PIDMaximum);  // Set the limits back to normal



You have to do it in two steps because if Min >= Max the call does nothing. This trick only works in AUTOMATIC mode.
Since you have the source code you could always add a method to reset ITerm. Typically you would set it to the latest Output value.

Nice!
That's just what I need, thanks for the help :slight_smile:

Old thread, but similar challenge. I took this approach, does it seem acceptable?

myPID_R.SetMode(MANUAL);
OutputR = 0;
myPID_R.SetMode(AUTOMATIC);