symbol Ta = b0
symbol Tb = b1
symbol DT = b2
symbol DT_setpoint = b3
symbol relaypin = 2
symbol LCDpin = 1
symbol manual_on_pin = pin4
symbol manual_off_pin = pin3
symbol DS18B20_a_pin = 2
symbol DS18B20_b_pin = 1
symbol adc_pin = 0
symbol baud = N2400
serout LCDpin,baud,(254,1)
pause 30
main:
'readadc 0,Ta 'note remember to remove these before downloading to Pic
'readadc 1,Tb
'read DT_setpoint
readadc adc_pin,DT_setpoint
DT_setpoint = DT_setpoint/10
'check if manual overide is active
if manual_on_pin = 1 then manual_on
if manual_off_pin = 1 then manual_off
'Check temp sensor A and B
readtemp DS18B20_a_pin,Ta
readtemp DS18B20_b_pin,Tb
if TA > 127 then neg_A
if Tb > 127 then neg_B
serout LCDpin,baud,(254,128,"A=",#Ta,223,"C B=",#Tb,223,"C ")
'Compare readings
if Tb>Ta then
goto calcdif
else goto manual_on:
endif
manual_on:
high relaypin
serout LCDpin,baud,(254,135,"A=",#Ta,223,"C B=",#Tb,223,"C ")
serout LCDpin,baud,(254,192,"Manual Fan on ")
goto main
manual_off:
low relaypin
serout LCDpin,baud,(254,128,"Manual Fan off")
serout LCDpin,baud,(254,192,"Set DT=",#DT_setpoint,223,"C"," ")
goto main
Tb_less_than_Ta:
serout LCDpin,baud,(254,192,"B<A Fan off")
goto Fan_off
calcdif:
let DT=Tb-Ta
serout LCDpin,baud,(254,192,"DT=",#DT,223,"C ")
if DT > DT_setpoint then
goto Fan_on
else goto Fan_off
endif
Fan_on:
high relaypin
serout LCDpin,baud,(254,200,"Fan on ")
goto main
Fan_off:
low relaypin
serout LCDpin,baud,(254,200,"Fan off")
goto main
neg_B:
let Tb = Tb - 128
serout LCDpin,baud,(254,128,"B=-",#Tb,223,"C ")
serout LCDpin,baud,(254,192,"- temp ")
goto Fan_off
neg_A:
let Ta = Ta - 128
serout LCDpin,baud,(254,135,"A=-",#TA,223,"C ",254,192,"- temp ")
goto Fan_off