# Problem with dynamic PID parameter change (node-red-contrib-pid)

**URL:** https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829
**Category:** General
**Created:** [5 May 2019 13:56 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829 "2019-05-05T13:56:59Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [5 May 2019 13:56 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/1 "2019-05-05T13:56:59Z")

</div>

Hi all  
I am a homebrewing, the process I am trying to control requires the control of an electric pot  
with 28 liters of water in which some kg of malts are immersed, at different temperature steps.

To try to keep the temperature I use node node-red-contrib-pid

Each recipe can vary in the quantity of liters of water and kg of immersed malts  
An example a receipe step ...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4dbd375224c723ad91ee46eb0f58e4bbb438d48e.png)

For this the 'first time' that I make a new recipe,  
I must be able to change the parameters dynamically ( es. Prop\_Band ),  
to make the T oscillate, as little as possible,  
around the value of the setpoint of each step.

My idea is for each recipe to find the right parameters and store them in a 'profile',  
which I will use when replicing a recipe.

I tried to dynamically change the Prop\_Band value, during the heating process  
but I get an abnormal result

TEST RESULT  
Initially I set the PB = 5 and the SetPoint = 28 in the PID and everything works fine.

When I try to modify the PB from 5 to 3,  
I verify that also the PID set point has been modified,  
the PID starts to intervene at 24 and ends at 27

The anomaly that returned is that,  
the change in the value of the PB took place correctly,  
but the SetPoint has also decreased by going from 28 to 27

I did other tests ...  
if I change PB = 2 the SetPoint goes down to 26.5  
if I change PB = 1 the SetPoint goes down to 26

DESCRIPTION OF THE ENVIRONMENT SYSTEM  
The pot has a 2.8Kw electric heater on the base to heat the water.

A pump is applied to the pan tap which allows the recirculation  
of the liquid during operation.

The temperature is read with a probe,  
at the exit from the tap, before the pump enters.

Inside the pot, there is a basket with a perforated bottom,  
equipped with feet to raise the basket from the bottom,  
avoiding direct contact of the malts with the heating elements

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5ef5dd74219d335cece7e04fd67974b478ed41be.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: [5 May 2019 14:39 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/2 "2019-05-05T14:39:20Z")

</div>

> [@batigolle](#):
>
> When I try to modify the PB from 5 to 3,  
> I verify that also the PID set point has been modified,  
> the PID starts to intervene at 24 and ends at 27

Put a debug node showing what is going into the pid node to change the PB and another on the output, both set to show complete message. Post what you see when you try to change the PB.

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [5 May 2019 15:41 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/3 "2019-05-05T15:41:42Z")

</div>

I entered the debug nodes, here is the result ...

Every 2 seconds the probe temperature is sent to the PID.  
Message for PID entry  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/44c649993b7603515593de1bf5359ee93eb3da13.png)

Message for PID input, when I manually start a step, to set the setpoint  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e788a2b978900f26f7c0df0f296baabf09c85fc8.png)

Message at the exit of the PID, before and after the attempt to modify the Prop\_Band.  
Between the two messages, there is the message sent to the PID for the PB change

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7b1cc39e458fd728ab799e3c2b4980d71960a933.jpeg)

To do the tests, I didn't use the pot, I entered a recipe with low temperatures (SetPoint 28 ° C).  
By manually heating the probe, I visually check on the screen, what are the values at which the PID starts and ends working  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/00676f638abcc81dcda84f2ae4f7fd355fd57beb.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: [5 May 2019 15:58 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/4 "2019-05-05T15:58:57Z")

</div>

You can see from the debug output that the setpoint has not changed (it is in the output message).  
What Ti and Td have you got?

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [5 May 2019 16:35 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/5 "2019-05-05T16:35:05Z")

</div>

You are right, I have also seen that in the output of the PID, the message, maintains the previous value of the setpoit, but .....  
in practice it is not so, in the test, it behaves as if the setpoint had changed (diminished)

You can see from the photo, after changing the PB from 5 to 3 ....  
the setpoint is 28, the probe is at 27.4 and the PID output = 0  
this is not correct, it should go to zero after the probe reaches 28  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c1433635fcfdb3f57b14449c126c2e5e25f0ac68.jpeg)

Setup PID

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

OUPUT PID

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d1c033cfd4e79ff371179c1e25a87e26e7d1dae0.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: [5 May 2019 17:06 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/6 "2019-05-05T17:06:08Z")

</div>

Firstly consider what the definition of setpoint is. The definition is the value that the process will settle out at after equilibrium is reached. It is not (normally) in the middle of the proportional band as that would imply 50% power when the process is on the setpoint. The way a PID algorithm works is to move the proportional band around the setpoint (under the control of integral) to get a stable process with the pv at the setpoint.

Also I see you have Ti set to 1 second. That means that the proportional band will swing wildly about over a few seconds, making it impossible to find the edges of the proportional band in the way you have tried. Set it to 3600 and try again. What value of Ti did you determine gave you good control? I would have expected maybe around 20 minutes for your process (so Ti = 1200).  
Did you follow the tuning technique linked to from the node's readme?  
[http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html](http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.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: [6 May 2019 08:13 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/7 "2019-05-06T08:13:17Z")

</div>

Actually I see that you have indeed found a bug in the PID node, so thanks for finding that. The result is that for a short time after changing the PB dynamically it is possible to get exactly the symptom you have found, with the process below the setpoint, but the power output 0. It is not a serious issue as the normal response of the control loop will cause the situation to recover. In normal operation with a well tuned system it is unlikely that this would be seen. However I have raised an issue and will get a fix in today, hopefully. Thanks again.

> <https://github.com/colinl/node-red-contrib-pid/issues/10>

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 09:54 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/8 "2019-05-06T09:54:28Z")

</div>

> [@Colin](#):
>
> Did you follow the tuning technique linked to from the node's readme?  
> [http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html](http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html)

I think I was one of the first to read it, you published it in the old forum ( google groups ),  
for me it's like the 'bible' 🤣  
I also translated it into Italian (I tried! 😉)

Thanks for the support !

---

<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: [6 May 2019 10:12 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/9 "2019-05-06T10:12:20Z")

</div>

I have released v1.1.5 of node-red-contrib-pid with the fix for the proportional band becoming dissociated from the setpoint. Available now from all good npm repositories.

If my guide is your bible then you should know better than to have Ti set to 1 second 🙂  
I may have to smite you with a bolt of lightning.

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 16:26 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/10 "2019-05-06T16:26:10Z")

</div>

> [@Colin](#):
>
> If my guide is your bible then you should know better than to have Ti set to 1 second 🙂  
> I may have to smite you with a bolt of lightning.

🤣🤣🤣  
⚡💥

however there is a reason ... 😇  
I had this problem a year ago, I thought it was caused by incorrect data being sent to the PID.  
A few days ago, I read about the same problem on GITHUB "Problem setting values dynamically # 9" and I intervened, describing my experience

I had modified my program to calculate the Oveshot and T1, as indicated by your document  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c2a1e4799a3101d0ca2b8d70156033178faea04c.png)  
to find a solution to the problem, I subsequently re-modified the calculated values and remained a bit at random 😪

later, I update the node and let you know

---

<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: [6 May 2019 16:35 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/11 "2019-05-06T16:35:21Z")

</div>

Oh, I thought you were the originator of #9 on github, when you joined in I did not notice that you were a new contributor. The original problem on that issue was not the one you have found, it was due to a misunderstanding on the part of the originator.

When you say "remained a bit random" do you mean you are having problems getting it tuned well? If so I will gladly try to help. Your process does not look as if it should be difficult to control.

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 16:57 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/12 "2019-05-06T16:57:51Z")

</div>

> [@Colin](#):
>
> When you say "remained a bit random" do you mean you are having problems getting it tuned well? If so I will gladly try to help. Your process does not look as if it should be difficult to control.

a year ago ... failing to solve the problem, I gave up the tests 😟,  
without putting back the correct values

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 17:01 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/13 "2019-05-06T17:01:23Z")

</div>

> [@Colin](#):
>
> The original problem on that issue was not the one you have found, it was due to a misunderstanding on the part of the originator.

true, but it helped me to understand how to send the data correctly to the PID  
and this prompted me to try again ...

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 19:27 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/14 "2019-05-06T19:27:34Z")

</div>

I did a test with the new version 1.1.5  
but I continue to always find the same problem 😔

---

<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: [6 May 2019 19:42 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/15 "2019-05-06T19:42:27Z")

</div>

Did you remember to restart node-red?

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 19:45 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/16 "2019-05-06T19:45:27Z")

</div>

Yes, after upload,  
I turned off and restarted the system (Raspberry)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e81bccccbc9c00ccedb15a97f67e4e3385603676.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: [6 May 2019 19:46 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/17 "2019-05-06T19:46:39Z")

</div>

Can you post the debug again so I can see? Set Ti to a sensible value if you have not already done that, to stop that confusing things.  
**[Edit]** Also could you expand the dots on one of them so I can see all the numbers please.

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 19:55 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/18 "2019-05-06T19:55:54Z")

</div>

> [@Colin](#):
>
> Set Ti to a sensible value if you have not already done that, to stop that confusing things.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/766ce9fff326a98db68acce8ab7457ca390696b1.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: [6 May 2019 20:09 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/19 "2019-05-06T20:09:35Z")

</div>

That is odd. What was the PB initially?

---

<div class="post-metadata">

### Author: ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)
#### Post date: [6 May 2019 20:13 UTC](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829/20 "2019-05-06T20:13:11Z")

</div>

PB initially = 5

[Next page](https://discourse.nodered.org/t/problem-with-dynamic-pid-parameter-change-node-red-contrib-pid/10829.md?page=2)
