m-lundberg / simple-pid

A simple and easy to use PID controller in Python
MIT License
801 stars 217 forks source link

Fix for bump in output when enabling auto mode #4

Closed m-lundberg closed 5 years ago

m-lundberg commented 5 years ago

This should fix #3.

I fixed the potentially huge dt after running in manual mode for a while by updating _last_time even when in manual mode.

For allowing to set the _error_sum to the last output variable when re-enabling auto_mode so that the PID can continue from where the manual tuning "left off", I added a new function set_auto_mode() which accepts a parameter for the last output value. I also kept the old auto_mode property setter for now for backwards compatibility.

To do before merging: