Gadd3rs
24-01-2006, 09:46
Hi there,
I have two times: a take off and a landing time recorded to an EEPROM.I can recall both times individually onto an LCD screen, but i have no idea how to subtract the two values (landing - take off time) to find the flight duration.
Here's the program (which no doubt has plenty of mistakes in), would appreciate any help :)
symbol lcd = 7 'pin for the lcd firmware
symbol line = 128 '128 for top line or 192 for bottom line
symbol clock = %11010000
symbol top = 128
serout 7,T2400,(254,1)
main:
if pin1 = 1 then hello
if pin1 = 0 then timer
if pin0 = 1 then hello2
if pin0 = 0 then timer
if pin7 = 1 then hello3
if pin7 = 0 then timer
if pin6 = 1 then hello4
if pin6 = 0 then timer
timer:
if pin1 = 1 then hello
if pin0 = 1 then hello2
if pin7 = 1 then hello3
if pin6 = 1 then hello4
serout 7,T2400,(254,192,"Current time ")
pause 250
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
debug
pause 100
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
if b0 < 10 then ooi
if b1 < 10 then oio
if b2 < 10 then ioo
serout lcd,T2400,(254,top,#b2,":",#b1,":",#b0," ")
goto main
ooi:
if b1 < 10 then oii
if b2 < 10 then ioi
serout lcd,T2400,(254,top,#b2,":",#b1,":0",#b0," ")
goto main
oio:
if b2 < 10 then iio
serout lcd,T2400,(254,top,#b2,":0",#b1,":",#b0," ")
goto main
ioo:
serout lcd,T2400,(254,top,"0",#b2,":",#b1,":",#b0," ")
goto main
oii:
if b2 < 10 then iii
serout lcd,T2400,(254,top,#b2,":0",#b1,":0",#b0," ")
goto main
ioi:
serout lcd,T2400,(254,top,"0",#b2,":",#b1,":0",#b0," ")
goto main
iio:
serout lcd,T2400,(254,top,"0",#b2,":0",#b1,":",#b0," ")
goto main
iii:
serout lcd,T2400,(254,top,"0",#b2,":0",#b1,":0",#b0," ")
serout 7,T2400,(254,192,"Current time")
if pin1 = 1 then hello
if pin0 = 1 then hello2
if pin7 = 1 then hello3
if pin6 = 1 then hello4
goto main
original:
i2cslave %10100000, i2cfast, i2cbyte
writei2c 0, ("glider1")
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,b0,b1,b2,b3,b4,b5,b6)
serout 7,T2400, (254,192,"JFM Take Off ")
pause 6000
serout 7,T2400, (254,1)
goto main
hello:
i2cslave %10100000, i2cfast, i2cbyte
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG landing")
pause 6000
serout 7,T2400, (254,1)
hello2:
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
i2cslave %10100000, i2cfast, i2cbyte
writei2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG landing")
pause 6000
serout 7,T2400, (254,1)
goto main
hello3:
i2cslave %10100010, i2cfast, i2cbyte
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG take off")
pause 6000
serout 7,T2400, (254,1)
goto main
hello4:
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
i2cslave %10100010, i2cfast, i2cbyte
writei2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG take off")
pause 6000
serout 7,T2400, (254,1)
goto main
Edited by - Gadd3rs on 1/24/2006 8:47:30 AM
I have two times: a take off and a landing time recorded to an EEPROM.I can recall both times individually onto an LCD screen, but i have no idea how to subtract the two values (landing - take off time) to find the flight duration.
Here's the program (which no doubt has plenty of mistakes in), would appreciate any help :)
symbol lcd = 7 'pin for the lcd firmware
symbol line = 128 '128 for top line or 192 for bottom line
symbol clock = %11010000
symbol top = 128
serout 7,T2400,(254,1)
main:
if pin1 = 1 then hello
if pin1 = 0 then timer
if pin0 = 1 then hello2
if pin0 = 0 then timer
if pin7 = 1 then hello3
if pin7 = 0 then timer
if pin6 = 1 then hello4
if pin6 = 0 then timer
timer:
if pin1 = 1 then hello
if pin0 = 1 then hello2
if pin7 = 1 then hello3
if pin6 = 1 then hello4
serout 7,T2400,(254,192,"Current time ")
pause 250
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
debug
pause 100
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
if b0 < 10 then ooi
if b1 < 10 then oio
if b2 < 10 then ioo
serout lcd,T2400,(254,top,#b2,":",#b1,":",#b0," ")
goto main
ooi:
if b1 < 10 then oii
if b2 < 10 then ioi
serout lcd,T2400,(254,top,#b2,":",#b1,":0",#b0," ")
goto main
oio:
if b2 < 10 then iio
serout lcd,T2400,(254,top,#b2,":0",#b1,":",#b0," ")
goto main
ioo:
serout lcd,T2400,(254,top,"0",#b2,":",#b1,":",#b0," ")
goto main
oii:
if b2 < 10 then iii
serout lcd,T2400,(254,top,#b2,":0",#b1,":0",#b0," ")
goto main
ioi:
serout lcd,T2400,(254,top,"0",#b2,":",#b1,":0",#b0," ")
goto main
iio:
serout lcd,T2400,(254,top,"0",#b2,":0",#b1,":",#b0," ")
goto main
iii:
serout lcd,T2400,(254,top,"0",#b2,":0",#b1,":0",#b0," ")
serout 7,T2400,(254,192,"Current time")
if pin1 = 1 then hello
if pin0 = 1 then hello2
if pin7 = 1 then hello3
if pin6 = 1 then hello4
goto main
original:
i2cslave %10100000, i2cfast, i2cbyte
writei2c 0, ("glider1")
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,b0,b1,b2,b3,b4,b5,b6)
serout 7,T2400, (254,192,"JFM Take Off ")
pause 6000
serout 7,T2400, (254,1)
goto main
hello:
i2cslave %10100000, i2cfast, i2cbyte
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG landing")
pause 6000
serout 7,T2400, (254,1)
hello2:
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
i2cslave %10100000, i2cfast, i2cbyte
writei2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG landing")
pause 6000
serout 7,T2400, (254,1)
goto main
hello3:
i2cslave %10100010, i2cfast, i2cbyte
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG take off")
pause 6000
serout 7,T2400, (254,1)
goto main
hello4:
i2cslave clock, i2cslow, i2cbyte
readi2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
b8 = b0/16
b9 = b8 * 10
b10 = b0//16
b0 = b9 + b10
b8 = b1/16
b9 = b8 * 10
b10 = b1//16
b1 = b9 + b10
b8 = b2/16
b9 = b8 * 10
b10 = b2//16
b2 = b9 + b10
b8 = b3/16
b9 = b8 * 10
b10 = b3//16
b3 = b9 + b10
b8 = b4/16
b9 = b8 * 10
b10 = b4//16
b4 = b9 + b10
b8 = b5/16
b9 = b8 * 10
b10 = b5//16
b5 = b9 + b10
b8 = b6/16
b9 = b8 * 10
b10 = b6//16
b6 = b9 + b10
i2cslave %10100010, i2cfast, i2cbyte
writei2c 0, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 10
readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
pause 10
serout 7,T2400, (254,1)
pause 1000
serout 7,T2400, (254,128,#b2,":",#b1,":",#b0)
serout 7,T2400, (254,192,"GEG take off")
pause 6000
serout 7,T2400, (254,1)
goto main
Edited by - Gadd3rs on 1/24/2006 8:47:30 AM