Hi there, in my quest to find a good autotune library, I have come upon this gem and started using it for control as well as autotune (as a TypeScript port for now, before moving PID control from the frontend to the ESP32). It works like a charm and the range of choices is great, however, I have come upon a quirk that I am not sure is correct:
Whenever the algorithm stabilizes PID control, it knocks it out of balance soon after (as seen in the attached graph, green being setpoint, red being the temperature sensor, yellow the heater power). When looking more closely at the problem, it seems to be induced by the logic resetting the integral here: https://github.com/lily-osp/AutoTunePID/blob/main/src/AutoTunePID.cpp#L182C6-L187C10
If I replace that section with just the _integral += _error * dt; statement, things work out beautifully. When looking at the data output, it seems the integral usually stabilized at a number far away from 0 (such as 65 or 70 in my case) when the error starts approaching 0, so resetting it causes readaptation of the algorithm.
Is this simply a typo and intended to be a similar logic to this block, or does this serve a different purpose I am unable to figure out?
I am by no means a PID expert, merely a curious user, so any help in understanding this further would be appreciated. The project in question is a DIY coffee roaster, btw: https://github.com/RobTS/reyaeger

Hi there, in my quest to find a good autotune library, I have come upon this gem and started using it for control as well as autotune (as a TypeScript port for now, before moving PID control from the frontend to the ESP32). It works like a charm and the range of choices is great, however, I have come upon a quirk that I am not sure is correct:
Whenever the algorithm stabilizes PID control, it knocks it out of balance soon after (as seen in the attached graph, green being setpoint, red being the temperature sensor, yellow the heater power). When looking more closely at the problem, it seems to be induced by the logic resetting the integral here: https://github.com/lily-osp/AutoTunePID/blob/main/src/AutoTunePID.cpp#L182C6-L187C10
If I replace that section with just the
_integral += _error * dt;statement, things work out beautifully. When looking at the data output, it seems the integral usually stabilized at a number far away from 0 (such as 65 or 70 in my case) when the error starts approaching 0, so resetting it causes readaptation of the algorithm.Is this simply a typo and intended to be a similar logic to this block, or does this serve a different purpose I am unable to figure out?
I am by no means a PID expert, merely a curious user, so any help in understanding this further would be appreciated. The project in question is a DIY coffee roaster, btw: https://github.com/RobTS/reyaeger