Be careful with Arduino libraries. If you are trying to learn something, it's usually better to write your own, or look at really good code.
Case in point, PIDLibrary, I'm looking at the PIDCompute function, line 57:
ITerm+= (ki * error);
That's not how you deal with I. You are supposed to accumulate (integrate) the error and multiply by Ki only for the final PID addition. You don't want to accumulate your errors multiplied each time by Ki, it makes no sense.
That is actually done intentionally to allow for changing of the tuning parameters while the PID is running.[1] The author of the PID library has a full writeup on the design of the algorithm.[2]
Case in point, PIDLibrary, I'm looking at the PIDCompute function, line 57:
That's not how you deal with I. You are supposed to accumulate (integrate) the error and multiply by Ki only for the final PID addition. You don't want to accumulate your errors multiplied each time by Ki, it makes no sense.