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.
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
My questions are:
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
Bookmarks