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

Scaling for cooling #27

Closed cianpdx closed 1 month ago

cianpdx commented 9 months ago

Inverting the output does not have the expected behavior for cooling

Consider a heating case: PB = 1 (no I or D) SV = 10, AV = 9.9, Output = .1 as expected

The equivalent cooling case (using inverted output):

SV = 10, AV = 10.1, Output = 0 , inverted to 1.0, equivalent to full cooling power. in effect, it controls to SV-PB instead of SV

To get around this I change the AV to be (SV-AV)+SV on the input to the PID block:

SV = 10, AV = 10.1

AV adjusted = (10-10.1)+10 = 9.9 Output = .1 as expected.

colinl commented 9 months ago

By "no I" do you mean you have set it to a large time? That does not fully disable I, it just makes it very slow acting.

What have you got Initial Integral set to? I guess you have set to zero, the default is 0.5. If you set it to 1 then you will get the effect you are looking for.

Are you intending to use integral eventually? If so then all this does is adjust the starting point. Once the integral kicks in then the loop will sort itself out.

colinl commented 9 months ago

Did that help explain what is going on?

cianpdx commented 9 months ago

Yes Integral is 100 million or something.

Even if I term will eventually counteract the P term, generally seems odd. Also makes it difficult to use gains determined by another simulator if the behavior will not be similar. Maybe this is just a feature request to add a cooling option.

I will close this and just use the polarity switch on the input side to make the output as expected.

colinl commented 9 months ago

I would like to understand the problem better if possible please, as if the node is missing a feature then I would like to know. Firstly, will you eventually want to use Integral and/or Derivative, or do you want just proportional control with no I or D?

cianpdx commented 7 months ago

Hi, I am back playing with this. I expect to use just P+I for this case.

At high level, inverting the output is not the same as inverting the logic of the loop. Waiting for I term to adjust for this isn't an elegant way to approach it. An option to change to heat or cool would be ideal.

this node handles it more typically. I will use it instead. https://flows.nodered.org/node/node-red-node-pidcontrol

colinl commented 7 months ago

Waiting for I term to adjust for this isn't an elegant way to approach it.

Approximately what power value into the cooler do you expect once it has reached a stable temperature?