PID Autotune not switching output off?

Anyone experiecing a runaway output when using the PID Autotune feature?

After enabling the Autotune, I’m watching the measurement climb until the logs say “switched state down” but the output remains on and the measurement keeps climbing.
If I watch a graph with the output duration bars, it actually shows that the output has stopped being turned on yet on the Setup->Output page the output remains on and I can turn it off. [edit: it turns out, I could not turn off the output with the autotuner running, it keeps turning it back on]

In this case, the input is an MQTT Value while the output is an On/Off Raspberry Pi GPIO (RPi.GPIO). Everything works normally otherwise, I’ve never noticed the output being left on under normal operations.

Also, the output remains active even after deactivating the PID Autotuner.

After turning on debugging for both the autotuner and the output, I think I might know what’s up.

If I understand this correctly… In the Autotuner, pid_autotune.py, line 157, after it has switched to RELAY_STEP_DOWN, the self._output is being set to zero. At some point later, the actual output is set to that value. I see this in the logs when the Output debugging says output_on_off(on, 0, sec, 0.0, etc) but it should be output_on_off(off, 0, sec, 0.0, etc).

Setting the value 0 but still sending the on signal to the output doesn’t turn it off, just turns it on indefinitely.

I was finally able to get the Autotune feature to work as advertised but I had to babysit the GPIO output the entire time by flipping the ‘On State’ to LOW to force the output off when the autotune was in relay step down state.
Without forcing the GPIO off, it remains on the whole time and, in this case, a heating element stayed on as the temperature kept climbing.

1 Like

Thanks for the diagnostics. I’ll check out the code and see if I can apply a fix. The autotune is an experimental feature, so it shouldn’t be relied on for obtaining a good PID tuning. There are a lot of factors that can cause issues. But I’m glad it worked for you.

I just committed what I think should be a fix for this issue. If you would like to test, please let me know if it works. Thanks.