tomcontr Posted January 16, 2005 Report Posted January 16, 2005 I have a problem geting the Ground Speed. This is my code: Public Property Get Int_FS_Ground_Speed() As Integer Dim Result(8) As Long FSUIPC_Read &H2B4, 4, VarPtr(Result(1)), (dwResult) FSUIPC_Process (dwResult) Int_FS_Ground_Speed = (((Result(1) / 65536) * 60) / 1000) * 60 It does work, but the number that it gives to me is wrong. I hope some one can help me Regards Thomas
Pete Dowson Posted January 16, 2005 Report Posted January 16, 2005 Int_FS_Ground_Speed = (((Result(1) / 65536) * 60) / 1000) * 60 It does work, but the number that it gives to me is wrong. First, think about the order in which you are doing things. If you take an integer, say 65535, and divide it by 65536, what do you think you get? Zero, that's what! :wink: So by dividing the value first you lose any fractional part of the metres/sec. Maybe that's accurate enough for your needs? Okay, press on(if not, copy it to a floating point variable first and do all your calculations in floating point). Secondly, what units are you trying to convert it to? You seem to be multiplying by 60 * 60 which will give you metres per hour, then dividing by 1000 -- so, you want kilometres per hour? Correct? What are you comparing this with to show that it is wrong? Please look at FSInterrogate, see what that is displaying and how it converts things. It is a very useful utility and is supplied in the SDK just to help clarify this sort of thing. Regards, Pete
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