Temperature and humidity control for an incubator using Reef-Pi

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
I have an incubator that I use to incubate Testudo Hermanni eggs. For this I use a RPI with Reef-Pi.

While the temperature control works great for my aquarium, I have major problems with the incubator:
The temperature in the aquarium runs within the set hysteresis around the set point.
But the temperature in the incubator shows a fluctuation range of 2 - 3 degrees Celsius, although I have set 0.1 degrees Celsius as hysteresis.
A DS18B20 serves as temperature sensor.

I assume that the 'inertial mass' - air instead of water - is much too low and that is why the overshoots occur.

Therefore, I imagine a proportional control instead of a 2-point control for the temperature as a solution: The heating power adapts to the difference between the set temperature and the actual temperature. This can be done very well via PWM.

In Reef-Pi, a PWM connection should also be selectable under temperature control. Two parameters would be useful: offset and slope.

Can this be implemented in Reef-Pi?
Or is there another solution or a work-around?

I am grateful for any suggestion for a solution.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
I think your analysis is correct: the thermal capacity of your air is much lower and the heater is therefore too powerful and/or has too much thermal capacity (so it heats far after it has been turned off).

Another possibility is that your sensor isn’t coupled well. If it’s designed for water, which has higher thermal conductivity if I’m not mistaken, it might heat up much slower than the air around it, switching off your heater much later. You could either try to remove the sensor’s shielding or improve its coupling with a kind of heatsink with fins and/or put it into the airflow of a fan.
 
Upvote 0

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,825
Reaction score
17,041
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
This will require some development work (coding) but I am happy to incorporate such feature if its of common use. I had thought of this (variable control based on analog input, instead of just digital on/off) while building the control logic, but i could not find any such output equipment (e.g. heater or ato) where it will be useful. Do you have any heater in mind that can take pwm input?
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
analysis is correct
Thanks!

a kind of heatsink with fins and/or put it into the airflow of a fan
Good idea: "... heatsink with fins..." I'll try it, because a fan is not enough.

Do you have any heater in mind that can take pwm input?
Yes, using a module between Reef-Pi (PWM) and any Heater:

Unfortunately this module will not be sold resp. shipped to Germany. I found similar modules, but out of stock for now.

Next solution: DIY with MOSFET: https://www.instructables.com/AC-PWM-Dimmer-for-Arduino/

This is what I go for. I don't recommend it everybody, but I'm familiar with AC 230V.
 
Upvote 0

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
I found others, available in Germany; e.g.:

I ordered 3 and will test the functionality over the weekend and report.

Nice ! I might actually use that too ramp up my flow pump, or dimm it, if it is too strong.

When you have set them up, can you write whether that circuit will still output AC or if it reduces it to pulsed DC ? Not sure if the latter works with typical Aquarium pumps.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
i could not find any such output equipment (e.g. heater or ato) where it will be useful. Do you have any heater in mind that can take pwm input?
In the meantime I found and tested successfully interfaces like: Raspi-PWM -> Interface -> Dimmer of power equipment:




What I'm doing for now: dimming down the heater to roughly 33 ./. 50% using PWM/Light-output and controlling a tasmota (WLan) switch by the temperature functionality.

Attached you'll find a principal drawing of the system.

I would prefer to have a functionality in Reef-Pi: PWM-signal ( 0% ... 100%) depending on the difference between the current value and the desired value; e.g. temperature.

Bildschirmfoto 2023-06-19 um 15.03.04.png Bildschirmfoto 2023-06-19 um 15.04.27.png Bildschirmfoto 2023-06-19 um 15.55.53.png
 
Last edited:
Upvote 0

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
@Ranjib Is there a chance that you'll implement the new functionality?
@Ranjib One possible method would be to fix macros and enable them to increment/decrement lights/PWMs.

That way you could run two macros to lower/increase the PWM every time the temperature reads too high/too low.

That's a very fragile regulator, but it should work well enough if you choose long enough update periods.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
One possible method would be to fix macros and enable them to increment/decrement lights/PWMs.
That's a very fragile regulator, but it should work well enough if you choose long enough update periods.

Perhaps, you have to consider the low thermal capacity of a terrarium and/or incubator...
 
Upvote 0

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
Perhaps, you have to consider the low thermal capacity of a terrarium and/or incubator...
Exactly, in that case you would need very long update periods on the macro regulator or very small increment steps.

One would also need to start at a very low PWM value, I imagine.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
in that case you would need very long update periods

As I understand, this would result in a high amplitude around the desired value.

The mean temperature for female and male Greek tortoises is 32.5 degrees Celsius. At 32.5 you'll have equal numbers of male and female tortoises. Normally you wish to have more female than male tortoises. That means that you have to control the temperature around 33 degrees. But you must not go over 35 degrees...

With shut on and off the heater, the amplitude around the desired 33.0 degrees is +/- 2 degrees. Far too high, although I increased the thermal capacity by using expanded clay.
 
Upvote 0

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
As I understand, this would result in a high amplitude around the desired value.

The mean temperature for female and male Greek tortoises is 32.5 degrees Celsius. At 32.5 you'll have equal numbers of male and female tortoises. Normally you wish to have more female than male tortoises. That means that you have to control the temperature around 33 degrees. But you must not go over 35 degrees...

With shut on and off the heater, the amplitude around the desired 33.0 degrees is +/- 2 degrees. Far too high, although I increased the thermal capacity by using expanded clay.
I think we might be misunderstanding each other.

In my envisioned macro-based integral regulator the PWM would slowly rise every time a temperature below the desired setpoint is detected on update. Same the other way: the PWM would slowly fall every time a temperature above the setpoint is detected on update.

So there is no on/off switching, but a slow change towards the right heating power.

If you make the change per time small enough, either by increasing the update period or by decreasing the stepsize per update, the heater would slowly approach the ideal heating power that keeps the temperature on setpoint.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
I think we might be misunderstanding each other.
Can be! Or not?

I made a simulation of your suggested solution using a spreadsheet.
Assumptions:
- starting point is the temperature of the environment.
- desired temperature is 33 degrees Celsius
- PWM duty cycle will be increased every time by 10% as long as the current temperature is below the desired temperature
- PWM duty cycle will be decreased every time by 10% as long as the current temperature is above the desired temperature
- heating is nonlinear with the PWM duty cycle
- natural fall of temperature is non-linear with the difference between the current temperature and the environmental temperature (no cooling system)
- heating (power) is nonlinear with the PWM duty cycle

Attached you'l find the calculation (simulation). Result there's a severe overshoot of temperature which would definitely kill the embryos in the eggs... :-(

Therefore you'l need to control the PWM duty cycle by the difference of desired and the current temperature. The closer you are at the desired temperature, the shorter the PWM duty cycle (= heating power) is. That's what you need.

As soon as I have time I'll make a simulation of such a solution.

Bildschirmfoto 2023-06-20 um 18.03.37.png Simulation Temp-Control using Macro-suggestion.png
 
Upvote 0

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,005
Reaction score
971
Location
Germany
Rating - 0%
0   0   0
well, that proves that 10% per minute is simply way too fast. I'd rather try a 1% step per 5 Minutes. I do agree that a proper regulator that uses the difference between current temperature and the desired temperature would likely be superior, but that's also much more difficult to get right. If you do it wrong, the regulator starts oscillating your heating power in exactly the same way as you see above.

Next:
Why do you even assume non-linear heating with PWM and non-linear heat loss with temperature difference ?
I would assume that at least the heating power is more or less linear with PWM.
Heat loss to environment might be non-linear if you get increased convection with increasing temperature difference, but I would not start with that assumption unless you have a good reason.

I think I was more or less able to recreate your simulation:
1687286063941.png

Instead of discretized Excel tables I used smooth functions in python, that's probably where the small differences come from.
Python:
# import
import numpy as np
import matplotlib.pyplot as plt

# init
temp_start = 20.0
temp_ambient = 20.0
temp_setpoint = 33.0

temp = np.array([temp_start])
pwm = np.array([0])

# heater control
def temp_incr(pwm):
    return 0.1353*(np.exp(pwm*0.04055)-1)

# temp loss
def temp_loss(temp_delta:float)->float:
    return 0.082*(np.exp(temp_delta/5.45)-1)

# simulation loop
index = 0
while index < 200:
    temp_new = temp[-1]+temp_incr(pwm[-1])-temp_loss(temp[-1]-temp_ambient)
    temp = np.append(temp,np.ones(1)*temp_new)
   
    pwm_new = pwm[-1]+0.5*np.sign(temp_setpoint-temp[-1])
    if pwm_new > 100:
        pwm_new = 100
    if pwm_new < 0:
        pwm_new = 0
    pwm = np.append(pwm,np.ones(1)*pwm_new)
    index += 1

# out
plt.figure()
plt.xlabel('time [minutes]')
plt.plot(temp,color='red',label='TempCurr')
plt.plot(pwm,color='blue',label='PWM')
plt.hlines(temp_setpoint,0,np.shape(pwm)[0],label='TepSetpoint')
plt.legend()
plt.grid()

If I now change to a pwm change of 1% per minute I get the following:
1687286269878.png


0.5% per minute looks like this:
1687286336530.png
1687286369874.png


Looks good enough too me for a first try. You would need to test in the real situation of course, since your heater has quite a big hysteresis you might need lower stepsizes or longer update periods.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
In the meantime I found and tested successfully interfaces like: Raspi-PWM -> Interface -> Dimmer of power equipment:

Unfortunately I realised that the equipment I tested ist not (!) well working! (Beside the discussion above)

I have to search for better working equipment.
 
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
Unfortunately I realised that the equipment I tested ist not (!) well working!

At the moment I have not the time to dive deeper in the issues with the tested equipment PWM -> Power electricity. There can be more than one issue:
- Thyristor (controlling only one phase) instead of Triac (controlling both phases) to control the power
- missing sync of the PWM signal with the phases of the power electricity
- perhaps other issues...

I tried to get around the second issue by setting the RPi of PWM down to 1 instead of 100. But this didn't work.

So, when I have more time, than I'll dive deeper in the issues.

Not to forget to mention, I found an equipment which can detect the zero crossing and sending this to an Raspberry Pi or Arduino:
 

Attachments

  • Bildschirmfoto 2023-06-23 um 09.37.19.png
    Bildschirmfoto 2023-06-23 um 09.37.19.png
    666.5 KB · Views: 18
Upvote 0
OP
OP
L

Litserv

Community Member
View Badges
Joined
May 3, 2020
Messages
62
Reaction score
59
Rating - 0%
0   0   0
Why do you even assume non-linear heating with PWM

1.) I assume a linear relationship between PWM duty cycle and mean output voltage.

2.) Further consideration (very simplified):

Power (P) = Voltage (V) * Current (A)
V = Resistance (R) * A
This leads to:
P = V^2 / R

3.) Result: Output Power is non-linear with PWM.

Am I right? Or what's wrong in my consideration?
 
Upvote 0
Back
Top