Hysteresis node

#1

I’m looking for a hysteresis function and I’m struggling a bit …
I came across several threads mentioning the thermostat node.

But that node only does temp and assumes status false if temp is too high which is ok with a heater I guess…

But I’m trying to control a dehumidifier with it and I can think of many other use cases for a generic built in hysteresis node…

switching on ambient light sensors, humidity, temp, …

Do I miss the obvious solution?

Cheers,
Martin

0 Likes

#2

For simple hysteresis look at the RBE (report by exception) node

0 Likes

#3

I didn’t think the RBE node had the ability to specify a setpoint, I thought it was only for changes relative to previous values.

The node node-red-contrib-ramp-thermostat will do a simple thermostat with hysteresis and you can set it to ignore the ramp feature if you don’t want it. The fact that it is documented to refer to temperature is irrelevant, it can be any measurable process value. You might also like to look at node-red-contrib-pid which should be capable of providing much better control than a setpoint with hysteresis but is more complex to setup. PID control may well be overkill for your process in which case just go for the thermostat mode. Even if you want to use PID I would suggest getting it going with the t/stat first as that will iron out the basic issues.

1 Like

#4

I forgot to comment on that. If the output is the wrong way up for your system (so ON when it should be OFF) you can insert a simple node to invert it.

0 Likes

#5

If you need simple hysteresis and a setpoint then a simple switch node should be ok. Eg if greater than 26 send off, less than 24 send on, otherwise send nothing.

0 Likes

#6

Or use a change node :

hyst

0 Likes

#7

thank you for the ideas.
I’ll play around with change & function node…

Whats the difference in using function node as in compared to change node with jasonata expression?

0 Likes

#8

Maybe a function is easy to define otherwise I tend to avoid functions for simple stuff.

Function:

var setpoint = 20;
var hysteresis = 1;
var current = msg.payload;

if (current >= (setpoint+hysteresis)) {
    msg.payload = "on";
} else if(current <= (setpoint-hysteresis)) {
    msg.payload = "off";
} else {
    msg.payload = "nothing";
}

return msg;
0 Likes

#9

essentially just personal preference.
In extremis the change node should be faster as the function node runs in a sandbox - but unless you are operating in the region 1000s of messages per second area then it really won’t be noticeable.

0 Likes

#10

It isn’t just about the message rate though - the change node uses much less memory at runtime which can often be a more important factor than raw throughout.

0 Likes

#11

node-red-contrib-pid gets my vote. I’m using it for an irrigation system (albeit in my greenhouse!).
It is more difficult to set up, but there is an excellent demo setup which really helps.
The advantage to using a PID is that it will provide more accurate control, by reducing it’s output as it nears the setpoint, to avoid overrun, and also intervene to reduce the rate of change.

0 Likes

#12

My greenhouse heating system smooths out the values from the temperature sensor with a rolling average over the last 10 (one a minute) using node-red-node-smooth. I found that it stopped rapid switch around ‘on’ and ‘off’ temperatures.

0 Likes