ErikZalm/Marlin — pull request #791 by drf5n (2014-02-18 19:24:10+00:00)
Title: temperature.cpp: Automatically eliminate excess integrator windup.

By backcalculating the integral accumulator value when the calculated process output is beyond {0,PID_MAX} this will prevent integral windup.

The current system with temp_iState_min_bed, temp_iState_max_bed, PID_INTEGRAL_DRIVE_MAX, temp_iState_min, temp_iState_max, and resetting at PID_FUNCTIONAL_RANGE are workarounds to control integral windup, but they still leave a bit uncontrolled.

Bumping against the PID_INTEGRAL_DRIVE_MAX=255 limit in Configuration.h can still allow excess windup and overshoot.

For example, if full power can change the hotend at 0.5C/s, manage_heater() is going to do bang-bang until setpoint-10C, then initialize the PID, and run for at least 20s, or 80 manage_heater() cycles. At (setpoint-10*Kp) the power will drop to 22/255 and start accumulating I to use to adjust the offset. Assuming a dead-time of 10s, at t+10s, T=setpoint-5C, and the unconstrained process output is wound up to 443. (assuming the Ultimaker PID values in Configuration.h) The process will have to overshoot for a while to start pulling the I accumulator down from PID_INTEGRAL_DRIVE_MAX.

This change isn't well tested yet.