Ok, you're building a spaceship, 100000 ft is high. I'd love to see this baby fly
First i think you need to look over your inputdata, methinks it's not properly extracted. I can't see any correlation between your data and 100(ish) metres, unless ofcourse it's already in tenths of ft(000D0Dhex=3341dec 3341*0,3048=1018.34 which would be close to your 100m).
Are you getting the data from a NMEA sentence($GPGGA) or is it a binary protocol? If it's NMEA you need to know that the data is separated by "," characters, they're not at a fixed position in the string. Atleast not towards the end of the string. This makes it difficult to extract and convert the data.
When you have your data properly extracted, the conversion would look something like this(pseudocode) ....
Code:
R0.HIGHBYTE = 0 'Prepare system variables for DIV32
R0.LOWBYTE = alt[2]
R2.HIGHBYTE = alt[1]
R2.LOWBYTE = alt[0]
AltMetres = DIV32 10
Alt10Ft = AltMetres ** 21501 '21501/65536=0.32808
SEROUT blah..,blah..,["Altitude :",dec Alt10Ft, "0 ft",13,10]
..... you could increase the resolution when "alt[2]" = 0 ......
Code:
AltMetres.HIGHBYTE = alt[1]
AltMetres.LOWBYTE = alt[0]
AltFt = AltMetres ** 21501 '21501/65536=0.32808
SEROUT blah..,blah..,["Altitude :",dec AltFt, " ft",13,10]
.... you could ofcourse combine them .....
Code:
IF alt[2] = 0 THEN
AltMetres.HIGHBYTE = alt[1]
AltMetres.LOWBYTE = alt[0]
AltFt = AltMetres ** 21501 '21501/65536=0.32808
SEROUT blah..,blah..,["Altitude :",dec AltFt, " ft",13,10]
ELSE
R0.HIGHBYTE = 0 'Prepare system variables for DIV32
R0.LOWBYTE = alt[2]
R2.HIGHBYTE = alt[1]
R2.LOWBYTE = alt[0]
AltMetres = DIV32 10
Alt10Ft = AltMetres ** 21501 '21501/65536=0.32808
SEROUT blah..,blah..,["Altitude :",dec Alt10Ft, "0 ft",13,10]
ENDIF
/Ingvar
Bookmarks