m-lundberg / simple-pid

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

Document reverse acting control using simple_pid #58

Closed kjkoster closed 2 years ago

kjkoster commented 2 years ago

Dear All,

Really more of a support question, but can the documentation be enhanced to show how to use simple_pid for reverse acting control?

To add colour: I have a temperature control (aiming for 70°C) for which I control the motor speed (PWM). Lower flow means higher temperatures, higher flow means lower temperatures.

Kees Jan

juan11iguel commented 2 years ago

You need to use negatives gains for all the control actions that you use (proportional, integral, derivative)

I agree that maybe in the README there could be a bit more documentation about the structure of the controller and so on but since it's a classical control strategy you can find a lot of information on Google

Wikipedia, related question in stackoverflow

juan11iguel commented 2 years ago

Checking the README it actually appears to be documented:

To use the PID in reverse mode, meaning that an increase in the input leads to a decrease in the output (like when cooling for example), you can set the tunings to negative values: pid.tunings = (-1.0, -0.1, 0) Note that all the tunings should have the same sign.

kjkoster commented 2 years ago

Oh, it is! You are right. Sorry to cause you work.