DS18B20 smoothing and PID tuning


#41

I just updated to the latest version of node-red.
Node-Red version: v0.18.7
Node.js version: v6.12.2


#42

Do you know which version of pid node you are using?

The -infinity display looks like a bug in the debug node if the payload is null, but that shouldn’t happen either.


#43

According to Palett Manager,
PID version: v1.1.2


#44

v1.1.2 is fine, the latest is 1.1.3 but that was only documentation clarification.

I am completely at a loss at the moment. Have you been looking at the source of the node in .node-red/node-modules/node-red-contrib-pid at all? Is it possible the code was accidentally changed. Otherwise, as I said, I am completely at a loss.

Could you disconnect the input to the pid node too and try injecting a value and see if you can get a similar effect? If so then export that section of the flow so I can try it here.

I am running the same version of node-red (0.18.7) but I don’t see the payload values displayed by the nodes, just the status dots, does anyone know why that might be?

When you said earlier the two messages are different I am only seeing one message in the post, am I missing something there?

It’s getting late here so I will have another look tomorrow. The only other things I can suggest immediately are to re-start node-red just in case, and try re-installing the node in case it has somehow got corrupted.


#45

I uninstalled pid and reinstalled. set parameters to zero and get the -infinity% on debug.node status. On debug.node complete to debug window I get nothing. (?)

By different messages I’m refering to the debug.node status which is -infinity% and the debug window which payload is null. Message 38 of 44.

You may be getting the three dots if your debug window is not wide enough.


#46

Might infinity be a divide by zero issue?


#47

If there is nothing in the debug window and the debug node is enabled and you have fully refreshed the browser since restarting node-red or similar then that must mean that the PID node has not actually sent out a message yet. You should see a message each time it is sent a process value.

[Edit] Try a full browser refresh (Ctrl+F5 on Firefox) and try again. I have seen missing debug messages after modifying flows occasionally and a refresh fixes it.


#48

Yes, I have been considering that, and can now explain the apparently null payload if PB is set to zero. I have raised an issue on the node [1]. The payload is actually NaN (or possibly ±Infinity) but there must be a bug in the Debug node that is showing that as a null payload in the debug window. Thanks for helping me to find that.

For the moment go back to a PB of 0.2 or similar and see if you are still getting the payload <0 or >1.

[1] https://github.com/colinl/node-red-contrib-pid/issues/7


#49

Also there seems to be a bug in the debug node somewhere, sending Infinity as a value to a debug node stops debug nodes from working until you force a full browser refresh. I will post separately about that.


#50

For reference there seem to be two bugs in the debug node. When sent a value of NaN then if set to show complete message it shows a null payload [1] and if sent a value of Infinity then the debug node shows nothing and all debug nodes show nothing until the browser is refreshed [2]. That together with the fact that there is a bug in the pid node that can cause it to pass on these values if the PB is zero explains most of those symptoms I think. I wonder whether there has been a subtle change in the way numeric overflow is handled because I am sure it did not do that originally.

[1] https://github.com/node-red/node-red/issues/1779
[2] https://github.com/node-red/node-red/issues/1778


#51

Good morning Colin!
Here are the process parameters:
image
And here are the results:


I’m on my laptop which isn’t the best way to work on it. After I walk my doggie and make some coffee I’ll get more done.
Charles


#52

Setting Ti to zero (which is not a valid integral time as it effectively means infinite integral effect) triggers the same bug both in the PID and therefore potentially in the debug node. Set Ti to a large value such as 9999. Initial integral zero is fine as that is a power value, and Td at zero is also ok as zero seconds of derivative means no derivative effect.

[Edit] By the way do you know what you have done to get a value shown in the pid status by the pid node, I don’t get that.


#53

Also can you export the flow just of the pid node and paste it here so I can check I have exactly the same settings as you. In case you don’t know put three backticks on separate lines before and after the pasted flow to ensure it is shown here as it should be.


#54

Debut.status under debug.node, not available with complete msg object selected.

PID settings you requested:

Results:


#55

Not sure what a backtick is…
[{“id”:“2805617b.3c39c6”,“type”:“comment”,“z”:“8aae4b77.5f52a8”,“name”:“Temperature Control”,“info”:"",“x”:230,“y”:40,“wires”:[]},{“id”:“34b4b935.381f7e”,“type”:“link out”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBucket_Heat_PID”,“links”:[“17d08261.4b2376”],“x”:975,“y”:130,“wires”:[]},{“id”:“7fb90422.38a1cc”,“type”:“link out”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBox_Cool_PID”,“links”:[“2f2d49d.cd842b6”],“x”:975,“y”:170,“wires”:[]},{“id”:“cd0aa371.e74d4”,“type”:“comment”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBox PID Loop Settings”,“info”:“PID Control Node\n\nThis node has 2 outputs, the first is for \nheating control, the second is for cooling \ncontrol.\n\nBoth outputs provide a floating point value \nbetween 0 and 10.\n\nSettings\n\nThe node takes the following configuration values:\n\n Gain: The % gain to apply to the difference between the setpoint and input value\n Ti: The time in seconds over which to apply the gain value\n Dead Band: The +/- each side of the setpoint to consider the setpoint reached\n Recalculation Time: The time in seconds between each calculation of values\n Setpoint Topic: the topic a message should have to set the setpoint\n Fire Topic: the topic a message should have to enable/disable Fire mode\n Fixed Value Topic: the topic a message should have to enable/disable fixed output mode\n Fixed Value: the value to output when in fixed mode, +ve for heating -ve for cooling\n\nOperations\n\nBefore you can use the node you need to set \nthe setpoint, to do this you need send a \nmessage with the setpoint value as the payload \nand a topic set to the Setpoint Topic \nconfigured in the editor UI.\n\nFire mode sets all outputs to 0. \nFire mode is enabled by sending a message \nwith a payload of false to and a topic equal \nto the Fire Topic. To disable Fire mode send \na message with a payload of true and a topic \nequal to the Fire Topic”,“x”:530,“y”:40,“wires”:[]},{“id”:“a6666729.59d64”,“type”:“link in”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBox_Stop”,“links”:[“3cf71be3.8491dc”,“bf31d5f2.1a3828”],“x”:295,“y”:120,“wires”:[[“e8716a19.58a768”]]},{“id”:“631bb978.f50118”,“type”:“link in”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBox_Start”,“links”:[“9281b062.7edd48”,“859b757a.2891d8”,“d025e0d6.f340d”],“x”:295,“y”:80,“wires”:[[“e8716a19.58a768”]]},{“id”:“858fbfb3.29de7”,“type”:“function”,“z”:“8aae4b77.5f52a8”,“name”:“Split Heat/Cool”,“func”:"/* A function designed to be used with node-red-contrib-pid in applications where both\n * heating and cooling are available to control the system.\n * The node is given a power value in msg.payload in the range 0 to 1, such as is produced by \n * node-red-contrib-pid and splits this into a heat power (o/p 1) and cool power (o/p 2) where\n * each is in the range 0 to 1. These can then be fed directly into an output device, if this\n * is continuously variable, or they may be passed to node-red-contrib-timeprop nodes to generate\n * time proportioned on/off outputs.\n * There are two particular issues to be dealt with in a heat/cool application. Firstly is the fact\n * that the cooling device may be more or less powerful than the heating device. It is necessary\n * therefore to be able to adjust the gain of the system separately for heating and cooling. Secondly\n * is the highly non-linear response of some devices, notably refrigerant systems, that can have a\n * large effect initially, then this tails off. To compensate for this it is useful to have an \n * overlap range where both heat and cool are slightly on.\n *\n * To allow for these requirements two variables can be set below. The value of the power input value\n * where the heating starts to come on is determined by the variable heatMin. Above this value the\n * heating will rise till it is fully on with an input of 1.\n * The cooling is fully on when value of the power input is 0, and falls till the cooling is fully\n * off at an input of coolMin.\n *\n * If the heating and cooling systems are of similar power then set heatMin and coolMin both to 0.5\n * in which case input values of 0.5 to 1.0 will map to heating outputs of 0.0 to 1.0,\n * and 0.5 down to 0.0 will map to cooling 0.0 to 1.0.\n * If, for example, the cooling system is more powerful than heating then they can both be set\n * to something like 0.7 which increases the gain in the heating region and reduces it\n * in the cooling region, to compensate for the different powers in the heating/cooling systems.\n * If some overlap is desired (so that both heat and cool are on slightly near the crossover\n * point) then overlap the two settings so that, for example, heatMin might be 0.45 and coolMin\n * might be 0.55\n */\n\n// set these as described above\nvar heatMin = 0.5; // the value of input corresponding to 0 heat o/p\nvar coolMin = 0.5; // the value of input corresponding to 0 cool o/p\n \nvar power = msg.payload;\nvar heat = (power - heatMin)/(1 - heatMin);\n// limit to range 0 to 1\nheat = Math.min(Math.max(heat, 0), 1);\nvar cool = (coolMin - power) / coolMin;\n// limit to range 0 to 1\ncool = Math.min(Math.max(cool, 0), 1);\nreturn [{payload: heat}, {payload: cool}];\n",“outputs”:“2”,“noerr”:0,“x”:810,“y”:40,“wires”:[[],[]]},{“id”:“17c982c3.59a825”,“type”:“debug”,“z”:“8aae4b77.5f52a8”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“payload”,“x”:800,“y”:80,“wires”:[]},{“id”:“e25eceb3.16d238”,“type”:“link in”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBucket_RX”,“links”:[“5ada9764.19b6a”],“x”:295,“y”:160,“wires”:[[“c7a2924f.956ff8”,“e8716a19.58a768”]]},{“id”:“c7a2924f.956ff8”,“type”:“debug”,“z”:“8aae4b77.5f52a8”,“name”:"",“active”:true,“tosidebar”:false,“console”:false,“tostatus”:true,“complete”:“payload”,“x”:570,“y”:80,“wires”:[]},{“id”:“e8716a19.58a768”,“type”:“PID”,“z”:“8aae4b77.5f52a8”,“name”:“BrewBucket.PID”,“setpoint”:“18.25”,“pb”:“0.2”,“ti”:“9999”,“td”:0,“integral_default”:“0”,“smooth_factor”:“0”,“max_interval”:“0”,“enable”:1,“disabled_op”:0,“x”:580,“y”:160,“wires”:[[“17c982c3.59a825”,“7fb90422.38a1cc”,“2c24d68b.d3ac72”]]},{“id”:“2c24d68b.d3ac72”,“type”:“debug”,“z”:“8aae4b77.5f52a8”,“name”:"",“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“x”:760,“y”:210,“wires”:[]}]


#56

That shows the value on the debug node. It is how you have a value showing on the pid node that I don’t understand.
The backtick is similar to a single quote but sloping left at the top. On my keyboard it is the the top left hand key next to the ‘1’ key.
Can you edit your previous post and put the backticks in please. Then in the preview pane it should look like

[here is the flow...]

#57

[{"id":"2805617b.3c39c6","type":"comment","z":"8aae4b77.5f52a8","name":"Temperature Control","info":"","x":230,"y":40,"wires":[]},{"id":"34b4b935.381f7e","type":"link out","z":"8aae4b77.5f52a8","name":"BrewBucket_Heat_PID","links":["17d08261.4b2376"],"x":975,"y":130,"wires":[]},{"id":"7fb90422.38a1cc","type":"link out","z":"8aae4b77.5f52a8","name":"BrewBox_Cool_PID","links":["2f2d49d.cd842b6"],"x":975,"y":170,"wires":[]},{"id":"cd0aa371.e74d4","type":"comment","z":"8aae4b77.5f52a8","name":"BrewBox PID Loop Settings","info":"PID Control Node\n\nThis node has 2 outputs, the first is for \nheating control, the second is for cooling \ncontrol.\n\nBoth outputs provide a floating point value \nbetween 0 and 10.\n\nSettings\n\nThe node takes the following configuration values:\n\n Gain: The % gain to apply to the difference between the setpoint and input value\n Ti: The time in seconds over which to apply the gain value\n Dead Band: The +/- each side of the setpoint to consider the setpoint reached\n Recalculation Time: The time in seconds between each calculation of values\n Setpoint Topic: the topic a message should have to set the setpoint\n Fire Topic: the topic a message should have to enable/disable Fire mode\n Fixed Value Topic: the topic a message should have to enable/disable fixed output mode\n Fixed Value: the value to output when in fixed mode, +ve for heating -ve for cooling\n\nOperations\n\nBefore you can use the node you need to set \nthe setpoint, to do this you need send a \nmessage with the setpoint value as the payload \nand a topic set to the Setpoint Topic \nconfigured in the editor UI.\n\nFire mode sets all outputs to 0. \nFire mode is enabled by sending a message \nwith a payload of false to and a topic equal \nto the Fire Topic. To disable Fire mode send \na message with a payload of true and a topic \nequal to the Fire Topic","x":530,"y":40,"wires":[]},{"id":"a6666729.59d64","type":"link in","z":"8aae4b77.5f52a8","name":"BrewBox_Stop","links":["3cf71be3.8491dc","bf31d5f2.1a3828"],"x":295,"y":120,"wires":[["e8716a19.58a768"]]},{"id":"631bb978.f50118","type":"link in","z":"8aae4b77.5f52a8","name":"BrewBox_Start","links":["9281b062.7edd48","859b757a.2891d8","d025e0d6.f340d"],"x":295,"y":80,"wires":[["e8716a19.58a768"]]},{"id":"858fbfb3.29de7","type":"function","z":"8aae4b77.5f52a8","name":"Split Heat/Cool","func":"/* A function designed to be used with node-red-contrib-pid in applications where both\n * heating and cooling are available to control the system.\n * The node is given a power value in msg.payload in the range 0 to 1, such as is produced by \n * node-red-contrib-pid and splits this into a heat power (o/p 1) and cool power (o/p 2) where\n * each is in the range 0 to 1. These can then be fed directly into an output device, if this\n * is continuously variable, or they may be passed to node-red-contrib-timeprop nodes to generate\n * time proportioned on/off outputs.\n * There are two particular issues to be dealt with in a heat/cool application. Firstly is the fact\n * that the cooling device may be more or less powerful than the heating device. It is necessary\n * therefore to be able to adjust the gain of the system separately for heating and cooling. Secondly\n * is the highly non-linear response of some devices, notably refrigerant systems, that can have a\n * large effect initially, then this tails off. To compensate for this it is useful to have an \n * overlap range where both heat and cool are slightly on.\n *\n * To allow for these requirements two variables can be set below. The value of the power input value\n * where the heating starts to come on is determined by the variable heatMin. Above this value the\n * heating will rise till it is fully on with an input of 1.\n * The cooling is fully on when value of the power input is 0, and falls till the cooling is fully\n * off at an input of coolMin.\n *\n * If the heating and cooling systems are of similar power then set heatMin and coolMin both to 0.5\n * in which case input values of 0.5 to 1.0 will map to heating outputs of 0.0 to 1.0,\n * and 0.5 down to 0.0 will map to cooling 0.0 to 1.0.\n * If, for example, the cooling system is more powerful than heating then they can both be set\n * to something like 0.7 which increases the gain in the heating region and reduces it\n * in the cooling region, to compensate for the different powers in the heating/cooling systems.\n * If some overlap is desired (so that both heat and cool are on slightly near the crossover\n * point) then overlap the two settings so that, for example, heatMin might be 0.45 and coolMin\n * might be 0.55\n */\n\n// set these as described above\nvar heatMin = 0.5; // the value of input corresponding to 0 heat o/p\nvar coolMin = 0.5; // the value of input corresponding to 0 cool o/p\n \nvar power = msg.payload;\nvar heat = (power - heatMin)/(1 - heatMin);\n// limit to range 0 to 1\nheat = Math.min(Math.max(heat, 0), 1);\nvar cool = (coolMin - power) / coolMin;\n// limit to range 0 to 1\ncool = Math.min(Math.max(cool, 0), 1);\nreturn [{payload: heat}, {payload: cool}];\n","outputs":"2","noerr":0,"x":810,"y":40,"wires":[[],[]]},{"id":"17c982c3.59a825","type":"debug","z":"8aae4b77.5f52a8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","x":800,"y":80,"wires":[]},{"id":"e25eceb3.16d238","type":"link in","z":"8aae4b77.5f52a8","name":"BrewBucket_RX","links":["5ada9764.19b6a"],"x":295,"y":160,"wires":[["c7a2924f.956ff8","e8716a19.58a768"]]},{"id":"c7a2924f.956ff8","type":"debug","z":"8aae4b77.5f52a8","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","x":570,"y":80,"wires":[]},{"id":"e8716a19.58a768","type":"PID","z":"8aae4b77.5f52a8","name":"BrewBucket.PID","setpoint":"18.25","pb":"0.2","ti":"9999","td":0,"integral_default":"0","smooth_factor":"0","max_interval":"0","enable":1,"disabled_op":0,"x":580,"y":160,"wires":[["17c982c3.59a825","7fb90422.38a1cc","2c24d68b.d3ac72"]]},{"id":"2c24d68b.d3ac72","type":"debug","z":"8aae4b77.5f52a8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":780,"y":210,"wires":[]}]


#58

back tick added in post.
Did I do it? :wink:


#59

Yes, thanks. You could just have editted your previous post and put them in (the pen symbol below the post).
What is the other pid node you have installed, if it is still installed,I wonder whether it has the same type and there is some cross coupling or something.
Finally can you put a debug node on the message going into the pid node and show the full message there please?
Thanks.


#60

Do you mean this:
image
If so, I didn’t put it there. I know how, but the PID is a fresh, unmolested, install.
(?)
Charles