# DS18B20 smoothing and PID tuning

**URL:** <https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015>\
**Category:** General\
**Created:** [22 June 2018 22:57 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015 "2018-06-22T22:57:42Z")\
**Posts on this page:** 20\
**Page:** 9

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2018 19:27 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/163 "2018-07-07T19:27:21Z")

</div>

> [@Backup](#):
>
> How about PID power output when disabled? After making the changes my freezer turned on even though the bucket temp was well below the setpoint.

That should be 1 (ie no cooling). Again that will change when the splitter node goes in again.  
The bit of the chart that we want to see (once it is up and running) is how it cools down from ambient or at least a good number of degrees above setpoint.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2018 19:46 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/164 "2018-07-07T19:46:49Z")

</div>

> [@Backup](#):
>
> It was on the output of the pid again, and it did fix it.

How very odd, you haven't got zero for PB or Integral Time or Max Sample Interval have you? If not then I don't understand how that can happen.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [7 July 2018 20:25 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/165 "2018-07-07T20:25:10Z")

</div>

My only zeros are derivative and smoothing.  
An unexpected byproduct of 95% scaling is the PID, effectively, never turns off. Disabling the PID only limits the output power to 5% so while I'm trying to make it back to 65F it is adding 5% on time every ten minutes.

I'm ready for a weekend. 🙂  
Charles

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2018 20:50 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/166 "2018-07-07T20:50:28Z")

</div>

With the Output Power When Disabled set to 1 (is it?) then that will go straight through the range node and the cooler should be off when the pid is disabled.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [7 July 2018 21:03 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/167 "2018-07-07T21:03:57Z")

</div>

Output power when disabled is set to 1 after it goes through the range node it is 0.95  
I thought that is what it is supposed to do. Maybe the scale should be 1.0 to 0 and 0.0 to 0.95?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2018 21:12 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/168 "2018-07-07T21:12:06Z")

</div>

Should be like this, so 1 maps to 1 and 0 maps to 0.95, or as configured in the node, the range 1 to 0 maps to the range 1 to 0.95  
 ![Screenshot-2018-07-07-22%3A06%3A16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e5721a7ff7ff1de7564f1fa6541c9b8dd7847196.png)

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [7 July 2018 21:47 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/169 "2018-07-07T21:47:22Z")

</div>

That makes a lot more sense and with PID disabled the output is to the GPIO pin is 0.

Thanks

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [8 July 2018 02:56 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/170 "2018-07-08T02:56:30Z")

</div>

I got influxdb installed along with grafana and I am able to reach the grafana server from my desktop. The problem is I assumed influxdb was a standard relational database like I am used to working with. Boy was I wrong.  
I may have something to report after I give my brain a rest and can absorb a new database.  
I did install your influxdb node and am exploring it. I think I got it connected to influxdb but not sure since grafana is not showing any data.

Hope you have a restful Sunday.  
Charles

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [8 July 2018 19:58 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/171 "2018-07-08T19:58:37Z")

</div>

Success!  
I am storing data in influxdb and graphing it in grafana across my network to my pc.  
I have my retention set to one day for now and it's just a test db but it works.  
I should have taken your advise first Colin. This combination is perfect for what I am doing.

The temps are pretty well equalized but I'm going to wait until tomorrow to start a trial run.  
I have to pay attention to my wife for a day or two.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 15:30 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/172 "2018-07-10T15:30:21Z")

</div>

Back to our own thread. I managed to extend the graph to 12 hours.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/ab1dec6379478e041c4460e29b81ba9c28d38bb2.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 16:09 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/173 "2018-07-10T16:09:57Z")

</div>

Can you define what the power scale is showing please.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 16:47 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/174 "2018-07-10T16:47:33Z")

</div>

Before I send the data to influxdb I do this math:  
`msg.payload = Number(1-payload);`  
Then in grafana I scale it to reflect our 5% limit.  
Math(\*100)  
So the power level is on a scale of 0 to 5%.  
I should probably do Math(\*200) which would give me a scale of 0 to 100%

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 17:19 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/175 "2018-07-10T17:19:08Z")

</div>

Actually the PID value is 0.9875 which is actually 0.0125 in a range of 0-0,5 so the actual percentage of power being used is 2.5%. Do you agree?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 19:19 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/176 "2018-07-10T19:19:11Z")

</div>

What you need to plot is the cool power as a percentage of the maximum we are allowing. To do that I would personally prefer to put the output of the PID algorithm, flipping 0 and 1, into influx, so that 0 is off and 1 is max cool (which is actually 5%, but that doesn't matter, it is still max cool). However if you prefer to put the actual cool power in that is ok, but scale the chart so that it shows 0 to .05 so that the graph shows the full range of power that we are allowing. At the bottom when there is no cool and at the top when the pid algorithm asks for max.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 19:44 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/177 "2018-07-10T19:44:11Z")

</div>

Lid is open and PID is disabled. Waiting for temp to rise.  
Here is the graph we were talking about.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a440dfc1c65af5f761c2340e1b02deb6874ba812.png)  
I think it's more readable and requires less monkey math.  
🙂  
Charles

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 19:58 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/178 "2018-07-10T19:58:47Z")

</div>

Looks good, now we can see what the power is doing.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 20:27 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/179 "2018-07-10T20:27:46Z")

</div>

Ya, in if I got my retention correct the wild power lines will go away in a few hours.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 July 2018 20:39 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/180 "2018-07-10T20:39:43Z")

</div>

Did you say you had it set to 24 hours? The problem with that is that you will not be able to look back in a few days or a week to see how it performed with certain tuning params. I generally have mine set to a year.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 20:43 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/181 "2018-07-10T20:43:34Z")

</div>

A typical fermenting cycle is 5 to 7 days but I sometimes go beyond that. Maybe 2 weeks? All those wild lines hurt my eyes though, I'd like to see them go. 😉  
I'll see if I can redo retention. It was a struggle to get it to 1d.

---

<div class="post-metadata">

**Author:** ![Backup](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/backup/32/862_2.png) [@Backup](https://discourse.nodered.org/u/Backup)\
**Post date:** [10 July 2018 20:48 UTC](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015/182 "2018-07-10T20:48:20Z")

</div>

I've only used 17% of my SD card so I guess I can afford some more storage and I may even want to look back at a previous batch to see how temp controll affected flavor.

[Previous page](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015.md?page=8)

[Next page](https://discourse.nodered.org/t/ds18b20-smoothing-and-pid-tuning/1015.md?page=10)
