Jump to content
The simFlight Network Forums

daniedelport

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by daniedelport

  1. In that case it would be nice if you could explain this in more detail, don't you think?

    For Sure.

    Let's start all over, Pete. I hope for the last time.

    All I do is the following:

    1. Pause FSIM.

    2. Write the Position of the plane (Lat, Lon, Altitude, Pitch, Bank angle) to FSUIPC. (The plane now moves to its new location.)

    3. Read Magnetic Variation. (magv)

    4. Compute True heading by adding the Magnetic Heading I want, to the Magnetic Variation we just Read above in step 3. (Is the Magnetic variation of my new position (I wrote in step 2) not different than at the "old" position of my plane it was in before I moved in it in step 2?)

    magv = (magv * 360#) / 65536#
    FS_Head = txtHead.Text + magv                    
    FS_Head = (FS_Head * 65536# * 65536#) / 360#
    If FS_Head < -360 Then
       FS_Head = FS_Head + 720
    ElseIf FS_Head < 0 Then
       FS_Head = 360 + FS_Head
    ElseIf FS_Head = 0 Then
       FS_Head = 360
    ElseIf FS_Head > 360 Then
       FS_Head = FS_Head - 360
    End If

    5. Write the True Heading to FSUIPC.

    6. Finish

    I hope that my English, which is not my First language, is understandable.

    Clearly the mistake I make is somewhere in converting my Mangnetic Heading to True.

    (An interesting thing I saw is that if I write the Pitch angle before the Altitude gets written the Pitch changes significantly. Perhaps this can help someone. It makes sense.)

    Perhaps there is a order to write the Position parameters? (Lat, Lon, Alt, Heading, Pitch, Bank angle.)

  2. Pete

    You are clearly misunderstanding me unfortunately. The writing and reading to and from offsets is, as you put it, a doodle.

    The only problem I have and persistently plagues me is that the true heading I am writing moves my aircraft incorrectly. The coordinates and altitudes are fine and I only read the magnetic variation after the plane is moved. Ill just play with it a bit more.

    MagVar of +20, not -20 I assume you mean? There's 40 degrees difference!

    Why bother with a programming language to show simple arithmetic?

    Thats why I typed 20 and not -20.

    Thanks for the interesting way you answer my questions.

    Regards

  3. Pete

    Still no luck. I have tried it a thousand different ways.

    In fact, unless you need the separate values, you don't need to do it separately at all. It all simplifies out quite well. Just add the two (when converting MAG to TRUE) or subtract MagVar from Heading (TRUE to MAG) no matter whether either are currently in the correct range, THEN normalise the result by adding or subtracting 360 till in range

    This I got thanks Pete. Works fine when reading from FS BUT . . .

    If you have a magnetic heading of say 100deg and a magn variation of say 20deg, how would you Write it to 0580. Code in C will be fine. The mathematics will be the same.

  4. This topic has been discussed on this forum but I have difficulty writing a heading to FS. (First converting my Magnetic heading to true.)

    My code that works 100% in converting the heading is as follows:

    (Where hdg and magv were read from FS, as heading and magnetic variation respectively.)

    magv = Round((magv * 360#) / 65536#, 1)
    magv = 360 - magv
    hdg = Round(((hdg * 360#) / (65536# * 65536#)), 1)
    hdg = hdg + magv
    If hdg < 0 Then
       hdg = 360 + hdg
    ElseIf hdg = 0 Then
       hdg = 360
    ElseIf hdg > 360 Then
       hdg = hdg - 360
    End If

    In Writng the heading I do as follows:

    Dim FS_Head As Long
    
    magv = (magv * 360#) / 65536#
    magv = 360 - magv
    FS_Head = txtHead.Text - magv
    FS_Head = (FS_Head * 65536# * 65536#) / 360#
    Call FSUIPC_Write(&H580, 4, VarPtr(FS_Head), dwResult)      
    Call FSUIPC_Process(dwResult)

    Long is 4 Byte integer in VB.

    txthead is a text box with my magnetic heading I want.

    My problem comes in at converting the magnetic to true.

    Please help

  5. Pete

    Yes, I am writing certain values to open/unused offsets I have identified from 0x3210 onwards. It is for Hot key logging purposes.

    I can easily write single key presse like Z etc. but the combinations like in my post is a bit unclear. My application is in VB so perhaps one of the VB boffins out there can also help.

    Also how do I know when the GPS window is displayed? Is this possible without normal windows API's and purely with FSUIPC?

    Thanks

  6. I am defnately missing something huge.

    Why does all my read commands return zero to some of the basic ofsets. Is it something to do with my reg key or what. I do not think so.

    What does the varPtr() function mean?

    Am I correct in asuming that the data type I need to use must corelate to its size. E.g. if I need to read e.g. Ground altitude at 0020 then I would use a Long data type in VB which is 4 bytes long??

    Offset 3C00 which I presume is a string, what VB data type should I use? String does not seem to work.

    Thanks for all the help.

×
×
  • 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.