DS18B20 smoothing and PID tuning

The other PID is the IBM version I mentioned earlier. It regulates my aging freezer.
Debug full message:

Yes I did mean that.
If it is a fresh install I wonder why the version of pid is not the latest.
I can’t find an ibm pid node. Can you provide a link please? Is it installed on this machine?

On the debug for the input can you put it on all the possible inputs (or disconnect the others please). I think the image posted only shows data from one of the links, though maybe there is nothing on the others. Would like to know for certain though.
We will get to the bottom of this eventually, thanks for your help analysing the problem.

I disconnected the setpoint insert and the other two inputs are for the enable, so I can turn it off and avoid a total freeze of my bucket of water.
I installed the PID using the palette manager. According to the manager the version is v1.1.2
The IBM version is node-red-contrib-PID-controller
OK-all debug nodes turned on and here is the result:

Are you kidding? This is the most coding fun I've had since I retired! I'm happy to help!

For curiosity sake, what’s the difference between Kp and PB? Do you know of a resource I could read up on?
Charles

I converted my UI to C so you foreigners won't have to convert in your head. :slight_smile:


You can disregard the setpoint. I'm hard coding it into the PID.
Thought you might be interested in a little history for your test rig.
I also noted that the GPIO is not turning on the freezer with these outputs. Heat is disconnected and it appears that a -2.1875 makes it want to heat. On the chart the cool status is the PID output +/- 19C.

CHarles

Unfortunately I have to go out this evening (which is now). I will sort out a debug version for you to use which will give us some diagnostic output so we can see what is happening.
Will answer the above questions then too.

I hope you have a nice evening.
Charles

To get the cool working properly with PID straight into cooler you will need to change the invert checkbox in the timeprop node so that 0 is full cool and 1 off. That is nothing to do with why the PID node output is negative though.

I have made a debug version which will give us some diagnostics to try and work out what is going on.
First rename the file .node-red/node_modules/node-red-contrib-pid/pid.js to pid.js.x and instead put the file you can download from [1] in its place. You should be able to download by right clicking the link and selecting Save Link As or something similar, depending on your browser.
Then stop node-red (node-red-stop) and restart it using
node-red-start
which will show you the log as it runs. Leave that terminal running and go to the browser and refresh the display (usually F5 or click the refresh button) and do whatever you do to send a process value to the pid node.
There are two possibilities as to what will happen (plus any I have not thought of).
If the debug output in the browser now shows a valid payload between 0 and 1 (so the new file has made it work) then please send me the original pid.js (now pid.js.x) so I can have a look at it. You can then carry on with your tuning using the new one.
If the debug output still shows the pid output is not in the range 0 to 1 then copy/paste the output from the terminal so I can see what my diagnostics are showing.

[1] https://www.dropbox.com/s/4halke68h1sdjot/pid.js?dl=0

Kp is a gain setting on the control, so the proportional (ie proportional to the process error) term is calculated using something like

p = Kp * (setpoint - processValue)

In the algorithm I use, PB is the proportional band, which can be thought of as a band around the setpoint where if the temperature is below the bottom edge of the band the then full heat will be asked for (thinking of a simple heat only system) and if it is above the top edge then no power will be asked for. Within the band the power asked for moves from full heat to none as the process crosses the band. In terms of a formula this is

p = (setpoint - processValue) / PB

Mathematically the two equations are identical, just with a different constant, but PB has some meaning in the real world which makes it much easier to get some sort of feel for what is going on.
The effect of the integral term (which is added to the p term above) is to move the band up or down around the setpoint so that when it is perfect control and the p term above is zero the integral term adds just the right amount of heat to keep the process at the right temperature. The Integral Time determines how quickly the band moves up and down. If the time is set too short then the band moves too quickly and overshoots the ideal point. So again by specifying the integral in this way gives some intuitive feel for the what it should be set too. In the case of your process you know that things settle out over tens of minutes so you know that 5 mins is going to be too quick for the integral and 2 hours is going to be too slow, so at least you have some sort of starting point. In the case of the Ki term in the conventional formula I would not have the slightest idea where to start.

Just a small point of order, which doesn’t contribute to the technical details, but worth clarifying. None of the PID nodes are affiliated with IBM.

There is one maintained by the core node-red project - https://flows.nodered.org/node/node-red-node-pidcontrol. Yes Dave and I work for IBM, but node-red is an independent project of the JS Foundation.

There is one maintained by @hardillb - https://flows.nodered.org/node/node-red-contrib-pid-controller. Ben was an IBMer when he published it, but did so as an individual, and he no longer works at IBM.

And there is Colin’s one - https://flows.nodered.org/node/node-red-contrib-pid

@knolleary can you possibly clear something up for us? If you look up at the screenshots you will see that there is a numeric value shown next to the blue dot in the status indicator by the Brewbucket pid (which is my node). Is there any way that can get there other than via a node.status assignment in the node? Mine specify the coloured dot, sometimes with fixed text, but none of the node.status assignments specify a numeric text value.
`

Hi knolleary!
I just read the license on the PID Node below.
node-red-contrib-pid-controller
/**

  • Copyright 2016 IBM Corp.
  • Licensed under the Apache License, Version 2.0 (the “License”);
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an “AS IS” BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    **/

I don’t mean to be smart-ass but why copyright it for IBM if not IBM?
Just curious.
Charles

Heh - good point. Looks like it hasn’t been properly updated since we moved everything over to the JS Foundation.

I love being right. :wink:

Colin:
Do you want me to set pb to 0 and Ti to 9999?

Not the pb, leave it at something sensible, Ti 9999. I understand the pb=0 problem. Check before you replace the file (if not too late) that you are still getting -ve values.

1 Like

@knolleary did you see my question a few posts above about the status indication?

Sorry, to late.
image

As you can see I'm getting output=0 from the PID now.

I don’t know where the 18.5 numeric text comes from. I didn’t specifically insert that myself but I’m really new to node-red and js both.