Jump to content
The simFlight Network Forums
cjellwood

Heading in the Bermuda triangle

Recommended Posts

Hi, I am having trouble with heading offset 0580. When my plane is heading 30 degrees, the FSCUIP shows 46? Here is my code ...

txtAirSpeed.Text = FormatNumber((AirSpeed.Value / 128D)).ToString

txtAltitude.Text = Altitude.Value.ToString

Dim BankValue = FormatNumber((Bank.Value / 10000000), 1).ToString

txtBank.Text = BankValue.ToString

txtFlaps.Text = Flaps.Value.ToString

Dim HeadingValue As Long = Heading.Value

HeadingValue = HeadingValue * 360

HeadingValue = HeadingValue / 4294967296

txtHeading.Text = HeadingValue.ToString

Dim PitchValue = FormatNumber((Pitch.Value / 10000000), 1).ToString

txtPitch.Text = PitchValue.ToString

am i doing something really dumb?

Share this post


Link to post
Share on other sites
Hi, I am having trouble with heading offset 0580. When my plane is heading 30 degrees, the FSCUIP shows 46? Here is my code ...

Are you by any chance comparing a MAGNETIC heading with the TRUE heading provided in offset 0580? Is the magnetic variation wherever you are about 16 degrees? You need to be aware of these things.

Please try using the tools available to check your own code. For instance, FSInterrogate will show you the TRUE heading and the Magnetic Variation (from offset 02A0).

Alternatively, if you put your aircraft into slew mode and press the Space bar (or possibly Shift+Space or Ctrl+Space in FSX?), it will turn your aircraft to TRUE north and you can read the magnetic variation locally from the heading indicator.

Regards

Pete

Share this post


Link to post
Share on other sites

The value I am getting from offset 0580 heading is different from the data Interrogator shows? example:

when the plane goes west to say '330 degrees', Interrogator shows 4143547924 where as my data read shows -151419372 ??

It is in sync when flying East so why the different data going west? Shouold Interrogator not be showing raw data the same as what I get from 0580?

Thanks

Share this post


Link to post
Share on other sites

when the plane goes west to say '330 degrees', Interrogator shows 4143547924 where as my data read shows -151419372 ??

Oh dear. Please use the FACTORED column in FSInterrogator, so you can see the converted value, not the raw FS units!

In any case you are mixing up signed and unsigned values. The heading is NEVER negative, it runs from 0 to 359.9999... and is therefore always positive. You are probably reading the correct data but treating it incorrectly.

It is in sync when flying East so why the different data going west? Shouold Interrogator not be showing raw data the same as what I get from 0580?

Going East the heading will be positive even if you are treating it incorrectly.

Pete

Share this post


Link to post
Share on other sites

This is my code to read and view the offset 0580

Dim Heading As New Offset(Of Integer)(&H580)

.....

Console.Write(Heading.Value)

how on earth can I be getting different data to the 32 bit output of interrogator?

Share this post


Link to post
Share on other sites

Dim Heading As New Offset(Of Integer)(&H580)

how on earth can I be getting different data to the 32 bit output of interrogator?

Integer in VB.NET is a signed 4 byte integer. You need a UInteger which is a 4-Byte unsigned integer. With signed integers, values greater than half the maximum value (in this case of a 4 byte integer, greater than 2147483647) are used for negative values (i.e. from 0 to -2147483647).

You need to do this:

Dim Heading As New Offset(Of UInteger)(&H580)

But this alone will not solve your heading difference problem. As Pete says you're probably not factoring in the local magnetic variation (see offset 02A0).

Paul

Share this post


Link to post
Share on other sites

I am factoring in the magnetic variation but that poses a new problem that may expose a bug in the works. The factored magnetic variation value is a constant 18.20435 when viewed in the Interrogator. Subtracting this from the heading value is easy but I get an obvious math problem when the heading is at between 343 -> 349 degrees i.e 343 - 18 = -1

so basically, now when I am at between 343 -> 359 degrees I get a negative value again?

I think it would be easier to just use the giro offset before I get banned for being a pain in the ass :)

on that subject, you reccomended using 'UInteger' to solve the previous problem... can you tell me what that type would be to get the Float64 value from 2B00?

Share this post


Link to post
Share on other sites
is there any danger in using offset 2B00 (Gyro compass heading) to get heading data? It seems to be the same as traditional heading data when it is factored

It's subject to gyro drift (unless you switch that off).

Pete

Share this post


Link to post
Share on other sites
Subtracting this from the heading value is easy but I get an obvious math problem when the heading is at between 343 -> 349 degrees i.e 343 - 18 = -1

A heading of -1 is the same as a heading of 359. Look at the face of the compass dial if you don't understand why!

Just normalise any result you ever get to lie in the range 0 to 359.9999... by adding 360 if it is less than 0, or subtracting 360 if it is greater than 360.

Note that the same applies to time. If you added an hour to 23:30 hours you don't get 24:30 but 00:30. and An hour before 00:30 is not -00:30. This is merely application of everyday common sense! ;-)

on that subject, you reccomended using 'UInteger' to solve the previous problem... can you tell me what that type would be to get the Float64 value from 2B00?

You need a programming reference for the language you are using. In C a 64-bit floating point number is a "double". I don't know what it is in yours, but you should be able to find out in the same way as you found out how to use the language in the first place.

Regards

Pete

Share this post


Link to post
Share on other sites
sorry, I think I am confiusing myself here. I will not write here again until I deal with my dumbness

Oh, I don't mind. don't worry. I try to explain everything when I see lack of understanding, so you should progress okay, hopefully. Sorry if I'm explaining things which you know in the process. But what's confusing still?

Regards

Pete

Share this post


Link to post
Share on other sites

can you tell me what that type would be to get the Float64 value from 2B00?

You use a 'Double'.

Thanks Paul. not totally different from C/C++ then! ;-)

Pete

Share this post


Link to post
Share on other sites

Thanks Paul. not totally different from C/C++ then! ;-)

Pete

Would be identical, except VB.NET insists on a rather vulgar and ostentatious capital D. ;-)

Share this post


Link to post
Share on other sites

This stage turned out ok in the end. I thought this was going the be the easy part!

To get around the negative value problem I simply created an argument to sniff the '-' and add 360. The doc gave me the impression that once the factoring was done correct then everything swims but obviously not. Surely Pete is aware of this glitch but relies on people being inteligent lol .

Public Class frmMain

Dim Altitude As New Offset(Of Integer)(&H3324)

Dim AirSpeed As New Offset(Of Integer)(&H2BC)

Dim Pitch As New Offset(Of Integer)(&H578)

Dim Bank As New Offset(Of Integer)(&H57C)

Dim Heading As New Offset(Of UInteger)(&H580)

Dim MagVar As New Offset(Of Integer)(&H2A0)

Dim Flaps As New Offset(Of Integer)(&HBFC)

...

txtAirSpeed.Text = FormatNumber((AirSpeed.Value / 128D), 1).ToString

txtAltitude.Text = Altitude.Value.ToString

Dim BankValue = FormatNumber((Bank.Value / 10000000), 1).ToString

txtBank.Text = BankValue.ToString

Dim FlapsValue As Long = Flaps.Value

txtFlaps.Text = Flaps.Value.ToString

Dim HeadingValue As Double = Heading.Value

HeadingValue = HeadingValue * 360

HeadingValue = HeadingValue / 4294967296

HeadingValue = HeadingValue - 17.89124

If HeadingValue < 0 Then HeadingValue += 360

txtHeading.Text = FormatNumber((HeadingValue), 1).ToString

Dim PitchValue = FormatNumber((Pitch.Value / 10000000), 1).ToString

txtPitch.Text = PitchValue.ToString

Gives this nice output. (you probably seen this before but I am impressed)

Untitled-2.gif

Share this post


Link to post
Share on other sites

To get around the negative value problem I simply created an argument to sniff the '-' and add 360. The doc gave me the impression that once the factoring was done correct then everything swims but obviously not. Surely Pete is aware of this glitch but relies on people being inteligent lol .

There's no "glitch", nor do you need very much intelligence!

If you take the Heading as an UNSIGNED value direct from the offset, take the Magnetic Variation, direct from the offset, and scale it to match the units of the heading (i.e. shift left 16 bits to make it a proper unsigned 32-bit value) then subtract it from the heading, you end up with another unsigned 32 bit number which when converted gives you the magnetic heading. That way you never need to add or subtract 360.

But either way, it surely isn't as matter of all that much intelligence to realise that -1 is the same as 359 when dealing with a 360 degree circle?

Regards

Pete

Share this post


Link to post
Share on other sites

the doc that says , "For degrees *360/65536. Convert True headings to Magnetic by subtracting this value". I just naturally assumed that once factoring was done then the subtraction took place? What you say is obvious now I see it before me sorry. The fact that -1 = 359 was not the issue I did not understand, it was the issue I needed help resolving which you have done

Thanks

Share this post


Link to post
Share on other sites

Hi again, I do not want to take up another thread so hopefully someone will hear my request here and help. Can someone please tell me the offset value of the barometric pressure readout circled in the picture below?

primary-flight-display-pfd-glass-cockpit.gif

Share this post


Link to post
Share on other sites
Can someone please tell me the offset value of the barometric pressure readout circled in the picture below?

That's the "Kollsman window", named after the German company that first started making altimeters with the viewable QNH adjustment window. Microsoft misspelled this as "Kohlsman" in their control names.

If you download the FSUIPC SDK, which is what you need if you are playing with offsets, you'll find a "Programmers Guide" (or for FSX an "Offsets Status") document, which lists all of the offsets set by FSUIPC. A search for "altimeter pressure" in that would have immediately found it at offset 0330.

Please do use the documentation supplied. It would be rather quicker than making fancy pictures! ;-)

Regards

Pete

Share this post


Link to post
Share on other sites

thanks Mr Pete :) I did see that offset in the guide but was confused when it said that FS does not use it? Anyways all good now thanks

Here is a screen shot of my pfd so far written in VB/GDI. Just to alter a few things on this section then later today i will start on the surrounding indicators such as oil temp, pressure, fuel etc. Shouold be a cracking little tool when finnishd although like all my projects they never are finnished lol So whats wrong with pretty pictures eh?

scrshot1.gif

Share this post


Link to post
Share on other sites
thanks Mr Pete :) I did see that offset in the guide but was confused when it said that FS does not use it?

What says FS doesn't use it? Of course it "uses" it. It is an essential part of all aircraft and always has been fully supported in FS for as long as I can remember!

Regards

Pete

Share this post


Link to post
Share on other sites
yI am visually impared hence why doing this project

You too? Sorry to read that. My impairment is Retinitis Pigmentosa (RP), but it is the type which progressively kills all my peripheral vision but leaves me my central detail (severe tunnel vision), so I can still work on a computer and read books, but fall over things, bang my head all the time, and can't go anywhere without crashing into people and shop displays!

No driving of course, nor real flying. But i suppose that's reveals the "good" side -- it was because I couldn't get my medical certificate for flying (it was on that test I discovered my impediment, which wasn't so bad back then) that I got so deeply involved in simulation instead. ;-)

Regards

Pete

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

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