m-lundberg / simple-pid

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

Question: Positive/Negative outputs #11

Closed bluckau closed 4 years ago

bluckau commented 5 years ago

Hi,

I would like to request clarification in the documentation on whether or not the Simple PID can be used for dual-controls (e.g. heating/cooling). If it is already set up to do that, please explain how (positive/negative output values?)

m-lundberg commented 5 years ago

Hi,

Positive and negative output values is supported by setting the output limits to the desired range, for example

pid.output_limits = (-10, 10)

will give output values between -10 and 10. You can also set

pid.output_limits = None

to put no limits on the output values. Of course the output values you get also depend on the tunings Kp, Ki and Kd and your input.

If you mean if the PID can work in reverse mode, meaning that an increase in the output leads to a decrease in the input (like when cooling), it can be achieved by setting the tunings to negative values:

pid.tunings = (-1, -0.1, 0)

(Note that all the tunings should have the same sign).

m-lundberg commented 4 years ago

I added some clarification on reverse mode to README.md