colinl / node-red-contrib-pid

A node-red PID loop controller node intended for the control of real world processes
Apache License 2.0
26 stars 18 forks source link

Initial integral documentation #17

Closed martenjacobs closed 3 years ago

martenjacobs commented 3 years ago

I'm using this node to control underfloor heating in my house. This works pretty well, but I've been struggling with persisting the integral value between restarts. My set-up caches the output integral in persistent storage, so it can feed the value back into the PID after flows are restarted, causing as little disruption to the heating system as possible. I thought this would be as simple as feeding back the cached integral in the integral_default key on startup, but this didn't work. It actually caused the integral to completely shift each time. Finally, I had to check the source code to find out that the initial value for the integral is calculated this way:

node.integral = (0.5 - node.integral_default)*node.prop_band;

So that means I have to supply my integral_default like this:

-(cached_integral/prop_band) + 0.5

This is fine, but I think it should at least be in the documentation.

colinl commented 3 years ago

Hi and thanks for the comments. That is an interesting way of achieving the result you want. The definition of integral_default, from the readme is: It should be set to an estimate of what the power requirement might be in order to maintain the process at the setpoint. So the way I have handled this in the past is not to persist the integral value but the power output, which should give a similar result when fed back into integral_default on startup. Your suggestion is actually rather better though I think. If you would like to submit a PR with suggested improvements to the readme that would be great.

martenjacobs commented 3 years ago

@colinl see #18

colinl commented 3 years ago

Closed by PR #18