# PID, strange behavior

**URL:** <https://discourse.nodered.org/t/pid-strange-behavior/28559>\
**Category:** General\
**Created:** [18 June 2020 16:55 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559 "2020-06-18T16:55:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilgio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ilgio/32/24182_2.png) [@ilgio](https://discourse.nodered.org/u/ilgio)\
**Post date:** [18 June 2020 16:55 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/1 "2020-06-18T16:55:11Z")

</div>

stable situation:  
setpoint: 26  
pv (temperature): 30  
payload: 0

```auto
{"payload":0,"pv":30,"setpoint":26,"proportional":4,"integral":9.206083333333336,"derivative":0,"smoothed_value":30,"_msgid":"ae571205.3a6de"}

```

after I put the setpoint at 28, and the payload goes to 0.26 and then drops with each hit

```auto
{"payload":0.26025914296199754,"pv":28,"setpoint":26,"proportional":2,"integral":9.206083333333336,"derivative":-5.931784478497281,"smoothed_value":28,"_msgid":"b7db2087.52d8b"}

```

because it makes this output that the temperature is 30 .. and the setpo int at 28 is still lower and therefore should remain 0

 ![Schermata 2020-06-18 alle 18.41.54](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/163bf1c64a1c0c7ccc52572efd6802fa75df3509.jpeg) ![Schermata 2020-06-18 alle 18.42.06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19da52007b8887739d2ba16a2ade3c781d4e9313.jpeg)

---

<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:** [18 June 2020 17:42 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/2 "2020-06-18T17:42:21Z")

</div>

Sorry, I don't fully understand. Generate a chart showing the setpoint, the temperature and the node output and post the result. Drawing charts is the only way to see what is happening with PID.

---

<div class="post-metadata">

**Author:** ![ilgio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ilgio/32/24182_2.png) [@ilgio](https://discourse.nodered.org/u/ilgio)\
**Post date:** [18 June 2020 18:03 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/3 "2020-06-18T18:03:10Z")

</div>

when I input setpoint, near to temperature, but not greater than the current temperature  
I view payload number \> 0

it should stay 0

---

<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:** [18 June 2020 18:11 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/4 "2020-06-18T18:11:34Z")

</div>

Make a chart please.

---

<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:** [18 June 2020 18:15 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/5 "2020-06-18T18:15:54Z")

</div>

But also remember, if you increase the setpoint then the output power will probably increase, that is the way pid works. Once the loop has been tuned properly it will make sense. If it is not yet properly tuned then the operation may appear to be illogical. So if you have not tuned it yet then do that first.

---

<div class="post-metadata">

**Author:** ![ilgio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ilgio/32/24182_2.png) [@ilgio](https://discourse.nodered.org/u/ilgio)\
**Post date:** [18 June 2020 19:45 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/6 "2020-06-18T19:45:42Z")

</div>

I want use pid for command a fancoil with 3 fan speed and off  
pid between 0 - 0.33 -\> speed 1  
pid between 0.34 - 0.66 -\> speed 2  
pid between 0.67 - 1 -\> speed 3  
pid 0 -\> off

---

<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:** [18 June 2020 20:13 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/7 "2020-06-18T20:13:18Z")

</div>

I suppose that should work, obviously it won't be able to sit accurately on the setpoint as you cannot get full proporional control of the power so the best it can do is to settle out switching between two fan speeds. However the tuning algorithm should work ok to get initial values for the loop. Have you tried the tuning algorithm suggested in the readme?

---

<div class="post-metadata">

**Author:** ![ilgio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ilgio/32/24182_2.png) [@ilgio](https://discourse.nodered.org/u/ilgio)\
**Post date:** [18 June 2020 20:25 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/8 "2020-06-18T20:25:08Z")

</div>

Don’t work for fancoil because at off (pid=o) doesn’t arrive never.  
What read me?  
[This example?](https://flows.nodered.org/flow/42f125b56a00dd5d1433c2f8023263e9)

---

<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:** [18 June 2020 20:32 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/9 "2020-06-18T20:32:27Z")

</div>

In the node's page on the node red flows site, npm and github it says  
"A tuning guide that walks through a simple tuning procedure using the above flow is available at [http://blog.clanlaw.org.uk/pid-loop-tuning.html](http://blog.clanlaw.org.uk/pid-loop-tuning.html)"

---

<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:** [18 June 2020 20:33 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/10 "2020-06-18T20:33:54Z")

</div>

Are you not able to use a time proportion output in order to get full control of the fan?

---

<div class="post-metadata">

**Author:** ![ilgio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ilgio/32/24182_2.png) [@ilgio](https://discourse.nodered.org/u/ilgio)\
**Post date:** [19 June 2020 08:25 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/12 "2020-06-19T08:25:10Z")

</div>

I use for cold

 ![Schermata 2020-06-19 alle 10.24.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/235f31aae57428d1ab4b54a0f82850334f371a3f.jpeg)  
I add a function

```auto
var pid = 1 - msg.payload;
msg.payload = pid

return msg;

```

![Schermata 2020-06-19 alle 10.16.06](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69c3a25b98fdcc241c7053ce7deae84e78ede3c7.jpeg)

---

<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:** [19 June 2020 08:55 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/13 "2020-06-19T08:55:41Z")

</div>

You have a massive proportional band (22 degrees) so from the point of view of the pid the temperature is well within the proportional band as the error is only a few degrees. However even so, the power should eventually go to zero.  
I suspect that proportional band setting is much too large, but as I said the first thing to do is to use the tuning algorithm to get initial approximate values for the proportional and integral settings. You probably won't need derivative.  
For the chart I suggest scaling the output value up a bit so that will be easier to see.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 August 2020 08:55 UTC](https://discourse.nodered.org/t/pid-strange-behavior/28559/14 "2020-08-18T08:55:45Z")

</div>

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