Experimental PID improvement changes

@Lbibass, @Sineos I’ve implemented and tested the changes to work with systems that are underpowered. It works by looking for for convergences in the maximum power setting using this method.

    def converged(self):
        powers = float(len(self.powers))
        if powers < TUNE_PID_SAMPLES + 1:
            return False
        powers = self.powers[-1*(TUNE_PID_SAMPLES+1):]
        if (max(powers)-min(powers)) <= TUNE_PID_TOL:
            return True
        return False

the conversion tolerance now defaults to 0.01, as its looking for convergence between numbers with a different magnitude than it was previously. You can alter the tolerance at run time just as you could with the previous iteration (if your system is to noisy). I’ll be interested to hear if people get convergence with the default or not, as picking a default is always a difficult decision.

PID_CALIBRATE HEATER=extruder TARGET=220 WRITE_FILE=1 TOLERANCE=0.02

To test it on my end, I intentionally set max_power far lower than it should be.

[extruder]
max_power: 0.4

this is what klipper master returns.

pid_Kp=14.195 
pid_Ki=0.627 
pid_Kd=80.378

this is what I just pushed to github returns.

pid_Kp=14.141 
pid_Ki=0.616 
pid_Kd=81.132

those values are within what I would expect for run to run deviances.

In summary if your system is underpowered you will get the same calibration results as what klipper master currently gives. If your system is overpowered, you will get better results, as the algorithm will decrease maximum power (during calibration) to make your system run in a symmetric way.