incubator temp control program
Ive been trying to figure out how to make the temp control program self stabilize so that the globes are held at a continual output. I figure they'll last longer that way. More importantly the temperature inside the incubator should remain the same or vary very, very little.
Heres how the program looks now if anyone wants to make a incubator at some stage. I think Im on the right track. The stability of the temperature is controlled by the delay in the gosubs ramp up and ramp down.
This sort of programming is quite interesting in that you need to create change yet also create stability.
The DS18B20 reading code is Prof. Andersons. I'll be buying my picaxe parts from him in future.
w11=200 'sets the heater level to start with
init:
pwmout 2,150,100 ‘ start pwm 'preheat setting
pwmduty 2,50 ‘ set pwm duty 'barely glowing
serout 7, t2400,("?f") 'clear screen move to pos 1 first line
main:
gosub checktemp
goto main
checktemp:
readtemp12 1,w0
calct:
b4 = w0 / 256 / 128
if b4 = 0 then Positive
w0 = w0 ^ $ffff + 1 ' take twos comp
positive:
W4 = W0 * 6 ' TC = value * 0.0625
W0 = W0 * 25 / 100
W4 = W4 + W0
gosub displaytemp
goto main
displaytemp:
b2 = W4 / 100
b3 = W4 % 100
if b4 = 0 then gosub displaytemp_1
return
displaytemp_1:
high 7
pause 50
serout 7,t2400,("?y0?x00")
pause 50
serout 7, t2400,("TEMP ")
pause 50
serout 7, t2400,(#b2,".")
b5 = b3 / 10
pause 50
serout 7, t2400,(#b5)
b6 = b3 % 10
pause 50
serout 7, t2400,(#b6)
low 7
if b2>=38 then gosub power_off
if b2<37 then gosub full_power
if b2=37 and b5>5 then gosub ramp_down
if b2=37 and b5<5 then gosub ramp_up
if b2=37 and b5=5 then gosub hold
return
power_off:
high 7
pause 50
serout 7,t2400,("?y1?x00")
pause 50
serout 7, t2400,("POWER OFF ")
pwmduty 2,0 ‘ set pwm duty 'power off
return
full_power:
high 7
pause 50
serout 7,t2400,("?y1?x00")
pause 50
serout 7, t2400,("FULL POWER ")
pwmout 2 , 99, 400
w10=400
pwmduty 2,w10 ‘ set pwm duty 'full power
return
ramp_up:
high 7
pause 50
serout 7,t2400,("?y1?x00")
pause 50
serout 7, t2400,("RAMP UP ")
inc w11
serout 7,t2400,("?y1?x30")
pause 50
serout 7, t2400,(#w11)
pwmduty 2,w11 ‘ set pwm duty
pause 10000
return
ramp_down:
high 7
pause 50
serout 7,t2400,("?y1?x00")
pause 50
serout 7, t2400,("RAMP DOWN ")
dec w11
serout 7,t2400,("?y1?x30")
pause 50
serout 7, t2400,(#w11)
pwmduty 2,w11 ‘ set pwm duty
pause 10000
return
hold:
high 7
pause 50
serout 7,t2400,("?y1?x00")
pause 50
serout 7, t2400,("HOLD ")
pwmduty 2,w11 ‘ set pwm duty
serout 7,t2400,("?y1?x30")
pause 50
serout 7, t2400,(#w11)
return