I think the answer to you problem would be to make fan1on a loop not a return.
Stay in that loop until the temp drops below the set point.
Move the ADC commands to a GOSUB and then you can sample from anywhere and have less code.
This example is using two probes on a 18F4320.
CHECK:
T1 = temp1*2
T2 = temp2*2
LCDOUT $FE,1,"INSIDE ",#T1
lcdout $FE,$C0,"OUTSIDE ",#T2
gosub getT1
gosub getT2
if T1 > T2 + 10 then BLINK
goto CHECK
BLINK:
LCDOUT $FE,1,"INSIDE ",#T1
lcdout $FE,$C0,"OUTSIDE ",#T2
high PORTD.0
LOW PORTD.1
pause 100
low PORTD.0
HIGH PORTD.1
pause 100
if T1 = T2 THEN DARK
gosub getT1
gosub getT2
goto BLINK
DARK:
low PORTD.0
LOW PORTD.1
goto CHECK
getT1:
ADCON0=$1 '%00000001 AN0
gosub getAD
temp1 = ADRESH
return
getT2:
ADCON0=$5 '%00000101 AN1
gosub getAD
temp2 = ADRESH
return
getAD:
pause 50
ADCON0.1 = 1
pause 50
return
end
Bookmarks