Temperature control of a system with variable setpoint and ambient temperature heated/cooled by Peltier

346 views
Skip to first unread message

Ivan Ilarionov

unread,
Jul 26, 2023, 5:10:57 PM7/26/23
to DIY PID Control

Hello,
I need some help to decide on control algorithm.
I have an insulated box in which there are about 4-5 liters of water that is cooled/heated by a Peltiers, driven by DC-DC buck convertor as variable CC source. Heating-cooling reverse is done by reversing the polarity with relay. The setpoint vary gradually between 16 and 25 degrees C on a schedule with speed between 0 and 2 degrees per hour. The box is placed in a room, which temperature can vary between 18 and 30 degrees with small hourly changes and big seasonal changes.

I've read a ton on information about control algorithms, but still don't know what to use for this system. It seems quite complex, because of to many variables that change its behaviour:

  1. Ambient temperature vary a lot. This affects not only the heat transfer rate of the box, but the performance of the Peltiers, most probably in non linear way.
  2. Setpoint varys a lot, which has similar effect on heat transfer and Peltiers performance.
  3. Peltiers are not simetrical at cooling and heating, nor linear.
  4. The system should be controlled conservatively, because Peltiers are more energy efficient when driven with low current. For example if the setpoint now is 20 degrees, and after hour is 19, the temperature change should happen as gradual as possible. Fighting overshoots will not be energy efficient too, although they are not very big problem for the system itself.
  5. DC-DC converter cannot be controlled under 0.5A

All these points make me realize, that it is impossible to have fixed PID constants. Probably scheduled constants depending on the ambient temperature or it's relation to the controlled temperature and direction of the Peltier?

I found some papers on self-tuning on step response, but I don't know how appropriate is for my system and I'm not sure that I can translate it into code. Neural networks - similar problems, also they seem too heavy on resources and won't fit Arduino nano that I use.
The system is quite slow. At 30 degrees ambient temp I did a step test -  lowered the peltier current from 2.248A to 1.284A and the temperature increased from 15.6 to 20.9C in a little bit less than 6 hours. Deadtime less than 30 seconds (I have a 10 seconds filtering buffer on the input)
Any advice? 


richard appleton

unread,
Jul 27, 2023, 8:56:54 PM7/27/23
to diy-pid...@googlegroups.com
Call me naïve, but I thought the big issue with overshoot in heating systems is thermal mass of the heater/cooler which seems insignificant in this setup. 4-5 kg of water versus 25g of Peltier module should not be subject to overages if you turn off the power when within a few tenths of a degree of setpoint. 

Run at high current when more than x degrees from setpoint, and low power when closer. It's not clear whether you have current control by the Arduino, or have to set that manually, but if manually then make sure that you set it with enough power to overcome the largest ambient to setpoint temp difference.

I really think that bang-bang control should be adequate in this particular case. Of course my practical experience is restricted to cooking with gas, microwave and induction (instant), coiled electric element (quick), solid element (slow) and glass top (glacial - pot still boiling over 5 minutes after turning off element) stoves.

Definitely curious as to the nature of the application...

--
You received this message because you are subscribed to the Google Groups "DIY PID Control" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diy-pid-contr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diy-pid-control/e829fb0d-e634-40db-a951-dcf0acb1acaen%40googlegroups.com.

Ivan Ilarionov

unread,
Jul 28, 2023, 3:27:14 AM7/28/23
to diy-pid...@googlegroups.com
The Peltiers current will be controlled by an arduino (but at the moment manually, as I'm not figured out the algorithm yet). The problem with on-off control is that it is inefficient and could thermally stress the Peltiers. Since it has small thermal resistance, the power loss through it is quite big and it will have to be compensated by running it at higher current, where it is less efficient (transferred heat is proportional to the current, Jaul heat is proportional to the square of the current). Moreover, my setpoint will be  ramping almost constantly, so the temperature under normal functional conditions is not supposed to go very far from the setpoint. So, the heat which I will need to transfer will depend more on the heat loss rate at the current inside and outside temperatures
The application is stupid, there is no real necessity of such tight control, but I still want to figure out something :) It is a very small orchidarium. Basically a box made from XPS boards, with glass front and top. There is a piece of rockwool inside, through which I circulate the water, which passes through the heatsinks of 2 peltiers, cooled by big CPU coolers. There are lamps above the top glass, which change partially the outside temperature. The orchids need to stay below a certain temperature at all times and a day-night temperature difference. My desire is to make the system controllable in order to emulate the hourly temperature curve of a real place (usually a cloud forest in Central or South America). And since the Peltiers are already quite ineffective, I want to control them in the most efficient way I can. 


Pieter S

unread,
Jul 28, 2023, 12:48:51 PM7/28/23
to diy-pid...@googlegroups.com
Do you know the insulation heat resistance of your insulated box? This will determine the effect/coupling of your internal controled temperature system with the external/ambient temperature. You should be able to measure/estimate by monitoring internal temperature decay wrt external temperature.

Ussually the control loop should be designed with enough gain and phase margin to reject external noise - you should be able to get by with a PI controller.

The dynamics of the system seems quite slow.

Ivan Ilarionov

unread,
Jul 28, 2023, 3:58:32 PM7/28/23
to diy-pid...@googlegroups.com
I measured it once, but after that I changed the dimensions and did not measure it again. I was measuring the power loss in the following way: I put a 22W car lamp which I powered with measured voltage and current, measuring the outside temperature and the final inside temperature after it settles. But this was when the box was empty. Now it has a wet wall inside, and I cool an unknown quantity of water, not the air, which changes the thermal resistance. And I'm not sure how the Peltiers and the circulating water through their coolers affect the heat resistance. In a few words - very difficult to measure it again. 
I think I will try to use the PID_V2 library for Ardiono, using the Proportional On Measurement functionality and also to implement some slew rate limiter of the output in order to avoid fast changes of the control value. Also I will switch to PWM when I go under 0.5A. And probably somehow will recalculate the control value when heating, in order to linearize it.


Steve Edmonds

unread,
Jul 28, 2023, 4:06:41 PM7/28/23
to diy-pid...@googlegroups.com
I too would think PI control should be possible. For the peltiers you could use an analogue output of the Arduino to control the current, either through a transistor/FET or more deficiently a switching regulator (plenty of circuits on the 'net).
When trying to program a controller for a wax melter with solid element, water jacket, thermal conductivity and latent heat of fusion I modelled the setup in a spreadsheet using Brett's PID equations. This made it very easy to experiment with the tuning before putting the values into the controller and wasting a day with a trial run.

Ivan Ilarionov

unread,
Jul 28, 2023, 4:58:05 PM7/28/23
to diy-pid...@googlegroups.com
The circuit is already done - I control  a DC-DC buck convertor as CC source with a digital potentiometer. The problem is that it cannot go below 0.5A, because the voltage cannot go below 1.2V, which is the reference voltage of the feedback. So for lower current I need to do something else. PWM probably won't work, as the switch on time of the DC_DC convertor probably is too big for something like this. Probaby if the frequequence is below 1Hz it could, but I have to experiment.


You received this message because you are subscribed to a topic in the Google Groups "DIY PID Control" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/diy-pid-control/z-VRGDTtvus/unsubscribe.
To unsubscribe from this group and all its topics, send an email to diy-pid-contr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diy-pid-control/ead0f0f6-ed43-7e21-e0b5-75b48e084fa5%40edmondsfamily.co.nz.

Steve Edmonds

unread,
Jul 28, 2023, 6:03:01 PM7/28/23
to diy-pid...@googlegroups.com
It should be relatively easy to control having proportional switching with a simple 0.5A constant current source below a threshold and your DC-DC buck convertor with variable current output above that threshold, adding in some hysteresis and delay if required. In one application I control a refrigeration unit switching and have to enforce a delay between switching off and switching on.

Thinking further, because you have heating and cooling, I would definitely be doing some basic modelling to pick up what might happen as the setpoint transitions through various ambient temperatures.

Ivan Ilarionov

unread,
Aug 1, 2023, 3:34:47 PM8/1/23
to diy-pid...@googlegroups.com
Ok, so my system is ready for experiments.
Please, can someone suggest starting PID values?
Here is an approximate step response:
Step response
This is done by changing current from  1.284A to 2.258A. The temperature drops from 21.13 to 15.4 degrees, but since the outside temp has dropped by a half a degree, we can say that the drop is about 5C degrees. 
Time constant seems to me like around 135 minutes.
The output value is from -267 to 267 (- for warming, + for cooling). 
I presume that there will be vast difference in both directions, so probably in the beginning I could start with cooling direction only.

0 output represents 0A
267 output represents 3.52A
2.258A = output 135
1.284 =  output 62
Input comes as a floating point variable in the range let say 12 - 27 degrees.
I'm using
 Brett Beauregard PID library.


Pieter S

unread,
Aug 2, 2023, 9:16:28 AM8/2/23
to diy-pid...@googlegroups.com
Start with Kp of 1? No Ki

Set point near ambient. 

You change the Kp till you get the dynamic speed you want, and small oscilate. Then tune back your Kp by half. And set Ki to negate the steady state fault.

Test system at required working temperature - you can then check rejection of noise (ambient variations) on system.

If you got large enough oven/freezer, you can test extremes.

Happy hunting.

Steve Edmonds

unread,
Aug 2, 2023, 4:53:48 PM8/2/23
to diy-pid...@googlegroups.com
Well described Peter.
Kp is often described as the change in output required from the PID controller divided by the error input.
It is not clear if the charted temperature change from 21.13 degrees was from a steady state of 21.13 at 1.284A.
If the PID controller is set up for an output -267 to 267 then I would be expecting quite a high Kp.

I have always found this hard to visualise and now set my PID outputs to 0-1.0 which for me is easier to picture a Kp, at what input temperature differential do I want 1/2 power or full power.
Steve

Ivan Ilarionov

unread,
Aug 2, 2023, 6:02:53 PM8/2/23
to diy-pid...@googlegroups.com
Yes, the temperature step on the chart is from a steady state of 21.13 at 1.284A.
I did some calculations and got Kp = 1.47 and Ki = 0.01, at least for the conditions from the chart. If I use Ki = 0, then when I get to the setpoint the PID output will be 0, so the Peltier will stop working and there won't be any energy input to keep the temperature at the setpoint state. The problem with testing is that the system is already running and I cannot go wild with the values. So, I have to make it slow, at least for the beginning. But I suspect that the values that could work now won't work very well when the ambient temperature go down to 20 degrees. Even less in heating direction, where the same current will produce much higher energy gain.


Pieter S

unread,
Aug 2, 2023, 9:41:58 PM8/2/23
to diy-pid...@googlegroups.com
We use peltiers in CCD systems going down to stable -60°C, ambient from -10°C - 40°C, air cooled.

The PI should be very robust. Maybe the location of your temperature probes wrt energy source/sink more important.

We measure at the copper end-block connected to peltier.

Ivan Ilarionov

unread,
Aug 5, 2023, 6:30:37 AM8/5/23
to diy-pid...@googlegroups.com
Ok, first test done. I started with Kp = 1.47 and Ki = 0.01, Kd = 0 and 1 second update period, but after less than 2 hours saw that it is not OK, so bumped Kp to 10. And here is the result of about a 32 hours test. This is only the cooling side, but the current conditions don't allow testing the heating side. I suppose that when ambient temp drops down, Tin will have difficulties to rise fast enough without heating.  Anyway, it looks better than I expected, but still there are some over and undershoots, which I'm not quite sure how to fix. 
Here are the charts:
https://i.stack.imgur.com/NpTyW.jpg
Any opinions?

Pieter S

unread,
Aug 5, 2023, 8:14:10 AM8/5/23
to diy-pid...@googlegroups.com
Like your graphs.

Try limiting you Ki counter? 

If not yet, read Brett's write up on the PID, whish that was available when I got introduced to control system way back ;)

Reply all
Reply to author
Forward
0 new messages