Jump to content
The simFlight Network Forums

Help on Altitude Calcluations


Recommended Posts

Guys,

I'm working wn Altitude using VB6 And I have encountered some problem on calcluation Or did I write string incorrect?? Let take a look at yje string I wrote:

Acknowledge:

Altitude, Offset Value H570, 8 data bit

String I wrote:

Dim Fake64bit As currency

Dim Altitude As Double

Dim dwResult As Long

If FSUIPC_Read(&H570, 8, VarPtr (Fake64bit), dwResult) Then

Alritude = Fake65bit * 10000#

Altitude = Altitude *360#/ (65536# * 65536#)

Altlbl.caption = (Fake64)

End If

Running FS2002/My form Creation I get:

FS2002:Alt 306

My form: 8729354 something

Obviously, I did wrong on calucation... can anyone tell me me what did I do wrong??

Thanks in advance

Link to comment
Share on other sites

Or alternatively, read a Long at 574 for the whole meters, and a Long at 570

Also, I don't see why you're doing the calculations at all - it looks to me like the whole meters are stored directly at 574, and the fractions directly at 570 - no 65536*65536 calcs needed.

Richard

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the delay in replying -- I've been on holiday with no Internet access. I'm just trying to catch up with an enormous backlog now!

Altitude, Offset Value H570, 8 data bit

String I wrote:

Dim Fake64bit As currency

Dim Altitude As Double

Dim dwResult As Long

If FSUIPC_Read(&H570, 8, VarPtr (Fake64bit), dwResult) Then

Alritude = Fake65bit * 10000#

Altitude = Altitude *360#/ (65536# * 65536#)

Altlbl.caption = (Fake64)

End If

The altitude there is NOT floating poiint, but fixed point. The integer in metres is 32-bits (4 bytes) at 0574, the fraction is in 0570.

Best to read it into an array of two integers. Read metres in the 2nd and the fraction (UNsigned) in 1/(65536*65536) ths in the first.

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.