I dont understand integral part of PID controller. Let's assume this pseudocode from Wikipedia:
previous_error = 0
integral = 0
start:
error = setpoint - measured_value
integral = integral + error*dt
derivative = (error - previous_error)/dt
output = Kp*error + Ki*integral + Kd*derivative
previous_error = error
wait(dt)
goto start
Integral is set to zero in the beginning. And then in the loop it's integrating the error over the time. When I make a (positive) change in measured value or setpoint, the error will become positive and integral will "eat" the values over the time (from the beginning). But what I dont understand is, when error stabilizes back to zero, the integral part will still have some value (integrated errors over time) and will still contribute to the output value of controller, but it should not.
Can somebody explain me that please?