soloam / ha-pid-controller

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

Only Updates when Process Variable changes #45

Open 11sas11 opened 1 year ago

11sas11 commented 1 year ago

The controller only updates when it sees a change in the process variable. This means that the integral doesn't keep winding up as it should and makes behavior erratic. If I have the update set to 30s, and I have an error the integral should add to the output every 30s. Am I doing something wrong, or is this how it is intended to work?

Noting the output is prodominately Integral 2023-08-04_09-02-26

2023-08-04_09-07-07

Also the scaling is a problem. It is okay with temperatures, but I want to use W into the house and adjust loads to suit. So typically the number is between -5000 and +5000, even with a proportional and integral at 0.01 and the output range set to 100 000 it saturates in one scan if there is -500 W of power.

soloam commented 1 year ago

Hello! I know that this is a huge limitation! I've been struggling to have time to address all this issues! I'm also using a lot this component, and I also need this. I'll make this my priority change!

Thank you

11sas11 commented 1 year ago

Thanks, I have been doing a fair bit of testing on it. I put it on my inbound power use that moves more than once a minute, and with the once a minute PV copy it updates. Another thing I notice is that I can get it to wind up slowly, but when the error goes the other way it jumps back to zero.

(btw on the scaling, I just divided the power by 1000 in the 1 minute write automation so it is -5, to +5 and that seems to give me latitude.)

I really appreciate the work that goes into these things, and I have been involved in software dev in my life previously, and understand that it takes a fair bit of time and effort to test and find issues, so just take this as trying to help out (and not a complaint or anything like that). 2023-08-07_13-36-59

dxstp commented 11 months ago

Confirmed, this is should be fixed as soon as possible. As a workaround, I've created a "noise generator" and added this value to the sensor input value. The noise is just a toggle between 0 and 0.01°C, with an automation routine every second. I wonder if adding a specified amount of noise to a discrete input value (21.0, 21.5, ...) would be helpful for the controller to avoid oscillations and windup near the target value.

widmermar commented 1 month ago

Unfortunately, the resetting behaviour is still present and makes this PID unusable for many applications. If the setpoint is lowered, the PID-signal is reset to zero, thus no smooth decrease possible. Since this controller does not seem to get any updates, what alternative do you use instead? I want to control battery charging/discharging, thus needing a smooth up and down regulation, if possible even positive (charge) and negative (discharge).

soloam commented 1 month ago

I must admit that time is a little low at the moment to check this issues! But it's not forgotten! I'm sorry for all the time that you wasted because of this!

widmermar commented 1 month ago

Thanks for your feedback! I did not waste to much time, since it's always a learning curve. Let me know if I can contribute to this controller, I am a quick learner ;-)