Nick, The statement:
if pwm_pars>max_pwm then pwm_pars=max_pwm
endif
can be made as such: pwm_pars = pwm_pars min max_pwm
That way no if then is needed.
Nick, The statement:
if pwm_pars>max_pwm then pwm_pars=max_pwm
endif
can be made as such: pwm_pars = pwm_pars min max_pwm
That way no if then is needed.
Dave Purola,
N8NTA
EN82fn
Hi David,
Thank you for the hint. It will be first on my “To do” list.
I noticed it in your first post and mark it as a good candidate for the time when I will do code optimization. I just slapped the code together to see how the system works in a dynamic scenario and prove the concept. The way I thought it is that when the actual temperature is way higher than set temperature the system will push maximum power. The closer the two temperatures are the system reduces its output. Only when the actual temperature is lower than set temperature the TEC will be turned OFF. This reduces the number of ON / OFF cycles which I understand the TECs are not happy with.
I am open to any other suggestions that will improve the project.
Nick
I’m in between two trips and had a little time to add a new feature to the code: hysteresis.
Adding few more variables and a call to te_control subroutine (code below) in the Main loop I can smoothly control the temperature with a ±2⁰F (good enough for me now).
One added bonus is that when restarting the TE after it was OFF I’m starting it with a safe voltage level output (start_pwm = 40) that will make sure the fans will not hesitate starting. After one cycle the regular rule, drive the TE as hard as the difference (act_temp – set_temp) is, kicks back in place. Short bench testing shows that it works like it should. When returning from next trip I will do more testing and also play with the values of min_pwm, start_pwm and max_pwm in order to get the desired temperature range with maximum efficiency and minimum ON / OFF TEC cycles.
My questions are:Code:te_control: If act_temp < (set_temp-hysteresis) then pwm_pars =0 pwm_flag=1 endif If act_temp > (set_temp + hysteresis) and pwm_flag =1 then pwm_pars = start_pwm pwm_flag=0 goto jump endif If act_temp > set_temp and pwm_flag =0 then pwm_pars = min_pwm + (act_temp - set_temp) endif jump: gosub set_pwm_pars Return
Is there a more elegant way of doing it?
Am I covering all logical possibilities or some more code is needed?
Any input will be appreciated.
Nick
according to this a pid style of control may extend the life of your peltier device, thermal cycling is detrimental
https://thermal.ferrotec.com/technol.../thermalref10/
Warning I'm not a teacher
Hi Richard,
Thank you for the link. I’ve been reading a lot about TEC controllers lately but did not find this one.
I know my goal might be too ambitious but so far the results are encouraging.
All I did so far is trying to create a poor man’s PID system at its simplest form.
Based on the temperature difference (act_temp – set_temp) I change the output level of my PWM.
It might be a little abrupt in the beginning but after the temperature stabilizes there will be only small steps in the voltage output (about 0.15V per step). That puts me lower than maximum admitted ripple for the TEC (5 – 10%) and it is only an occasional change not continuous like a non-filtered AC to DC voltage.
If I can find the right range (more testing is needed and unfortunately I must travel a lot for the next few weeks) I might not have to turn the TEC OFF at all and only lower the output voltage to maintain the temperature, which in turn keeps the TEC happy.
Since I’m having the fans paralleled with the TEC I must keep this min_pwm adove a certain value. Some brushless fan manufacturers recommend 5V as minimum running voltage and 7V as minimum starting voltage. That is the reason why I’m starting the system with a kick.
Not sure if this is the best approach reason for which I’m posting here.
Thank you for the input. I hope others will be interested in this project and bring new ideas to the table.
Nick
Why not add another sensor on hot side of TEC to control fans independently from TEC?
Hi Pedja089,
This might be one of the improvements that I thought about too, in case this first minimal approach will not work.
I’m also planning on adding a temperature sensor / thermostat on the cold side (if my testing finds it necessary) to prevent freezing of the TEC. I have some trusty DS1821 that can be programmed for different trigger temperatures.
I wanted to start simple which is the reason why I’m using the same output for fans and TEC for now.
The nice part is that the cooler is back together, I have access to all wiring and I can do all the work /changes externally.
Thank you for interest and support.
Nick
Bookmarks