Temperature maintenance with node-red-contrib-pid

1,353 views
Skip to first unread message

Batigolle

unread,
Jan 4, 2018, 4:42:00 PM1/4/18
to Node-RED
Hi all
I'm trying to make a control of the heating and maintaining temperature of a pot with water. 
The pot is electric. I installed the node-red-contrib-pid.
Someone has already tried this way and can advise me the basic parameters of the PID to start doing some tests ?

I looked for information in the previous posts and I understood that I will have to integrate the node PID with
node-red-contrib-timeprop, in order to switch on the boiling resistance at intervals

If someone can provide me with a set of parameters to be set in the PID to start the tests and shorten the times,
 perhaps an example flow, I thank him in advance.

Thanks

Colin Law

unread,
Jan 4, 2018, 5:27:48 PM1/4/18
to node...@googlegroups.com
No time now but will post something in around 12 hours.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/b9a5d9d7-79aa-4a3d-bf8c-74dac97a1f6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Caparrós

unread,
Jan 4, 2018, 6:30:10 PM1/4/18
to Node-RED
Have you take a look already on this:   https://flows.nodered.org/flow/987b13d07372de57673a35facad33e24


Regards

Andy

unread,
Jan 4, 2018, 8:51:12 PM1/4/18
to Node-RED
You can use the default values to to start with and it will maintain your set temperature pretty well.  You will need to tune it for your particular heater and such for it to be perfect, but the default values should work.

Is there a particular problem you're trying to solve?  I assume your heating element is just switched on and off with a relay or SSR or something like that?  In that case the PID loop should just turn on the element until it gets to the set point and then start to dither around the set point, which is where PID tuning comes into play.

Batigolle

unread,
Jan 5, 2018, 4:04:59 AM1/5/18
to Node-RED
Thanks David
now I read it

Batigolle

unread,
Jan 5, 2018, 4:18:26 AM1/5/18
to Node-RED
Hi Andy
I confirm that my system must control a 2500W on / off resistor with SSR

In my system the water temperature increases by 1.6 ° C per minute (on average) to the maximum power of the 2500W resistors
when the temperature approaches the setpoint, the power must decrease to reduce the overtemperature effect,
subsequently the temperature must remain as constant as possible for about an hour.

The resistance will have to light up for short periods when the temperature falls below the set point, without causing excessive overheating, the optimum would remain in the setpoint + -0.5 ° C if possible

I'm a Homebrewers  

Regards

Colin Law

unread,
Jan 5, 2018, 4:23:45 AM1/5/18
to node...@googlegroups.com
I don't think that is using node-red-contrib-pid as it is talking about tuning using Ki Kp Kd which are difficult for many to get their heads round. node-red-contrib-pid uses a proportional band for setting the gain, which is in process units, degrees in this case, and time values in seconds for  the integral and derivative settings, which again are much easier to comprehend.

Tuning a simple control system like a heated pot should be very simple.  Initially set the proportional band to a very small value, 0.1 degrees I suggest. If your temperature sensor does not give a stable reading however you may need to set it a bit larger than this in order that it does not switch the heater on/off with noise in the reading. Set the integral to a large value (compared to the time response of the system) so something like 30 minutes (1800 seconds) assuming this is a pot not a tank. If it is a large tank or takes a long time to heat up then set it to a couple of hours. Set the derivative time to zero.  Set the setpoint to a temperature that it will not matter if it overshoots a few degrees.

Then switch it on. It should rise to the temperature but then oscillate around the setpoint going a few degrees (or fraction of a degree) each side of the setpoint in a regular manner.  Measure the size of the oscillation peak to peak, possibly 2 degrees for example, and the time period of the oscillation from one peak to the next (a full cycle, not peak to trough). This might be 4 minutes for example.  Now set the integral time to half of the period, so in this case with a period of 4 minutes, set it to 2 minutes, or 120 seconds.  Set the proportional band to the size of the peak to peak oscillation, 2 degrees in this case.  Leave derivative at zero for the moment. Let it cool down and try again.

You should find you now get quite good control, and it may already be perfectly good enough.  If you want to improve it then multiply the prop band by about two thirds and try again. That should get it closer quicker but may make it start over/undershooting. If still ok then decrease it further.  When you find the optimum value for that (a bit of overshoot and then settling out without undershoot) then, if necessary, you can try some derivative.  The problem with derivative (which can reduce the overshoot) is that it amplifies any noise in the temperature sensor.  If you are using something like a DS18B20 then the reading only has a resolution of 0.0625C, which means that rather than increasing steadily as the temperature rises it goes in steps. The node has a setting Derivative Smoothing Factor which defaults to 3, which is a reasonable default value and this helps with the problem, but it cannot completely remove it. As the derivate itself is increased then the noise on the power output increases and at some point will get too much. Theoretically the derivative should be set to a quarter of the integral (so 30 seconds in this case) but likely this will be too much. You could try it and see what happens. If it makes the output too noisy then try reducing it to 10 or 20 seconds, or whatever you can get away with. In fact, though, with a simple process like this there may well be no need for derivative at all.  The same applies in room heating for example.

To aid in tuning I suggest you graph both the temperature and the power value, then you will get a better idea of what is going on.

With regards to the use of node-red-contrib-timeprop you just need to feed the output of the pid node into it.  Its purpose is to convert a power value in the range 0 to 1 into a time proportioned output for driving a relay or similar, so a power value of 0.25 would be converted to a signal that is on for 25% of the time and off for 75%. The node has a setting to control the time period of the cycling, which should obviously be set to a small value compared to the time response of the process, Preferably less than 10% of the period of oscillation measured during the tuning process.  The node also has an Invert setting that allows you to control which way up the output is, so it doesn't matter how the hardware is configured, you can use this setting to make sure that it is on and off when it is supposed to be and not the other way round.

Colin

On 4 January 2018 at 23:30, David Caparrós <davi...@gmail.com> wrote:
Have you take a look already on this:   https://flows.nodered.org/flow/987b13d07372de57673a35facad33e24


Regards

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Batigolle

unread,
Jan 5, 2018, 4:41:19 AM1/5/18
to Node-RED
Hi Colin
thanks for the complete description of the possible PID calibration, very interesting,
I will try to put it into practice, creating a small test system, a DS18B20 temperature sensor and a light bulb as a heating element.
Initially I can not for practical reasons, understand how to calibrate the PID with the real pot with 20 liters of water, on my desk;)

In the previous answer to Andy I better described the characteristics of my system and what is the goal

Will follow updates
Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Colin Law

unread,
Jan 5, 2018, 4:53:58 AM1/5/18
to node...@googlegroups.com
With a 20 litre pot the time response of the system will be much slower that I suggested in my previous post, so I think you will need to start with a larger integral. It doesn't really matter how large it is provided it is significantly larger than the time response of the system.

Colin

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

cflurin

unread,
Jan 5, 2018, 9:19:37 AM1/5/18
to Node-RED
Using an on/off resistor with SSR and a DS18B20 temperature sensor I think a simple node like the ramp-thermostat will do the job.
How often do you read the temperature?

Colin Law

unread,
Jan 5, 2018, 9:58:41 AM1/5/18
to node...@googlegroups.com
Why use a crude approach like a thermostat when, with a bit of extra playing and no extra cost, you can get control within a small fraction of a degree? Plus I am sure the yeast will be happier with a stable temperature and there can be no doubt that happy yeast makes tastier beer  :)

Colin

On 5 January 2018 at 14:19, cflurin <fluri...@gmail.com> wrote:
Using an on/off resistor with SSR and a DS18B20 temperature sensor I think a simple node like the ramp-thermostat will do the job.
How often do you read the temperature?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

cflurin

unread,
Jan 5, 2018, 10:26:33 AM1/5/18
to Node-RED
If you'd be able to set the power between 0 and 2500W, then I'd agree but with an on/off control I'd not use a PID control.


On Friday, January 5, 2018 at 3:58:41 PM UTC+1, Colin Law wrote:
Why use a crude approach like a thermostat when, with a bit of extra playing and no extra cost, you can get control within a small fraction of a degree? Plus I am sure the yeast will be happier with a stable temperature and there can be no doubt that happy yeast makes tastier beer  :)

Colin
On 5 January 2018 at 14:19, cflurin <fluri...@gmail.com> wrote:
Using an on/off resistor with SSR and a DS18B20 temperature sensor I think a simple node like the ramp-thermostat will do the job.
How often do you read the temperature?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Colin Law

unread,
Jan 5, 2018, 10:43:47 AM1/5/18
to node...@googlegroups.com
Provided you can drive it using time proportioned on/off control at a rate of around ten times the natural frequency of the process then the control is effectively linear and PID works well.  That has been the most common method of controlling heaters in industry for 50 years, probably more.

You say you would not use PID, why not?  What is the advantage of thermostat on/off control apart from easier setup?  The disadvantage is poorer control.

Colin


To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Batigolle

unread,
Jan 5, 2018, 12:06:47 PM1/5/18
to Node-RED
Hi 
Cflurin , I have already used an ON-OFF control (STC1000), but the temperature management is not satisfactory. 

In my case, water with grains, thermal inertia is difficult to control.

I have to follow as closely as possible the following chart (example)

Colin Law

unread,
Jan 5, 2018, 12:11:49 PM1/5/18
to node...@googlegroups.com
If you already have on/off control then you will know already the natural period and the amplitude of the oscillation (provided the hysteresis on the thermostat is not too large) , so you can get your initial estimates of PB and Ti immediately.  What amplitude and period are you seeing?

Colin

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
Jan 5, 2018, 12:41:57 PM1/5/18
to Node-RED
Hi Colin, I've been reading your answers on the use of PID for a while with, I'm afraid, minimal understand as my eyes glaze after the first sentence or two B-)

However, your explanation in this thread is the best I've seen and with pretty practical examples. I'm wondering if you've thought of writing this up somewhere? It might save you a lot of future writing. ;-)

cflurin

unread,
Jan 5, 2018, 1:05:49 PM1/5/18
to Node-RED
@colin
I agree, a "time proportioned on/off control" will justify the use of a PID.

Batigolle

unread,
Jan 5, 2018, 1:14:18 PM1/5/18
to Node-RED
I try to remember the last test ...
when it reaches 56, the temperature continues to rise up to 58-59 ° C
with the resistance turned off, go back to 56 after 5-8 minutes

In the pot there is a recirculation pump to promote the uniformity of the temperature and the extraction of sugars from the grains

Batigolle

unread,
Jan 5, 2018, 1:16:34 PM1/5/18
to Node-RED
Hi Julian
I agree with you, I was thinking the same thing 

David Caparrós

unread,
Jan 5, 2018, 2:02:14 PM1/5/18
to Node-RED

Hi Batigolle,

For the experience I have on oil tanks on machines there are several important points to consider if you need a really accurate control but you need to put on the table first if you need to reach this level as ....as many hing you add... more energy consumption while depending on the application maybe is not required this precision and a contain power consumption will be preferable...

However if you wanted to go further you need to take into consideration points as:

- The inertia of the temperature change.
- The Thermal isolation of the tank/container.
- The flow of fluid inside the tank.
- The way that fluid is cold down or heat up.

Just for your consideration for a very accurate control the heat up or the cooling is not done over the full tank,normally there is a re-circulation pump and this flow is what is cold down or heated, so you have a constant flow, like this you only heat a small portion of the fluid and this will be added to the tank constantly and the control (will take longer to reach the target) but will be very stable once in there.

IS also very critical where the thermocouple is located on the system as should be taken into the fluid flows.

Best regards

Batigolle

unread,
Jan 5, 2018, 2:49:40 PM1/5/18
to Node-RED
Hi David

the points you have identified are very important

the most critical is the positioning of the probe for the detection of temperature, there are various solutions, each has its advantages and disadvantages, we must always find the right compromise

in the photo, the classic 4 points ,where to choose the positioning of the probe

David Caparrós

unread,
Jan 5, 2018, 3:40:40 PM1/5/18
to Node-RED
Frankly speaking there were theories that changed with the years, actually what I see on machines isd the probe located close to the suction line on the re circulation pump, I guess the reason is because this point is far from the return line and exposed all time time to a fluid flow, from other side I don't know if could be considered the location of the heater, most probably the best is not to be directly on the tank while will work better as mentioned previously heating up the fluid that comes from the re-circulation pump so the adding of heat to the main tank is better controlled and reduce the inertia.

Regards

Colin Law

unread,
Jan 6, 2018, 4:43:06 AM1/6/18
to node...@googlegroups.com
On 5 January 2018 at 17:41, Julian Knight <j.kni...@gmail.com> wrote:
> Hi Colin, I've been reading your answers on the use of PID for a while with,
> I'm afraid, minimal understand as my eyes glaze after the first sentence or
> two B-)
>
> However, your explanation in this thread is the best I've seen and with
> pretty practical examples. I'm wondering if you've thought of writing this
> up somewhere? It might save you a lot of future writing. ;-)

Yes, it is in my plan to do that, along with a long list of other
stuff, when I can find the time.

Colin

Batigolle

unread,
Jan 11, 2018, 3:49:18 PM1/11/18
to Node-RED
Hi Colin 
I studied your new instructions on how to make the PID tuning, 
I renew the compliments ... a job well done!

My load (heating resistance) must be controlled in ON / OFF mode, 
so I must add the node node-red-contrib-timeprop after the PID node.

How do you suggest setting its "Cycle Time", "Actuator dead time" and "Trigger period" parameters,
in relation to the values entered in the PID?

There is a correlation between the two settings or I have to go to attempts ?
 
For example, with the values found in your example flow, how would you regulate?

Thanks

Colin Law

unread,
Jan 11, 2018, 4:22:29 PM1/11/18
to node...@googlegroups.com
Hi Batgolle

Since it is an electrical heater the actuator dead time is zero. Heat starts going into the system the moment the switch closes.  Actuator dead time is for the case where there is something like a motorised valve that may take 20 seconds to open or close.

As for cycle time, if you imagine that it is operating at 50% power, so on for 50% of the cycle time then off for 50%, then the measured temperature will rise a little and fall a little each cycle.  The cycle time should be set small enough that this rise/fall is negligible.  Usually one will have a feel for what this is likely to be.  For something like room heating with hot water radiators then 5 or 10 minutes is typically used.  If it were fan heaters however then possibly 1 minute would be appropriate.  If I remember correctly you are heating a decent sized volume of water, so I might guess that 1 minute cycle time would be ok, or maybe 30 seconds.

For trigger period I usually go for 1 to 2% of the cycle time, or thereabouts. That gives you 1% (or 2%) resolution on the power which should be sufficient.  The beauty of closed loop systems is that they take errors out of the process for you and once you get them tuned are very tolerant.

In theory the smaller the cycle time and trigger period the better. However there are compromises to be traded off. If using a mechanical relay then the shorter the cycle time the more rapidly the relay is switching, so may wear out more quickly.  With mechanical actuators then obviously you don't want to be opening and closing them more than necessary.  If I remember correctly you are going to use an SSR so those issues are not relevant so the cycle time could be brought right down.  However there is also the trigger period to consider. Every time this activates then node red has to pass messages about, and in addition once one gets to small fractions of a second one cannot guarantee the timing in node-red.  On a pi zero, for example, I don't like to take the trigger below 0.5 seconds, and if it were doing a lot of extra work then even that might be pushing it.

I have not tried the sample flow with a timeprop signal. It is a much faster process than will usually be encountered in the home environment, I think one would have to put the cycle time right down to a second or thereabouts, with trigger period at 1/100 second.  Whether node-red would cope with that I don't know.

Colin


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages