Luro02 / klipper-mpc

Implementation of Model Predictive Temperature Control for klipper
GNU General Public License v3.0
16 stars 2 forks source link

Dynamic `min_ambient_change` for faster convergence of ambient temperature? #10

Open Luro02 opened 11 months ago

Luro02 commented 11 months ago

The min_ambient_change defines how much the ambient temperature should be adjusted to correct errors in the calibration values. A higher value, could result in a faster convergence to the target temperature, but might decrease stability of the ambient temp.

One could change the min_ambient_change while the control algorithm is running to improve convergence speed and stability:

Initially it will use a high value, until the ambient temperature is no longer increasing or decreasing (fluctuating around a range of values). Then it will decrease the min_ambient_change until there is some ambient_temp at which the algorithm stabilizes.

Alternatively one could do the following:

delta = 1.0 - max(0.0, min(1.0, temp / target_temp)) and then calculate the ambient_change with ambient_change = delta * (max_ambient_change - min_ambient_change) + min_ambient_change (or just use a map_range(delta, 0.0, 1.0, min_ambient_change, max_ambient_change) function)