'2 CHANNEL FROST STAT USING 18X
'WITH OUTSIDE TEMP MONITORING
'AND THREE PRESET TEMP SETTINGS
start:
pause 250
serout 1,t2400,(254,1,12)
pause 200
b6=6
b7=6
main:
setint %00000100,%00000100 'SETS INTERRUPT FOR MODE SWITCH
b9=0
readtemp12 0,w0 'READ FIRST TEMP (DOWNSTAIRS TEMP)
goto neg_check
display:
gosub insert_zero 'INSERTS SPACE WHEN TEMP IS <10
if b0>=b6 then gosub off_1
b13=0 'CLEARS b13
b13=b6-1 'SETS TEMP 'ON' DIFFERENTIAL (HYSTERESIS)
if b0<b13 then gosub on_1
pause 1000
b9=1
readtemp12 7,w0 'READ SECOND TEMP (UPSTAIRS TEMP)
goto neg_check
display_1:
gosub insert_zero1 'INSERTS SPACE WHEN TEMP IS <10
if b0>=b7 then gosub off_2
b13=0 'CLEARS b13
b13=b7-1 'SETS TEMP 'ON' DIFFERENTIAL (HYSTERESIS)
if b0<b13 then gosub on_2
pause 1000
b9=2
readtemp12 6,w0 'READ THIRD TEMP (OUTSIDE TEMP)
bit15 = w0/32768 'DIVIDE W0 TO ISOLATE BIT 15
poke $51,bit15 'PUT BIT15 INTO VARIABLE $51
goto neg_check
display_2:
gosub insert_zero2 'INSERTS SPACE WHEN TEMP IS <10
poke $50,b0 'LOAD OUTSIDE TEMP FROM B0 INTO $50
pause 1000
goto main
test:
branch b9,(display,display_1,display_2,main,main) ''2 X MAIN' ADDED SO PROG NOT STUCK IN LOOP WHEN ' 'RETURNING FROM PRESETS WITH b9 VALUE 3 OR 4
neg_check: 'CHECKS FOR NEGATIVE TEMP
w1 = w0
bit15 = w0/32768
if bit15 = 1 then goto neg_calc
goto pos_calc
neg_calc: 'CALCULATES NEG TEMP (2s COMPLIMENT + 1)
b8="-"
w1 = 65535 - w1 + 1 'CONVERT TO TWO'S COMPLIMENT FOR NEG NO.
w1=w1*10
w2=w1/16
b0=w2/10
b1=w2//10
if b0=0 and b1=0 then gosub no_sign 'REMOVES 'SIGN' IF TEMP = ZERO
goto test
pos_calc: 'CALCULATES POSITIVE TEMP
b8="+"
w1=w0*10
w2=w1/16
b0=w2/10
b1=w2//10
if b0=0 and b1=0 then gosub no_sign
goto test
interrupt:
if pin2=0 then gosub outside_control: 'WAIT FOR PIN 2 SWITCH TO BE RELEASED
outside_control:
serout 1,t2400,(254,128,"outside temp control")
gosub blank_line 'CLEARS LINES 2 AND 3 ON DISPLAY
gosub blank_line2 'CLEARS LINE 4 ON DISPLAY
if pin2=1 then outside_control 'WAIT FOR PIN 2 SWITCH TO BE RELEASED
pause 5
activated:
serout 1,t2400,(254,192," activated ")
serout 1,t2400,(254,148," setpoint = 10",223,"C ")
if pin1=1 then activated 'WAIT FOR PIN 1 SWITCH TO BE RELEASED
for b0=0 to 200 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
if pin1=1 then deactivated
pause 5
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
b1=b1+1 max 1 'SETS bI TO A MAX VALUE OF 1
if pin1=1 then deactivated
poke $52,b1 'LOAD VARIABLE b1 INTO $52
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
if pin1=1 then deactivated
pause 5
if pin1=1 then deactivated
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
next b0
setint %00000100,%00000100 'SETS INTERRUPT FOR MODE SWITCH
return
deactivated:
serout 1,t2400,(254,192," de-activated ")
serout 1,t2400,(254,148," ")
if pin1=1 then deactivated 'WAIT FOR PIN 1 SWITCH TO BE RELEASED
for b0=0 to 200 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
if pin1=1 then activated
pause 5
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
b1=b1-1 min 0 'SETS bI TO A MIN VALUE OF 0
if pin1=1 then activated
poke $52,b1 'LOAD VARIABLE b1 INTO $52
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
if pin1=1 then activated
pause 5
if pin1=1 then activated
if pin2=1 then set_Z1_ontemp_1 'GO TO FIRST TEMP SETTING
next b0
setint %00000100,%00000100 'SETS INTERRUPT FOR MODE SWITCH
return
set_Z1_ontemp_1:
gosub blank_line 'CLEARS LINES 2 AND 3 ON DISPLAY
gosub blank_line2 'CLEARS LINE 4 ON DISPLAY
set_Z1_ontemp:
serout 1,t2400,(254,128," Set Dwnstairs Temp ")
if pin2=1 then set_Z1_ontemp
if pin1=0 then goto inc_1
serout 1,t2400,(254,192," +",#b6,".0",223," C ")
let b0=1
b6=b6+b0
if b6>20 then gosub dec_1 'LIMITS DOWNSTAIRS SETPOINT TO 20
serout 1,t2400,(254,192," +",#b6,".0",223," C ")
pause 5
inc_1:
for b0=0 to 200 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
pause 5
if pin2=1 then set_Z2_ontemp: 'GO TO NEXT SETTING
if pin1=1 then set_Z1_ontemp
pause 5
if pin2=1 then set_Z2_ontemp: 'GO TO NEXT SETTING
next b0
setint %00000100,%00000100 'SETS INTERRUPT FOR MODE SWITCH
return 'AUTO RETURN AFTER TIME OUT
dec_1:
pause 5
let b6=6 'RESET DOWNSTAIRS SETPOINT TO 5
return
set_Z2_ontemp:
serout 1,t2400,(254,128," Set Upstairs Temp ")
if pin2=1 then set_Z2_ontemp
if pin1=0 then goto inc_2
serout 1,t2400,(254,192," +",#b7,".0",223," C ")
let b0=1
b7=b7+b0
if b7>20 then gosub dec_2 'LIMITS UPSTAIRS SETPOINT TO 20
serout 1,t2400,(254,192," +",#b7,".0",223," C ")
pause 5
inc_2:
for b0=0 to 200 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
pause 5
if pin2=1 then work_temp
if pin1=1 then set_Z2_ontemp 'GO TO NEXT SETTING
pause 5
if pin2=1 then work_temp
next b0
setint %00000100,%00000100 'SETS INTERRUPT FOR MODE SWITCH
return 'AUTO RETURN AFTER TIME OUT
dec_2:
pause 5
let b7=6 'RESET UPSTAIRS SETPOINT TO 5
return
work_temp:
if pin2=1 then work_temp 'WAIT FOR PIN 2 SWITCH TO BE RELEASED
for b0=0 to 10 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
if pin2=1 then night_temp 'GO TO NEXT SETTING
b6=10
b7=10
serout 1,t2400,(254,128," Work ")
if pin2=1 then night_temp 'GO TO NEXT SETTING
gosub preset_sub
if pin2=1 then night_temp 'GO TO NEXT SETTING
gosub Z1_sub
if pin2=1 then night_temp 'GO TO NEXT SETTING
gosub Z2_sub
gosub blank_line2 'ENSURES NO UNWANTED CHARACTERS ON THIS LINE
if pin2=1 then night_temp 'GO TO NEXT SETTING
next b0
serout 1,t2400,(254,220,"(Wrk)")
pause 20
return 'AUTO RETURN AFTER TIME OUT
night_temp:
if pin2=1 then night_temp 'WAIT FOR PIN 2 SWITCH TO BE RELEASED
for b0=0 to 10 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
if pin2=1 then day_temp 'GO TO NEXT SETTING
b6=12
b7=17
serout 1,t2400,(254,128," Night ")
if pin2=1 then day_temp 'GO TO NEXT SETTING
gosub preset_sub
if pin2=1 then day_temp 'GO TO NEXT SETTING
gosub Z1_sub
if pin2=1 then day_temp 'GO TO NEXT SETTING
gosub Z2_sub
gosub blank_line2 'ENSURES NO UNWANTED CHARACTERS ON THIS LINE
if pin2=1 then day_temp 'GO TO NEXT SETTING
next b0
serout 1,t2400,(254,220,"(Ngt)")
pause 20
return 'AUTO RETURN AFTER TIME OUT
day_temp:
if pin2=1 then day_temp 'WAIT FOR PIN 2 SWITCH TO BE RELEASED
for b0=0 to 10 'SET TIMER LOOP FOR AUTO RETURN TO MAIN PROGRAM
if pin2=1 then outside_control 'GO TO FIRST SETTING
b6=17
b7=12
serout 1,t2400,(254,128," Day ")
if pin2=1 then outside_control 'GO TO FIRST SETTING
gosub preset_sub
if pin2=1 then outside_control 'GO TO FIRST SETTING
gosub Z1_sub
if pin2=1 then outside_control 'GO TO FIRST SETTING
gosub Z2_sub
gosub blank_line2 'ENSURES NO UNWANTED CHARACTERS ON THIS LINE
if pin2=1 then outside_control 'GO TO FIRST SETTING
next b0
serout 1,t2400,(254,220,"(Day)")
pause 20
return 'AUTO RETURN AFTER TIME OUT
'DISPLAY SUBROUTINES
on_1:
peek $50,b0 'LOAD VARIABLE $50 INTO b0
peek $51,b1 'LOAD VARIABLE $51 INTO b1
peek $52,b2 'LOAD VARIABLE $52 INTO b2
if b0>=10 and b1=0 and b2=1 then goto off_1 'O/P OFF IF O/S TEMP IS POS & = OR > THAN 10
b10="o"
b11="n"
b12=" "
high 4 'SWITCH ON RELAY 1(DOWNSTAIRS)
serout 1,t2400,(254,212,"Dwn ",b10,b11,b12) 'DISPLAY RELAY 1 STATE
return
off_1:
b10="o"
b11="f"
b12="f"
low 4 'SWITCH OFF RELAY 1(DOWNSTAIRS)
serout 1,t2400,(254,212,"Dwn ",b10,b11,b12) 'DISPLAY RELAY 1 STATE
return
on_2:
peek $50,b0 'LOAD VARIABLE $50 INTO b0
peek $51,b1 'LOAD VARIABLE $51 INTO b1
peek $52,b2 'LOAD VARIABLE $52 INTO b2
if b0>=10 and b1=0 and b2=1 then goto off_2 'O/P OFF IF O/S TEMP IS POS & = OR > THAN 10
b10="o"
b11="n"
b12=" "
high 5 'SWITCH ON RELAY 2(UPSTAIRS)
serout 1,t2400,(254,225," Up ",b10,b11,b12) 'DISPLAY RELAY 2 STATE
return
off_2:
b10="o"
b11="f"
b12="f"
low 5 'SWITCH OFF RELAY 2(UPSTAIRS)
serout 1,t2400,(254,225," Up ",b10,b11,b12) 'DISPLAY RELAY 2 STATE
return
no_sign:
b8=" "
return
Z1_sub:
serout 1,t2400,(254,192,"Dwnstairs +",#b6,".0",223,"C ")
return
Z2_sub:
serout 1,t2400,(254,148," Upstairs +",#b7,".0",223,"C ")
return
preset_sub:
serout 1,t2400,(254,135,"Preset Temp ")
return
insert_zero:
if b0<10 then serout 1,t2400,(254,128,"Dwnstairs ",b8," ",#b0,".",#b1,223,"C ")
else serout 1,t2400,(254,128,"Dwnstairs ",b8,#b0,".",#b1,223,"C ")
end if
return
insert_zero1:
if b0<10 then serout 1,t2400,(254,192," Upstairs ",b8," ",#b0,".",#b1,223, "C ")
else serout 1,t2400,(254,192," Upstairs ",b8,#b0,".",#b1,223, "C ")
end if
return
insert_zero2:
peek $52,b2
if b2=1 then serout 1,t2400,(254,148,"*") 'SETS MARKER FOR OUTSIDE INFLUENCE
if b2=0 then serout 1,t2400,(254,148," ") 'REMOVES MARKER WHEN OUTSIDE INFLUENCE OFF
end if
end if
if b0<10 then serout 1,t2400,(254,149," Outside ",b8," ",#b0,".",#b1,223, "C ")
else serout 1,t2400,(254,149," Outside ",b8,#b0,".",#b1,223, "C ")
end if
return
blank_line:
serout 1,t2400,(254,192," ",254,148," ")
return
blank_line2:
serout 1,t2400,(254,212," ")
return