PID with two sensors? how?

Hello all,
After long reading of the forum but also Internet, I don't find the answer to my problem. May be some gurus will be able to help me?

Let me explain the setup first:

  • I want to heat a chamber (a box of wood of 50cmx50cmx50cm) to a quite precise temperature: 41°C.
  • To do so, I used the PID library connected to the famous DS18B.
  • To heat, I use two fans+heater of 600w each. I use a relay to run the PID (the library works fine for that, it is an option.) the relay is connected to the pwm.
  • My chamber contain a biologic mass which create a big inertia. With such setup I can increase of 1°C after 12minutes. This is ok, i need to go slow.

My problem:
Due to my biologic mass, I must not let the heat power going at max. I must be at maximum 50°c. (mesured at 10cm of the source) If I do so I can increase of 1°C to 41°C by each 12min. ok.
I made my program to eat without "intelligence" at 50°C while T° is below 39°C.
Once 39°c obtained, the PID start.
But once PID run in action, I don't have anymore the 50°c limit. It can act at max and then releasing the 600W...
I could use % of power or PID value (max output) but I want to share my code to freinds and they will have different heater. My setup won't fit their hardware setup...

proposal solution??:

What I would like to be able to do is to run a PID to heat up to 41°c since beginning (without the 50°C limit up to 39...) and adding a sensor checking heat output and then limiting to 50°C.

Question:
Do you know how I can PID and in same time providing limits to the source by measuring the heating value?

any idea, help, is welcome.
Guil.

The PID library comes with and Adaptive Tuning example that does exactly what you describe. It aggressively tries to get to the setpoint when far away (temp < 39C), but then becomes more conservative as it gets near the setpoint (temp >= 39C)

Yes, you are correct but I will not be able to manage the power of the heater.
Far away from the limit, pid will drive the heater at max power that will result in being above 50c killing all my bees inside the box :slightly_smiling_face:
I'm looking a way to limit heat power to 50c when pid request "max".

Interesting control problem - if you limited the power of the heater , then the heat rise will be much slower and more controllable . You might then get away with on /off control .
A small mass heater , such as a ( small) IR lamp might work well

It’s also worth looking at how your chamber is heated - a warming pad underneath it for example would work better than direct heating which will create hot spots .

For your control system , just turn the heater off if the higher temperature is reached and reset the integral term to zero when the temperature drops below the set temperature - that might do it ?

Thanks for replying!
I need to heat with a temperature control. The heater with fan is necessary to get an homogenous temperature in the full chamber. The animal inside will resist to temperature (it's real temp is by default 36°c) but I need to push it to 41°c
This animal is in capacity to resist and cool itself so I need to push it to the limit to see it increasing the T°.
But I can't heat more than 50°c unless I will destroy organism structure....
This 41°C need to be kept for 3h. This is the reason of the PID. Having an increase of T° of 1°c/12min, I need to have system managing the evolution.
But I believe I found a solution

The PID manage the metrics and the output and with AutoPID library I can run in relay mode thru the variable Relaystate.
So when RelayState is 1, I go under a function that check the heater temp and if T°>50 Stop, if T°<50-4°C I start
So the heat control is done separately over a dedicated function. For the PID it is seen as a "1".

it's not obvious how PID works in this application. is PID being used to control the power to the heater (i.e. some % of max, PWM)?

it seems there may be 2 modes. the first when starting up and getting to some desired temperature from some much lower temperature and 2) maintaining some desired temperature.

and assuming the heater may continue to add heat after being shut off, should the shut off temperature be below the target temperature, knowing how much higher the temperature will increase after the heater is shut off. or is this where PID comes in?

and once shut off and after the temperature has peaked, what should the threshold be for turning the heater back on, again knowing how long it takes for the heater to turn on. will this be below the shut off temperature.

perhaps the thresholds can be adaptive by measuring the peak vs shutoff temperatures and adjusting the shutoff temperature again after the peak is reached and similar for the turn-on threshold

i don't understand the above. what happens after 3 hr?

Hi there, thanks for paying attention to my case.

The PID is managing the temperature inside the animal (bee colony). I need to increase the bees T° and the brood to 41°C during 3h to kill parasites.
But I can't heat more than 50° to keep the wax physically strong.

So I heat the hive at max until I reach 41°c in the middle of the colony. So I need to reach the 41°c carefully and not going over. The PID need. Once, the temperature achieved, I need to keep it to this level during 3h and then after I just stop. The T° will slowly decrease to normal T°

I was looking on how I could manage my 41°C and in same time keeping the heat to 50°c max.
I want to pilot the 50°c max thru a sensor because I will provide the diagram + source code as opensource and other beekepers won't have exactly the same heater. So I can't manage at my hardware level but more at the sensor level checking the heat, being technical fan/heat agnostic.

So my idea:
PID do its job with sensor 1 (in brood)
when PID ask to heat --> goes to heat-function ()
heat-function()
if temp-sensor2 > 50°C open heat relay
if temp-sensor2 < 47°c close heat relay
end

Sensor2 measuring the heat of course...
G.

I'm not sure that PID gets you much here. As far as I can tell from your description, heating is on or off, so you can do a simple bang bang controller.

I'd be inclined to heat continuously until the temperature reaches some temperature below 41 and then wait to see what happens in the centre of the hive because I expect it will keep rising for a while. Then just heat briefly when the temp is less than 41. You may be able to get some clues about how much lag there is on heat transfer by comparing the two sensors.

:slight_smile: This is not so easy.
The precision is mandatory here. I already made some prototypes last year over many hives. I'm full of data for now and I now exactly how it act (humidity as well, this is another topic...).
My initial question was on how to control the Heat while a pid control the output. A sort of PID with two sensors... not so simple .

Where are these two temperature sensors located? You keep talking about maintaining 41C but not going over 50C. Is one sensor in the middle of the hive? (41C) and the other is near the heater? (50C)

A diagram would be helpful.

Yes sorry, may be I should draw something. A diagram is better than a long speech... but you are right. 41C is in middle of the colony (more or less in the middle). But "protected by the bees keeping the brood at 36c.
The Sensor 2 is near the heater which are located completely at the bottom of the box.

Okay. That makes more sense now.

It sounds like you should use PID for your internal temperature combined with the source temperature. If the source temperature > 50C, system is off, if it is less than PID controls the PWM signal. You also wanted a bit of hysteresis (47 to 50C) so you will have to track what state you are in...

if sensor2 >= 50, relay OFF, state = COOLING
if sensor2 < 47, relay ON, state = HEATING
if state == HEATING, use PID to control heater PWM

1 Like

Thank you for your help (all). This discussion opened me ideas and bring me new angles. I love that. many brains for a better solution.

Thank you all!