soloam / ha-pid-controller

PID Controller to Home Assistant
MIT License
97 stars 12 forks source link

PID doesn't do anything since 1.1.3 #15

Closed RubenKelevra closed 1 year ago

RubenKelevra commented 2 years ago

Looks like there's some calculation error going on. My setpoint is 10 and the sensor reports below 10 for hours and the output stays at maximum.

The internal state shows an extremely high value for I which seems to be wrong.

config output_24h_and_internal_values sensor_data_and_output

soloam commented 2 years ago

You are suffering of what is called pid windup! If your PID gets saturated, meaning that it never reaches the set point, no matter the time it runs, your integral (the I) will keep growing and growing!

In a PID, the output is the sum of all 3 componentes (p+i+d), in the end it calculates the output. Since your integral is huge, your integral alone will max out the output. To avoid this set the windup parameter to the max that you would like to get from the integral!

soloam commented 2 years ago

I was looking at the code and I think there is a bug calculating the min a max windup of the integral! I'll make some tests and then report back

RubenKelevra commented 2 years ago

I downgraded to 1.12 and there's the same issue:

Screenshot_2022-02-23-01-09-05-031_io.homeassistant.companion.android.jpg

It might be related to the sample time setting, which I wasn't using before.

soloam commented 2 years ago

Try to add some value to the windup! This is the maximum number that the integral should supply! Try to set it to something like 1

RubenKelevra commented 2 years ago

Ah somehow HACS messed up the downgrade. So the screenshot before was also with 1.1.3.

Using 1.1.2 the issue is gone.

soloam commented 2 years ago

1.1.2 had a issue that was not calculating the integral part ok! Probably that's what's happening now to you! Did you tried to set the windup on 1.1.3?

RubenKelevra commented 2 years ago

I did set the windup now on 1.1.3 to 1.

I'll report back after having it running a bit like that :)

RubenKelevra commented 2 years ago

I was looking at the code and I think there is a bug calculating the min a max windup of the integral! I'll make some tests and then report back

I was waiting on the tests on possible code issues :)

RubenKelevra commented 2 years ago

1.1.2 had a issue that was not calculating the integral part ok! Probably that's what's happening now to you! Did you tried to set the windup on 1.1.3?

Looks much better, but the "effort" is now too low.

How do I influence the response to be a bit higher (choose higher output if the values are too high) than 1? Increase windup or lower windup?

soloam commented 1 year ago

Please open issue again if problem still occurs in current versions!