Jump to content
The simFlight Network Forums

Offset 0570 (altitude) conversion


Recommended Posts

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 ;-)

Link to comment
Share on other sites

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é

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.