init:
pause 200
FVRSETUP FVR2048 'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011 'Set ADC to FVR
Symbol batt = w1 ; Word variable for the calibadc10 reading
calibadc10 batt ; Take the reference reading
pause 20
Main:
debug
low B.5
if pinC.4=1 or pinc.5=1 or pinc.7=1 then high b.7
pause 50
low b.7
' relay 1 top B.5
' relay B.6
elseif pinB.1=1 and pinB.2=0 and pinB.3=0 and pinB.4=0 then
serout C.0,N2400,(254,128)
serout C.0,N2400,("relay ")
goto p_relay
elseif pinB.1=0 and pinB.2=1 and pinB.3=0 and pinB.4=0 then
serout C.0,N2400,(254,128)
serout C.0,N2400,("sensor ")
goto p_relay
else gosub volt
endif
goto main
p_buzz:
high B.7
pause 50
goto main
Volt:
readadc10 B.0, batt '3.5v batt
batt = batt *17
bintoascii batt,b4,b5,b6,b7,b8
readadc10 C.2, batt ' 24v batt
batt = batt *27
bintoascii batt,b12,b13,b14,b15,b16
serout C.0,N2400,(254,128)
serout C.0,N2400,( "PLUG IN CABLE.. " )
serout C.0,N2400,(254,192)
serout C.0,N2400,("Batt ",b13,b14,"v - ",b6,".",b7,"v ")
goto main
p_relay:
' relay 1 trigger B.5
' relay 2 trigger B.6
' relay s2 in C.4 centre pin NC
' relay s3 in C.7 bottom pin NO
serout C.0,N2400,(254,128)
serout C.0,N2400,("RELAY TEST ")
serout C.0,N2400,(254,192)
serout C.0,N2400,(" wait... ")
pause 50
if pinC.4 = 0 and pinC.7 = 0 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** a *** ")
pause 20
goto main
elseif pinC.4 = 1 and pinC.7 = 1 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** b *** ")
pause 20
goto main
elseif pinC.4 = 1 and pinC.7 = 0 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** c *** ")
pause 20
goto main
elseif pinC.4 = 0 and pinC.7 = 1 then
high B.5 ' relay 1 (top)
pause 2000
endif
if pinC.4 = 0 and pinC.7 = 1 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" PASS PASS ")
pause 1000
elseif pinC.4 = 0 and pinC.7 = 0 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** FAILED *** ")
pause 20
elseif pinC.4 = 1 and pinC.7 = 1 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** FAILED *** ")
elseif pinC.4 = 1 and pinC.7 = 0 then
serout C.0,N2400,(254,192)
serout C.0,N2400,(" *** FAILED *** ")
pause 20
low B.5
pause 500
endif
goto main