MattWise Posted March 14, 2006 Report Posted March 14, 2006 I wasn't aware that I had to get the magnetic variation
jd Posted March 14, 2006 Report Posted March 14, 2006 twenty degree magnetic variation would put you within 1 degree of the number you gave me jd
Pete Dowson Posted March 14, 2006 Report Posted March 14, 2006 I wasn't aware that I had to get the magnetic variation You don't have to, it isn't mandatory. It depends what you want to use the heading you are reading for. It is a True heading, not a Magnetic one, which is good for navigation by maps but it won't match your magnetic compass heading. The magnetic variation gives you the difference between them. It varies all over the world. Regards, Pete
MattWise Posted March 14, 2006 Report Posted March 14, 2006 LukeK I did what you suggested and it didn't work either. I still got .312 Any ideas?
Joshua Robertson Posted March 16, 2006 Report Posted March 16, 2006 ... What does # mean in Visual Basic? ... Pete, Not that you'd need to know this knowing as I do that you don't use VB but I thought I'd share this tidbit of information with you concerning the # trailing the numbers in VB such as 360#. This is straight from the MSDN documentation: "Double (double-precision floating-point) variables are stored as IEEE 64-bit (8-byte) floating-point numbers ranging in value from -1.79769313486232 E308 to -4.94065645841247 E-324 for negative values and from 4.94065645841247 E-324 to 1.79769313486232 E308 for positive values. The type-declaration character for Double is the number sign (#)." So essentially the # symbol defines a numeric value as being a double data-type variable. There are several different ways to define a value as being a certain type of variable as I'm sure you are aware. The method I use most often is by explicitly declaring a variable as a specific variable type either in the application globals section, the form globals, or the procedure globals sections. This is just my two cents (or what ever your local currency is) Regards, Joshua Robertson (creator of FS Real Time) 3D Softworks Design Studios http://www.3dsoftworks.net
Pete Dowson Posted March 16, 2006 Report Posted March 16, 2006 So essentially the # symbol defines a numeric value as being a double data-type variable. Ah, I see. In C a constant can be forced to be a double by simply adding a decimal part, thus 360.0 The VB "#" method is a bit like having to use "F" for float (the 32-bit version), as in 360.0F, or even 360F. Thanks, Pete
FIS Posted April 16, 2006 Report Posted April 16, 2006 :) Gday all Maby a little late to post ? but was looking to get heading in Vb6 I found this works Perfect Dim Vcount as long,MY_Heading as Single If FSUIPC_Read(&H580&, 4, VarPtr(Vcount), dwResult) Then If FSUIPC_Process(dwResult) Then MY_HEADING = CSng(Vcount * 360#) / (65536# * 65536#) End If End If Text1.Text = MY_HEADING
Joshua Robertson Posted April 16, 2006 Report Posted April 16, 2006 :) Gday all Maby a little late to post ? but was looking to get heading in Vb6 I found this works Perfect Dim Vcount as long,MY_Heading as Single If FSUIPC_Read(&H580&, 4, VarPtr(Vcount), dwResult) Then If FSUIPC_Process(dwResult) Then MY_HEADING = CSng(Vcount * 360#) / (65536# * 65536#) End If End If Text1.Text = MY_HEADING That code snippit returns the heading in degrees-true. You would still have to add the magnetic variation to get the heading for degrees-magnetic. Try also reading the offset &H02A0 for the MagVar value. It's a signed 16-bit value which can be read into a single precision variable within VB. Regards, Joshua Robertson (creator of FS Real Time) 3D Softworks Design Studios http://www.3dsoftworks.net
BUM Posted May 24, 2006 Report Posted May 24, 2006 Mattwise, did you ever solve this problem? I'm new and trying and getting the same results that you posted here. I can't seem to get anything to work in 6.0 or .net! :?
kaelastreet Posted May 27, 2006 Report Posted May 27, 2006 I seem to get -65 when the airplane is on a heading of 270(w) degrees. After the decimal point, I see 8 or so dancing random numbers, so I am ignoring them. Call FSUIPC_Read(&H580, 4, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) Plane_heading = x / 65536 / 65536 * 360 lbl4.Caption = Plane_heading.. lbl4 is just a text window to show the result. Kaela
jd Posted May 27, 2006 Report Posted May 27, 2006 here is my code snippet Public Function Plane_heading() As Single ' degrees Plane's magnetic heading. Dim x As Long Dim dwResult As Long Call FSUIPC_Read(&H580, 4, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) Plane_heading = norm360((x / 65536 / 65536 * 360) - magvar) end function you may have to adjust for the magnetic variation, which is what magvar is (another function, to get the current magnetic variation) norm360 is a normalize function, which brings all heading to a range of 1-360 degrees
kaelastreet Posted May 28, 2006 Report Posted May 28, 2006 norm360 is a normalize function, which brings all heading to a range of 1-360 degrees Hi Could you share that with me please? Kaela
jd Posted May 28, 2006 Report Posted May 28, 2006 Function norm360(h As Long) As Long If h > 360 Then norm360 = h - 360 ElseIf h = 0 Then norm360 = 360 ElseIf h < 0 Then norm360 = h + 360 Else norm360 = h End If End Function
kaelastreet Posted May 28, 2006 Report Posted May 28, 2006 Hi. many thanks JD. wile I was at it, I tried my own version and got it all sideways. You just shed a lot of light on the matter there. Thanks Peter, I will re-read the results I was getting in FS_Interrogate. Could lead to a fruitful evening. I have seena routine somewhere in my stuff for rotating a graphic in VB, now I have been trying to find that, sigh, as we get older we have more answers, just that they seem cluttered up with a lot more 'other stuff'. I have to resist the urge to ask too many questions, but I am reading 'Theif of time' as well, so the two may overlap... One question: I offer this to you with so much more experiance than I, Can any of the existing material used in the Guages folder, be re-used outide of FlightSim, or can they ONLY be interpreted by FlightSim??? In your reply (and it works quite admirabley), h=(x / 65536 / 65536 * 360) - magvar, I think... Kizzie
kaelastreet Posted May 30, 2006 Report Posted May 30, 2006 Hi JD. Thank you for your help above. I have been exploring the MSDN pages at Microsoft.com, looking for a method I can adapt to rotate images. 0 degrees, 30 degrees, 60 degrees and 90 degrees I have been trying to find relativly simple VB code to enable me to rotate these images by o - 360 degrees. example: image.rotate(x) One method, would be to have three hundred and sixty five images, selecting each in turn to meet the need, but I think there is a more attractive solution. I understand that you may be able to point me in the right direction. Warmest Regards Kaela
craig1231 Posted July 2, 2006 Report Posted July 2, 2006 I couldn't find anything that relates to... example: image.rotate(x) But heres the next best thing http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=39615&lngWId=1 Craig
MattWise Posted July 8, 2006 Report Posted July 8, 2006 Ok here is what I am doing. I am using : Public Function Plane_heading() As Single Dim x As Long Dim dwResult As Long Call FSUIPC_Read(&H580, 4, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) Plane_heading = x / 65536 / 65536 * 360 End Function I get a return of .312 If I do this: Dim Vcount as long,MY_Heading as Single If FSUIPC_Read(&H580, 4, VarPtr(Vcount), dwResult) Then If FSUIPC_Process(dwResult) Then MY_HEADING = CSng(Vcount * 360#) / (65536# * 65536#) End If End If Text1.Text = MY_HEADING I get .312 my plane gyro compass is reading 340 whiskey is reading 340 But if I get the Auto Pilot heading I am doing this: Dim APHeading As Long Dim Convert As Single Call FSUIPC_Read(&H7CC, 4, VarPtr(APHeading), dwResult) Call FSUIPC_Process(dwResult) Convert = (APHeading * 360) / 65536 Me.Caption = Convert I get a return of 339.9 I can round. Thats not big deal. Can someone help me with the plane heading.
Pete Dowson Posted July 9, 2006 Report Posted July 9, 2006 Ok here is what I am doing. I am using : Public Function Plane_heading() As Single Dim x As Long Dim dwResult As Long Call FSUIPC_Read(&H580, 4, VarPtr(x), dwResult) Call FSUIPC_Process(dwResult) Plane_heading = x / 65536 / 65536 * 360 End Function I get a return of .312 I'm not familiar with VB, which I assume this is, but assuming "Single" is a type of floating point I would have thought it advisable to convert "x" to floating point first, before doing the calculations: Plane_heading = x Plane_heading = (Plane_heading * 360.0) / (65536.0 * 65536.0) Note that I always use parentheses () to force the order of computation -- I never trust compilers to get it right! ;-) Pete
Paul Henty Posted July 9, 2006 Report Posted July 9, 2006 Is the difference not due to magnetic variation? 0x0580 is a True heading, while the whisky compass, the gyro compass and the Autopilot heading at 0x07CC are all Magnetic headings. The current Magnetic Variation is at offset 0x02A0. If it's 20 degrees then your 0.312 is probably correct. Paul
MattWise Posted July 9, 2006 Report Posted July 9, 2006 So your telling me to drop the decimal infront of .312? If that is the case the how come AP is so close with 339.9?
Pete Dowson Posted July 9, 2006 Report Posted July 9, 2006 So your telling me to drop the decimal infront of .312? If that is the case the how come AP is so close with 339.9? No, he's not telling you that. Please read it again. The heading provided by the offset you are reading is in degrees TRUE --i.e. it is relative to TRUE North. The one shown on the panel is Degrees MAGNETIC. The difference is the magnetic variation, which is also readable if you want to convert one to the other. Your ".312" may well be the correct TRUE heading. Why don't you use FSInterrogate to check your results against? That is why it is provided after all. :-( Please read again the comments in the documentation about these offsets. Pete
MattWise Posted July 10, 2006 Report Posted July 10, 2006 Here is what I am doing: Dim PHeading As Long Dim MagVar As Long Dim dwResult As Long Call FSUIPC_Read(&H580, 4, VarPtr(PHeading), dwResult) Call FSUIPC_Process(dwResult) Call FSUIPC_Read(&H2A0, 2, VarPtr(MagVar), dwResult) Call FSUIPC_Process(dwResult) MagVar = MagVar * 360 / 65536 Plane_heading = PHeading Plane_heading = (Plane_heading / 65536 / 65536 * 360) - MagVar The Plane Heading is returning .312 while at 340. The MagVar is returning 20. If I do the final math I get -19.68761 Any ideas?
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