Busfreak Posted November 14, 2003 Report Posted November 14, 2003 Hi guys! Sorry for this rather stupid question... :-) Could anybody here give me a hint how to convert the ALTITUDE values obtained from offsets 0570/0574 into one precise value? I am using VB6 and simply can't find the correct way to combine the HIGH 32-bit integer and the LO 32-bit integer into one precise value... Any help would be highly appreciated! Thanks a lot! Speedbirdie ;-)
hsors Posted November 14, 2003 Report Posted November 14, 2003 Hi Speedbirdie, You can calculate aircraft altitude (ft, AMSL) with the following VB code Public Const FtToM as double=0.3048 (in the declaration section of any module) Dim AltLow as long (long at &H570) Dim AltHigh as long (long at &H574) Dim td as as double (temp variable) Dim AltAMSL as double (result, ft) td=CDbl(AltLow)/65536/65536 If td<0 then td=td+1 AltAMSL=(CDbl(AltHigh)+td)/FtToM Hope it will do your job Hervé
Pete Dowson Posted November 14, 2003 Report Posted November 14, 2003 You can calculate aircraft altitude (ft, AMSL) with the following VB code Just watch out when the altitude is negative (which it won't be often, but it is possible in some parts of the world). Test the High part for < 0 and if it is you need to take extra steps because both parts are negative but only the high part is signed. I don't know VB enough to code it for you. Compilers that support 64 bit integers ("long long" or "_int64") types are an advantage in these cases. Regards, Pete
Busfreak Posted November 14, 2003 Author Report Posted November 14, 2003 Hi Herve and Pete! First of all thanks a lot for your helpful replies!! Please let me ask you one more thing... When using Herve's code I have one problem: the calculated altitude in feet is not really "precise", in fact it changes in steps of about 3 feet. I guess that's due to the ALT->FT conversion, but is there a way to correct this and calculate the *precise* altitude value? Thanks again for your support!! Best Regards, Speedbirdie
Pete Dowson Posted November 14, 2003 Report Posted November 14, 2003 When using Herve's code I have one problem: the calculated altitude in feet is not really "precise", in fact it changes in steps of about 3 feet. I guess that's due to the ALT->FT conversion, but is there a way to correct this and calculate the *precise* altitude value? It should be precise -- the "about 3 feet" is probably one metre (3.28084 feet). The High value of the Altitude (the 32-bit integer at offset 0574) is in metres. The Low value, the 32-bit (unsigned) integer at 0570 is in units of 1/65536ths of a metre, or about 0.00005 feet (though I doubt if it ever goes that accurate). It sounds like you are not reading, or are losing somewhere in the calculation, the fractional part of the value. Of course, measuring an aircraft's altitude to the exact millimetre or inch is a bit daft without defining it more in any case -- where are you measuring it from? The pilot's eye, the centre of the prop, the CofG? I don't usually bother with the fraction myself, the value in metres seems quite adequate for most purposes. Regards, Pete
Busfreak Posted November 14, 2003 Author Report Posted November 14, 2003 Pete, thanks very much! You were absolutely right...there was a stupid little typo in my VB6 code which caused the calculation loose the fractional part. Corrected now and working. Perfect! Many, many thanks! Speedbirdie
Raymond van Laake Posted November 14, 2003 Report Posted November 14, 2003 Just a thought.... somewhere in the fsuipc sdk there's a VB example how to get the LAT of an aircraft with one 64 bit variable: currency. Maybe that can be used for this as well Ray
Busfreak Posted November 15, 2003 Author Report Posted November 15, 2003 Oh well, maybe that's worth a try! Hope I will be able to find the VB6 code example you mentioned! :-) Thanks for the hint! Speedbirdie
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now