Closed iverberk closed 7 years ago
Yeah, the Celsius logic likely needs some work, as I really only use the Fahrenheit scale on my systems. I'll look into it and see if I can reproduce those errors.
As for your setup, you should be able to set up your fridge to work using a dual controller (e.g. where both your fridge compressor and heater are controlled by the same "controller." I assume that you have some sort of relay board connected to the RPi GPIO pins for controlling the compressor and heater tube. Where is the temperature probe placed? In my fridge, I have one temperature probe that controls the fridge placed near the side wall, so it responds fairly rapidly to the temperature changes and I use a hysteresis value of 2F (roughly 1C) with the setpoint at 32F. This holds the fridge temperature pretty close to 32F on average, but with swings to either side of this. I then use "fermwrap" heater pads inside a Reflectix wrapping around my fermentors with a separate temperature probe inside a thermowell to independently control temperature. In your case, the overshoot is likely due to there being too little airflow such that the changes in temperature when the compressor or heater tube is on is not rapidly detected by the probe.
Unless you are fermenting in very small vessels, this is unlikely to impact your fermentations since the large volume inside will buffer these changes. The average is important, and you can see this by adding a probe to the inside of the fermentor. You can also use the sensor priority fields in the controller configuration window to apply this second sensor to the control algorithm.
PID may yield better control for your situation, as it will calculate output levels that won't change much once the algorithm has settled. I would suggest using only single-sided control with PID though because during switchover, the output level will not be correct for the heater when it switches on (and vice-versa). It can be done, and you can add separate PID values for P, I and D, but I don't think the switchover is as seamless as it could be.
Hysteresis mode simply controls the temperature like a thermostat. For example, if you have a fridge and you would like to get to 4C, the compressor will stay on until it reaches this temperature. It will then shut off. As you have seen, there can be some overshoot due to a lag in the temperature probe coming to the temperature (which can be solved by placement of the probe, or addition of a fan to circulate air). If hysteresis is set to zero, the compressor will turn back on as soon as the temperature dips below 4C, unless there is a delay set and this has not elapsed. If you set hysteresis to 1C, the compressor will not turn on again until the probe reads 5C (and the compressor delay has elapsed since the last time it was running).
Make sure to set your compressor delay to at least 5 minutes, 10 preferably, to reduce the chance of burning out the compressor. The heater can turn on and off as frequently as you wish, it shouldn't be affected by rapid cycling.
Hi Craig,
Thanks for your elaborate response!
I'm using this setup as a dough proofing box, so the setup is quite a bit simpler than a fermentation setup. I basically need to be able to keep a steady air temperature (and maybe humidity later on).
I'm using one controller to control the cooling (freezer) and heating (tubular heater). They are both connected to separate relays that are controlled from the RPi GPIO pins. I have just a single DHT22 'hanging' in the fridge, measuring the air temperature. There is no air circulation yet (I was planning to add this) so I guess that explains the slow temperature change pickup for the sensor. I might add a second sensor to measure internal dough temperature but for now I think I'll try with one first.
So adding a fan should reduce the overshoot and otherwise I would need to add a second temperature sensor? Thanks again.
Ivo:
Wow, that's an interesting use for CellarWarden! Yes, adding a recirculation fan should help to reduce the overshoots. A second temperature probe embedded into your dough would ensure that the controller is accurately controlling the dough's internal temperature, and not just the temperature of the chamber. This could be important because, as with beer fermentation, it could be higher than the surroundings during active fermentation.
Thanks for the description!
Craig
P.S. You can find waterproof DS18B20 probes like this that would work well for this application:
Thanks, very cool. I need to think if this will work with a rising/living 'dough'. Normally you put the dough in a container/bowl and let it rise free-form. Putting a relatively big wire with temperature probe in the dough might disrupt the dough rise and would probably stick to the dough, making it difficult to remove without destroying the shape/air pockets of the dough.
Ideally it would be a small 'needle' like this http://www.hukseflux.com/product/tp02 but I haven't found anything that is relatively cheap and works with the RPi. Thanks for the suggestion though!
That looks kind of expensive and probably overkill for what is needed. There are certainly meat probes such as from Thermoworks that contain a small thermistor. The issue is that the RPi doesn't have a built-in analog to digital converter, and while I'm working on adding this functionality through existing solutions (e.g. I2C ADC chips, Arduino communications over Johnny Five), it would still require a bit of electronics tinkering to get it to work. Does seem like a fun project though!
Ivo:
I've updated sensors.js to fix the error in Celsius display. I made a mistake in my ranging logic, so this overwrote the temperature scale configuration value. I've also updated the Controls tab to properly display C or F when plotting temp data. Hopefully this will fix these issues.
Craig
Just do a git pull and this should fix the problem. After this, I'd suggest resetting the logfile (click the Config button and then the Logging tab and click Reset Logfile) and the controller logfile (click the Controllers button and then the Reset Logfile button).
Awesome, working as expected. Thanks for the quick fix!
You're welcome. Best of luck!
HI Craig,
Just one more advice question if I may :-)
I'm trying to setup the PID algorithm with my tubular heater. I tried the auto-tuning option, but I'm not sure what the correct procedure is. I disabled the cooler (emptied the GPIO pin setting) and got the box to about the set temperature. If I enable the auto-tuning with default settings (4 second window) I see the relay switching on and off quite rapidly (probably on the 4 second interval). It's only 'on' for a very short amount of time in which the heater probably won't do anything significant. The tubular heater takes some time to warm up (it's only 45W). The procedure also does not seem to end and keeps overshooting/undershooting the target (http://pasteboard.co/6BweYukW7.png).
Can you recommend the correct procedure to (auto-)tune the PID parameters for the tubular heater (https://www.tlc-direct.co.uk/Images/Products/size_3/HETH451.JPG)? Like I said, the heater takes a little time to really warm up. Thanks!
Oh, by the way, after cancelling these were the numbers that the auto-tune came up with:
Autotuning cancelled. Preliminary values - Kp: 12.732404852780894 Ki: 0.0054904425279212144 Kd: 7381.6515021648875
Not sure if these numbers make any sense....
Ivo:
The PID autotune routine takes some time for it to go through enough cycles to calculate the P, I and D parameters, so that's not unexpected. After a few cycles, you can cancel it as you did. The values provided are rough values that CellarWarden will calculate. You can plug these numbers in for the PID and they will be a good starting place. Note that autotune will never be perfect, and you can manually adjust those parameters to get the best operation with minimal overshoot and cycling. Once the PID settles in, you should see fairly stable temperature with output also fairly stable.
The I'm still working on the autotune code, so it is still not optimal. Nevertheless, it will function and provide reasonable variables (except the D variable which can sometimes be rather large and give choppy output values). You can control the amount of time that your heater is on by editing the PID Window Size parameter. This defines the amount of time in seconds over which to do time proportioning. In other words, if your actuator is slow acting (e.g. like a compressor or your tube heater), put a larger value here (say 120 seconds). This will ensure that any time heating is called for, it will turn on for a sufficient amount of time to heat your chamber before turning off on each cycle. The default is 4 seconds, which is typically fine for a resistive heater controlled by an SSR. For something switched by a mechanical relay, longer window times are appropriate. Change the PID Window Size parameter and run the autotune routine again. The values you get will be approximate for your system. Then do the same for the cooling actuator (with the heater disabled).
BTW, what do you mean by tube heater? If this is a resistive heater, then it should be producing heat as soon as it is powered. It may not glow red (if it actually does), but if it is using power, that power will be dissipated as heat.
BTW, those values look okay except the D value. I'd drop that to around 50 and see how that does.
Also, you can do a git pull to update the index.js file, which should now report output values on the second y-axis of the Controller graph.
It's actually this heater: http://www.prem-i-air.nl/en/product/692919/prem-i-air-tubular-heater-power-w-45 . It starts producing warmth as soon as power is applied to it but because it low-wattage it takes a while to generate a significant amount of heat. I will definitely need to increase the window size I guess.
What do you mean exactly by a cycle? I'll do the update, thanks!
For PID, CellarWarden uses time proportioning. It's basically like a slow form of pulse width modulation (PWM) where the duty cycle of the actuator is cycled on and then off for a proportion of time. Let's say the PID is calling for 50% output and the Window Size parameter is set to 120 seconds. In this case, the actuator would be turned on for 60 seconds, and then turned off for 60 seconds, and the cycle would be repeated until the PID provides a different output value. With a window size of 4, the total cycle time would be 4 seconds, 2 seconds on 2 off for a 50% output from the PID algorithm.
It looks like a simple resistive heater encased in a plastic tube. In that case, a small PID Window Size should be appropriate, assuming this is controlled by an SSR and not a mechanical relay. Fast switching of a mechanical relay would significantly reduce its service life, whereas an SSR is designed for this. So I think a short cycle should be fine for this. Are you using an SSR or mechanical relay?
I'm using an SSR. If I set the window size to 4 this will mean that the heater is only powered on for a a couple of seconds every time. Given that it is low-wattage, will that generate enough heat eventually to increase from 21 to 28 Celsius? It can only achieve this if it is accumulating heat from every previous output run. Sorry, just trying to get some grip on the way PID works. Your explanations help a lot!
I think I'm just going to try again with the auto-tuning and let it run until it finishes. It does finish by itself right?
Since the power is on instantaneously, the power has to go some where. The heater immediately converts this into heat. So even if it is on only for a short duration, there will be some heat generated. If you have a 4 second Window, at 50% output, the heater will cycle on at 2 seconds and then off at 2 seconds. Integrated over time, this will equate to roughly 22.5W output on your 45W rated heater.
Hi Craig,
Got it all setup now and seems to be working. Ran into some more observations:
If I switch to Celsius the graph keeps drawing in Fahrenheit. Also, the LCD seems to keep showing Fahrenheit numbers. The only things that seems to change is the 'F' -> 'C'. Does this need additional work?
I was testing today and I have some troubles with large overshooting over the target temperature (> 4 degrees Celsius). I'm working with a small freezer that has a tubular heater installed. Naturally when cooling down it will keep cooling when the refrigerator has turned off and the same for the heater. I know about the hysteresis adjustments but not sure how to 'dial them in' to the correct values. Any tips? Also, can I use the PID algorithm with a tubular heater without breaking it?
Hope you can help out with this. Really enjoying the software!