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 17 forks source link

Ability to work with negative numbers? #29

Closed NorbNorb closed 4 months ago

NorbNorb commented 4 months ago

The description and the example indicate that this PID controller cannot be used with negative process variables for the input and output. I tried the example flow and set the "Output power when disabled" to -100. This value is output briefly, but then set to 0 again. How can I use this PID controller if my process allows positive and negative values? Examples are: Position along an axis, power flow, etc.

colinl commented 4 months ago

Hi @NorbNorb The process value can be anything you like, +ve or -ve. The output power value is always in the range 0 to 1. For a heating type process then 0 would be no heat and 1 would be full heat. You can scale the power to match the value you have to feed back to your process to control it. So if you wanted the min output to be -50 and the max to be 100 then use a Range node configured to scale the range 0:1 to the range -50:100 (or 100:-50 if it is that way round).

NorbNorb commented 4 months ago

Thanks!