DS18B20 smoothing and PID tuning

Ok, I see. But in my age box which my temp sensor is inside a 750ml bottle filled with water (stacked together with a bunch more bottles of the same size but with better air circulation.) the temp change should be much faster and so a derivative may be useful?

Partly correct, yes. Ti and Td have to be the same for heat and cool, so you have to go for values that are ok for both. That means that if you tuned them separately then the Ti value would be the larger of the two and Td would be the smaller of the two. That is because a Ti larger than optimum gives you less integral effect, which may give a slightly poorer response, but will not cause problems, and similarly a smaller Td may be less than optimum but will not cause problems. In practice I am confident that the optimum Ti for the heat loop will be less than you have determined for the cooler as the heater will have less delay on startup than the compressor, so the loop response will be quicker. So when you get round to tuning the heater I suggest leaving Ti at the value you have now.

For the PB values however, there is not a compromise. Suppose you determined you wanted 5 degrees for the cooler and 2 for the heater. Then you add those together to get 7 and set the PB to that. Then in the heat/cool splitter node you adjust the constants so that the heat/cool crossover is off centre by an amount such that the cooler ends up with 5 of the 7 and heater ends up with the other 2.

in paragraph 2, would the PID value when disabled have to be split similarly?

Yes, which is a bit of a pain, in fact it has occurred to me that it would be useful if the splitter node allowed a disable input in the same way the PID node does. Then the same signal could be fed to both and the splitter node would handle it, holding both off. PR welcome :slight_smile:, though it wouldn't actually be a PR as it is just a function node.

Not familiar with PR.

Is that a different system altogether?
It might be, though whether it would be necessary or not depends on the control loop. The derivative has little effect once the loop is close the the setpoint, it is only if you change the setpoint or on startup that it does anything much. If you are not worried about getting absolutely the fastest startup response without causing excessive overshoot then it is probably not necessary.

It's the same RPi with its own freezer and sensors but similar setup with PID, GPIO and UI and eventually I/O to influxDB. The only time it will require more than maintenance temp control is when the freezer is opened and more bottles are added or subtracted. :wink:

My brewbox lid is open and I'm waiting for 75F. PB is set to 5 with Ti still at 57600.
When the pv settles to steady state and if it's not at setpoint, say above, do I decrease the Ti to make it approach setpoint? Is the procedure different for above sp or below sp?

It will be at setpoint, that's what the integral does. If you look at your last chart you can see it in action. Between 09:00 and 13:00 the temperature does not change, but because the temperature is below the setpoint the integral is slowly winding the power down. You can see the power gently dropping. This causes the temperature to start rising towards the setpoint. Similarly if the temperature were too high then it would increase the power to bring it down. If you had left it a bit longer it would have settled out on the setpoint. Of course outside temperature changes will have an effect, and could push it slightly off setpoint, but then the integral should pull it back on again. Such is the magic of PID (well PI in this case).

Well, this is just about perfect. I only reduced the PB to 5 from 10 and this is the result.


This is a 16 hour graph and the pv was within 1F of setpoint in less than 6 hours. Taking into consideration the aerobic lag time of the yeast this couldn't be better. The only wild card now is the heat generated by an active yeast. I'm not certain how affected the process will be but I don't think it will be extreme.
Awesome Colin! That's the prettiest graph I've seen!

Assuming the self generated heat comes on slowly then the integral should have little trouble compensating. Did you accidentally change the setpoint at 21:30?

You could get it in there quicker by reducing the PB further so you get a little overshoot, but it sounds like you don't want to cool it down too quickly anyway, in which case obviously leave it as it is.

Yes, I was intending to set my aging temp a degree lower and did the brew temp instead.
I'm happy with it the way it is and I agree that the yeast generated heat won't be a factor that requires compensation. It may build quickly, a few hours to peak, then gradually reduce as the sugars are consumed and yeast die off. At worst it will only be 1 or 2F from what I've read. I've never actually measured it myself.

I intend to share my flow when I'm satisfied it's stable. Do you think I should restore the Split Hot/Cold node before I share? Should I wait until winter when the heater is stable?

As long as it builds over a few hours the integral should take it out. I would wait till it is all working before publishing, otherwise you won't know whether there is some minor error in there.

Good. compensating for larger or smaller batches would be a lot of work. :slight_smile:
I have a beer kit on hand, I'll see if I can work in a live batch this week and give you an update.

Cheers! image

I didn't have the yeast I needed for my beer kit so I put together a batch of orange wine. 3 gallons volume in a 5 gallon bucket.


The graph is 36 hours with the bucket into the freezer at about 1pm yesterday. The must was at 99F to start. I forgot about the boiling water addition and it raised the must temperature more than I expected. I waited until 20:20 to pitch the yeast and am surprised that just opening the freezer lit and removing the lid on the bucket raised the liquid temperature by 2F. I did, inadvertently raise the temp probe out of the must.
The PID control seems to adapt pretty nicely to a smaller volume but I don't think that's the whole picture. Notice that the temperature bottoms out at around 8am the next morning at 64.40F and stays there until the ambient temperature starts to rise. The expectation was that when the yeast started to be significantly active it would raise the temperature of the must and looking back to the 5 gallon bucket of test water the percentage of full power is significantly higher than just plain water would need and though the ambient temperature is level the power required is still rising.
Any way, long story short, the PID controller is working nicely with reduced volume and active yeast.
Nice work Colin. Very nice work.
:smile:

While there is a temperature difference between the box and the must then the must will not all be at the same temperature. The outside will be lower than the centre and there will be convection currents circulating in the liquid. If, when you added the yeast, the probe did not end up in exactly the same place in the liquid, or if you stirred the liquid when you added it, then that would explain the temperature change at the probe. Plus also if you added any significant amount of liquid with the yeast then that would change the temperature too.

The reason the temperature appears to bottom out and then rises slowly is because you have a very large integral time, it will take a very long time to take out the last little bit of error. You could try taking the integral time down to about 2/3 of the current value and see if that helps. It might increase the initial overshoot a bit. Over a period you can adjust it and find the best compromise that gives you the quickest settling on the setpoint with acceptable overshoot. Decrease the integral by about 2/3 each time.

I did stir in the yeast but the liquid added was only a couple ounces. It is a bit of a shock that there would be that much difference in temperature between the core and outer edge of the bucket. My temp probe is about 1/3 of the way in from the edge. I could really get involved in adding something to stir the must but, it's just a hobby. :blush:
Anything I do to optimize the 3 gallon batch will affect the 5 and 6 gallon batches too so I think I'll just be happy with what I have, at least until I see how the larger batches work out.
My wife and I are interested in Paul Reed's irrigation project and may be doing something similar but that's a project for next year.
Thanks for the input,
Charles

It is only while it is cooling down that there will be a temperature gradient in the liquid. Once the box temp is the same as the must then it will all be the same temp.

But that doesn't take into consideration the heat generated by the yeast. It would be evenly distributed through out the must but still would require more energy to keep it cooled to the desired temperature. I doubt the difference would be 2F but from the graph above it does seem to show more cooling required as the yeast becomes more active.
I'm looking at the graph of the last 12 hours and it is settling in on the setpoint but the energy required is higher than simple water.

Once the must temperature is effectively the same as the box temperature then there cannot be a great amount of heat transfer in either direction, therefore there will not be a significant temperature gradient through the must even if the yeast is generating a bit of heat. You can easily prove it by giving it a quick stir and see if the temperature changes.

Also once it is stable most of the cooling will just be compensating for heat lost through the wall of the freezer into the environment, so the main thing that determines the power level will be the outside ambient temperature.