This integrator design seems a bit odd to me.
Firstly, I think we always want to sum after multiplying (otherwise changing the I gain will generally cause a large step change in the TEC current).
Secondly, we should be definitely be multiplying by the I gain before we clip. Otherwise the integrator limits depend on the I gain, which is horrific.
I also don't think I understand the electric current error condition on the integrator.
Imagine the following situation: the unit starts off cold, so the current rails positive. Now, before it has reached steady-state we lower the set point. Because the current is still railing the integrator will remain shutdown and will never track in.
It's also not clear to me what happens when the I gain is changed. Imagine Kp and Kd are both zero and we step Ki. That can easily result in the output shooting up to max because of the multiply after sum issue. At that point the integrator is shut off and can never recover, can it?
That design is not only odd but fundamentally flawed. It's not hard to show that the only reliable way to address these and numerous other issues in the ubiquitous naive PID controller implementations is to ditch them.
https://hackmd.io/IACbwcOTSt6Adj3_F9bKuw is a short write-up.
Thanks for that nice write up @jordens
There are varying levels of sophistication we can go for here. Right now even a few really simple tweaks (multiply before sum, rethink the limiting) would make a huge impact on usability.
Deleting a branch is permanent. It CANNOT be undone. Continue?