User Tools

Site Tools


Sidebar

bms:guides:pid
Approved 2022/08/06 07:57 by mk (version: 5)

PID Regulator

PID regulators is a bit more difficult to explain and understand. They use more system resources so often the control curve is preferred if the system is low on resources.

I'll try a simple explanation first: If the temperature (Control variable) gets below setpoint, the regulator will increase the heating (Output variable) The bigger the difference, the faster the output will change.

In a basic PID regulator, there's 3 variables, proportional gain (P or P-band), integral gain (I or I-time) and derivative gain (D)

You can use 3 methods, P, PI or PID

P-regulator

A P-regulator, will measure the “error” from ( setpoint - control variable ), if setpoint is 23 and control variable is 20, the “error” will be 3. It will then take the output variable and add the error. If the output was 0, after the calculation it will be 3. Thus the P regulator, as seen in below picture as blue, will never reach it's setpoint.

Pseudo code

On Wikipedia there's a lot of information about this regulator, but I will highlight one thing from there, a pseudo code examble.

  • Kp - proportional gain
  • Ki - integral gain
  • Kd - derivative gain
  • dt - loop interval time
  • previous_error := 0
  • integral := 0
loop:
error := setpoint − measured_value
proportional := error;
integral := integral + error × dt
derivative := (error − previous_error) / dt
output := Kp × proportional + Ki × integral + Kd × derivative
previous_error := error
wait(dt)
goto loop

Proportional or P-band

Integral or I-time

I or Integral, will make the output go faster, the longer it takes for the control variable to reach the setpoint.

Practically explained

Where P will @@@@@@@@@@@@@@ ADD MORE TEKST HERE IN THE FUTURE @@@@@@@@@@@@

Derivative

D or Derivative, is pretty much never used in in regulators used for BMS systems. (Heating, cooling and air handling)

D will try to avoid an overshoot, by predicting where the output will be. If set too high, it will slow the output too much, and “never” hit the target, but if set too low, you might overshoot your setpoint.

Practically explained

If you have control variable of 20 degrees but setpoint is 23 degrees, the regulator will raise the output, eg. from 0 towards 100%. If 50% is where the output needs to be for the control variable to stay at 23 degrees, and D is too low, the output will raise to 60% and control variable could reach 23,5, before it will lower the output and finally settle down. See green line in graph above.

Illustrative examble

With a little help from this guy I was able to put together 3 live test simulations of P, PI and PID regulators. Theese simulations open out side this wiki, so you have to press back button to get back here. What you can do is change the control variable and adjust parameters accordingly.

TIP: Change control variable slowly to simulate a change in temperature or pressure.





https://www.researchgate.net/profile/Mohamed_Mourad_Lafifi/post/What_is_the_best_method_can_we_used_to_tune_PID_controller/attachment/5f5775b1ecec86000108690f/AS%3A933466292113420%401599567115449/download/PID_Tuning_Guide_022810.pdf


Discussion

Enter your comment. Wiki syntax is allowed:
G᠎ Q R
 
bms/guides/pid.txt · Last modified: 2022/08/06 07:57 by mk