Node-red-contrib-pid components values

I use node-red-contrib-pid module by colinl and while the node itself works fine the output values of the P,I,D components do not make much sense. When the temperature (PV) is lower than the setpoint the P component is negative, while the output increases (just as it should). Same goes for all 3 components. It looks like the sign is inverted when the components are output in the message properties.

As the author has explained at [question] signs of components · Issue #25 · colinl/node-red-contrib-pid · GitHub the component values should go down when the power should decrease (which makes sense) but I observe the opposite.

Again, the regulator operates perfectly fine, the question is only about the output component values.


The filled area is the output of the regulator, the lines are the components.

Sorry, I misread your original post on the issue you linked to. Lets try again.

Looking at the proportional term, conventionally in PID algorithms this is calculated by determining the error (which is PV - setpoint) and then scaling that by the proportional band or gain. That does indeed give a negative value when the process is low.

As you say, in order to generate the correct sign for the output power it is inverted and offset to give a power value in the range 0:1 by the line in pid.js:
power = -1.0/node.prop_band * (proportional + node.integral + node.derivative) + 0.5

I always assumed error to be setpoint-PV, not the reverse (so that one can add PV+error and get a target value, like in statistical modelling).
if you see error as PV-setpoint it becomes clear why the component values have counter-intuitive sign.
Thank you for the claiifcation.

It doesn't actually matter which way round it is of course, provided a correction is made to get the sign right at the end.

It looks like I have been doing it all wrong for 50 years. Luckily it doesn't matter provided the final answer is correct.

1 Like

anyway your implementation which basically replaces coefficients with timing is crazy cool! I've never seen such PID algos.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.