Jump to content
The simFlight Network Forums

How reading the correct Compass Value - VB?


Recommended Posts

I have one question relating to the Wisky Compass Offset 02CC.<BR><BR>- Using VB 2008 - Timer set to a value of: 200 (even tried with different values)<BR><BR>Reading the Compass Value while:<BR><BR>1. flying with no Bank inclination - straight - compass value is correct.<BR><BR>2. changing the Bank inclination to the left - Compass Value is INCREASING<BR><BR>3. changing the Bank inclination to the right - Compass Value is DECREASING<BR><BR>It takes quite a lot of time to stabilize.<BR><BR>How can this be corrected in order to get a smooth reading like the GPS ?<BR><BR>Many many thanks in advance for your kind help.<BR><BR><BR>NB:<BR>i searched for a previous Forum Post and found 1 specific: <SPAN class=main_topic_title>Geting heading from FSUIPC with VB<BR><BR></SPAN>Is it possibile to get the VB code for a Hdg value like the GPS-Heading ?<BR><BR><BR><BR>Friedrich

Link to comment
Share on other sites

I have one question relating to the Wisky Compass Offset 02CC.<BR><BR>- Using VB 2008 - Timer set to a value of: 200 (even tried with different values)<BR><BR>Reading the Compass Value while:<BR><BR>1. flying with no Bank inclination - straight - compass value is correct.<BR><BR>2. changing the Bank inclination to the left - Compass Value is INCREASING<BR><BR>3. changing the Bank inclination to the right - Compass Value is DECREASING<BR><BR>It takes quite a lot of time to stabilize.<BR><BR>How can this be corrected in order to get a smooth reading like the GPS ?

You can't. That compass floats, and only reads accurately when flying straight and level. That's one reason why other aids were invented.

Regards

Pete

Link to comment
Share on other sites

You can't. That compass floats, and only reads accurately when flying straight and level. That's one reason why other aids were invented.

Regards

Pete

Many thanks for your quick answer.

That's one reason why other aids were invented.

It would be nice if someone could supply the VB code for getting the right Compass Heading when Banking left or right. (like the wisky compass when flying straight)

We have the following Offsets:

Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' compass Heading

Dim truehdg As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H580) ' True Heading

Dim magvar As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2A0) ' Magnetic Variation

Dim gyrodrift As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&HC3E) ' Gyrodrift

Many thanks in advance,

Friedrich

Link to comment
Share on other sites

Is it possibile to get the VB code for a Hdg value like the GPS-Heading ?

Hi Friedrich,

You need to get the true heading (0x0580) and then subtract the magnetic variation at the player's location (0x02A0):

The offsets declarations are:

Dim magneticVariation As Offset(Of Short) = New Offset(Of Short)(&amp;H2A0)
Dim playerHeadingTrue As Offset(Of UInteger) = New Offset(Of UInteger)(&amp;H580)

The conversion is:

Dim hdgTrue As Double = playerHeadingTrue.Value * 360D /(65536D * 65536D)
Dim magVar As Double = magneticVariation.Value * 360D / 65536D
Dim hdgMag As Double = hdgTrue - magVar

This may give you a heading less than 0 or greater then 360. Use a normalisation function to correct this:

hdgMag = Norm360(hdgMag)

    Function Norm360(ByVal h As Decimal) As Decimal
        If h &gt; 360 Then
            Norm360 = h - 360
        ElseIf h = 0 Then
            Norm360 = 360
        ElseIf h &lt; 0 Then
            Norm360 = h + 360
        Else
            Norm360 = h
        End If
    End Function

This will give you the actual True heading and will probably be the same as the GPS heading.

It may not be the same as the heading on the HSI instrument because of gyro drift. If you want to factor that in you need to also add:

Dim gyroDrift As Offset(Of Short) = New Offset(Of Short)(&amp;HC3E)

And add that into the calculation:

Dim drift as Double = gyroDrift.Value * 360D / 65536D
Dim hdgTrue As Double = playerHeadingTrue.Value * 360D /(65536D * 65536D)
Dim magVar As Double = magneticVariation.Value * 360D / 65536D
Dim hdgMag As Double = hdgTrue + drift - magVar
hdgMag = Norm360(hdgMag)

Paul

Link to comment
Share on other sites

We have the following Offsets:

Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' compass Heading

Dim truehdg As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H580) ' True Heading

Dim magvar As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2A0) ' Magnetic Variation

Dim gyrodrift As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&HC3E) ' Gyrodrift

Friedrich

But only the whiskey compass offset is a Double type. Please read the User Guide supplied with my DLL that explains what VB.NET types to use with each size offset. The offset sizes are marked in the "FSUIPC For Programmers.PDF" and "FSUIPC Offset Status.PDF" that comes with the FSUIPC SDK.

The same documents also explain how to convert the values from FSUIPC into 'human readable' values, as shown in my post above.

Understanding these two concepts is essential. You can't use the FSUIPC interface without this knowledge.

Paul

Link to comment
Share on other sites

It would be nice if someone could supply the VB code for getting the right Compass Heading when Banking left or right. (like the wisky compass when flying straight)

We have the following Offsets:

Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' compass Heading

Dim truehdg As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H580) ' True Heading

Dim magvar As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2A0) ' Magnetic Variation

Dim gyrodrift As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&HC3E) ' Gyrodrift

If you want the heading, as showing on the AI, then just compute it from the True Heading and the Mag Var. But note that of the values you list above only 02CC is actually a Dounble. The others are all integers of 32 or 16 bits (4 or 2 bytes). Please re-read the details in the offsets list. You need always to take care to read and interpret data in the correct way.

Pete

Link to comment
Share on other sites

But only the whiskey compass offset is a Double type. Please read the User Guide supplied with my DLL that explains what VB.NET types to use with each size offset. The offset sizes are marked in the "FSUIPC For Programmers.PDF" and "FSUIPC Offset Status.PDF" that comes with the FSUIPC SDK.

The same documents also explain how to convert the values from FSUIPC into 'human readable' values, as shown in my post above.

Understanding these two concepts is essential. You can't use the FSUIPC interface without this knowledge.

Paul

Many thanks to you and Pete. In fact i noticed the Double + Integer values.

Regards,

Friedrich

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.