colinl / node-red-contrib-pid

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

Output when integral is locked #16

Closed SplinterII closed 3 years ago

SplinterII commented 3 years ago

It seems, when the integral term gets locked because the process is far from the setpoint, the PID output always goes to 0 (which leads to overheating in my use case).

Looking at the code I cannot figure out what happens to node. integral when the integral term gets locked. It seems node.integral is not set at all. If wind up is to be prevented, should'nt the I term be locked to 0 then?

colinl commented 3 years ago

I suspect you have not set something correctly. Can you post a chart showing the process value and the node output when the problem appears?

SplinterII commented 3 years ago

I'll be back when I get more clear what's happening, I'm not fully sure myself yet... thanks sofar.

colinl commented 3 years ago

Is it possible that you have the direction of the control reversed? The algorithm assumes that an increasing output from the node will cause the process value to rise. If your process value decreases when the output is high then you may need to invert the output before sending it to the process. You could do that with a Range node configured to scale the input range 0 to 1 to the output range 1 to 0.

SplinterII commented 3 years ago

This is exactly what's happening. If the pv (ie. CPU temperature) rises, the cooling fan of my Pi should blow more, ie. the PID should steer a higher value to the PWM pin. So I'm indeed mapping PID output 1-0 to PWM pin values 0-100.

colinl commented 3 years ago

You said at the start: It seems, when the integral term gets locked because the process is far from the setpoint, the PID output always goes to 0 (which leads to overheating in my use case). But if you are mapping 0 pid output to 100 PWM then that should cause increased cooling which should bring the process temperature down again, so what you describe should work.

SplinterII commented 3 years ago

Yes indeed. Let's close this for now, I can't seem the recreate the issue I was having. Thanks for your help anyway!

colinl commented 3 years ago

No problem, ask again if you have further issues.