PID to control temperature of flowing water

249 views
Skip to first unread message

Schlappo22

unread,
Apr 3, 2023, 10:56:06 AM4/3/23
to DIY PID Control
Hello PID Group,

glad I found this group here and was hoping to get a bit of feedback / input regarding a project that I am working on.

I am working on a water cycle which I want to use to dispense water at a certain temperature between room temperature and (around) 95degC. In my application I don't want to heat the water in the tank but rather use a "flow through heater" to heat the water instantaneously to the desired temperature. There a lot of heaters out there that are able to heat small amounts of water when flowing through without the need of preheating.
See my rough sketch below.

2023-04-03 16_53_34-Formula_Makr.drawio - diagrams.net.png

As you can see, I will have a Thermocouple on the inlet and on the outlet side, which I intend to use for the PID. I have started with the Arduino Library by Brett and was wondering if anyone has some advice when approaching this project. I hope that I can keep you posted on progress and showstoppers once components arrive.

Regards, Lukas

Steve Edmonds

unread,
Apr 3, 2023, 3:43:41 PM4/3/23
to DIY PID Control
Do you have variable flow rate, what temperature deviation is acceptable?

I have a wax melter project where I found for various reasons straight PID was not the best option and I resorted to energy balance control. It was not until I started running various tests and logging the data that I found this.
I started with a thermocouple, but because I could not insert it in the melter water jacket that response was far too slow, so I changed to a thin film RTD bonded to the outer jacket.
My thermal lag is about 5-7 minutes, long enough to input enough heat to boil the water jacket before I see any temperature rise, and as I ideally need to run the melter at 91-93C my biggest issue is not boiling the water jacket.
In your case with low flow not boiling the water during a heating cycle. To solve this I ran some tests to determine thermal response and losses so I could limit heat input during any heating cycle to an amount calculated to be less than that required to boil the water.

You may be able to use some similar energy calculations to limit heat input and possibly scale the PID output control based on flow and temperature differential.

Steve Edmonds

unread,
Apr 3, 2023, 8:19:58 PM4/3/23
to DIY PID Control
I also had issues with the proportioning of the relay output when run in the main loop, initial heating for me is at 100% but steady state requirement when the wax has melted is about 7.5%. I moved the proportioning into a timer interrupt routine where the interrupt runs every 0.1s and gained better control. With a 20 second control window 0.5% equates to half a cycle of the AC power controlled by the solid state relay.

Schlappo22

unread,
Apr 4, 2023, 3:31:27 AM4/4/23
to DIY PID Control
Thanks very much for your reply.
I think a variable flowrate will overcomplicate the application. So I will start with a set flowrate and maybe tackle that problem a bit later. So for now, lets assume constant flow rate.
Interesting application you have there! The thermal lag that you have should not be such a big problem for me. And if, I need to fix it. If I need 5-7 minutes to heat up my flow through heater, than the whole application does not make any sense.
To answer you question regarding the deviation, I don't know what is going to be achievable, but I am aiming for as small as possible. And would generally allow larger deviations with rising temperatures. When it comes to temperatures below 40degC. it has to be within the +-1degC bracket.
I intend to use this Flow Through Heater: FTH II from Ferro Techniek (so you know what I mean when I talk about FTH).
The heater has two power circuits (400W and 800W) that combined and spread across 5 phases will provide up to 1200W. So switching them on / off at the zero crossings, is how the intended use case looks like. They also mention a constant flow-rate, so we will keep it that way.

Is that how you control your system as well?

Steve Edmonds

unread,
May 4, 2023, 12:28:52 AM5/4/23
to DIY PID Control
What is the time to taken to run through the code in loop{}, if it becomes too long it may affect the PID control when the windowsize is very short.

Schlappo22

unread,
May 9, 2023, 12:39:18 PM5/9/23
to DIY PID Control
Hello,

So one loop takes 91ms at the moment.
Just tested.

Regards

Steve Edmonds

unread,
May 10, 2023, 5:57:06 AM5/10/23
to DIY PID Control
What is the time for one loop of the
```
for (variables[0][0]; variables[0][0] < variables[1][1];) {}
```
 loop, I assume close to 90ms.
If so there is only 1 opportunity every 90ms to change the relay state as the comparison code
```
if (Output < millis() - windowStartTime) digitalWrite(RELAY_PIN, HIGH);
    else digitalWrite(RELAY_PIN, LOW);
```
is in this loop.

If your windowsize is 83ms , 100% power is on for 83ms, 1 half cycle at 50Hz is 10ms and is the shortest on time the relay can be on, equaling 10/83 = ~12% so that your heater could potentially have ~8 power steps.

To run the comparison for relay control at 100Hz to allow small window sizes independently of the time the loop takes I have put the comparison into a timer interrupt routine for my application.
Reply all
Reply to author
Forward
0 new messages