New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PID Control Hysteresis #398
Comments
Currently untested, but I implemented the Mycodo/mycodo/controller_pid.py Lines 364 to 389 in e9038c9
I should get around to testing this weekend or sooner and have a release by the end of the weekend. |
I like this a lot, will be very useful for the health of my refrigerators! |
Kyle, looking at the link above on hysteresis control got me thinking that PID control and this hysteresis control are alternatives, and should not be combined together. A little googling seems to support this. |
I added |
I can't conceptualize how the same PID can use hysteresis for just lowering and not use it for raising. I can see two PIDs being used, one raising, and one lowering with hysteresis. This could work well, without the PIDs not competing too much if tuned properly. |
I believe that those were two different operations, but I'm not familiar with brewing. The competition was a main topic of the discussion, though. |
1 similar comment
I believe that those were two different operations, but I'm not familiar with brewing. The competition was a main topic of the discussion, though. |
The current iteration of Hysteresis in Mycodo's PID controllers can theoretically work very well together. Here's one heating/cooling scenario: PID 1: Heat, Raise to 30 °CSetpoint: 30 °C, Hysteresis: 0 (disabled), the PID will raise the temperature to 30 °C and stop when the temperature is above 30 °C. PID 2: Cool, Lower to 31 °CSetpoint: 33 °C, Hysteresis: 2 (Min Band: 31 °C, Max Band: 35 °C), the PID will lower to 31 °C, then stop until the temperature rises above 35 °C, at which point it will begin regulating again to 31 °C. Leaving the gap of one degree (30 °C to 31 °C, there shouldn't be any direct competition between the PID controllers. You would even make the gap 0 °C (Rise to 30 °C, Lower to 30 °C) and the PIDs should still function properly (considering they're well-tuned). |
With testing the PID with direction set to Both, I had to fix some issues related to the wrong outputs being activated, due to the integrator and/or derivator. To do this, I reset both the integrator and derivator upon the current measurement reaching the opposite band threshold. That is, when the measurement reaches beyond either the Minimum Band or Maximum Band, the integrator and derivator are reset to 0, so the PID acts as though it were just turned on. This creates a smooth output instead of the aberrant behavior seen in the first graph, below. Before FixAfter Fix |
Kyle, |
Let me know if there are any issues. I'm closing this, as I believe it's complete. |
Sounds good, looks OK on my end for all of the delays and hysteresis. |
From this comment
Proposed is the addition of the PID option
band
to enable PID hysteresis.Example: Temperature Controllers Using Hysteresis
To my understanding it should operate like this:
If PID is set to Raise
Raise to the maximum value (setpoint + band value), then allow the condition to fall to the minimum value (setpoint - band value) before resuming regulation.
If PID is set to Lower
Lower to the minimum value (setpoint - band value), then allow the condition to raise to the maximum value (setpoint + band value) before resuming regulation.
If PID is set to Both
When the condition enters the band region (setpoint +/- band), do not apply the PID. When the condition falls outside (above or below), then begin applying the PID again. If it rises above the maximum value, begin lowering until it enters the band region. When it lowers below the minimum value, begin raising until it enters the band region.
Let me know your thoughts, if I'm missing a part of this concept, or if there are alternative methods that would be desirable to add.
The text was updated successfully, but these errors were encountered: