The simFlight Network Forums

# Getting the Bank Angle of the Aircraft

## Recommended Posts

Hello!

I was wondering how I can read the bank angle from FS, and to output the result in degrees. I'm programming a GPWS which will call out "Bank Angle - Bank Angle" when exceeding a 30 deg (or what you like to set it to) turn.

I've tried to use 057C-offset, but the values varies a lot when I get them. I'm programming in Visual Basic 6.

/Chazzie

##### Share on other sites

I've tried to use 057C-offset, but the values varies a lot when I get them. I'm programming in Visual Basic 6.

Sounds like you have an error then. Please check out FSInterrogate in the SDK. Use it with my FSUIPC.FSI file, also in the SDK, and you can see not only the value changing, but also compare all of its different "raw" forms depending how it is interpreted.

My bet is that you are losing part of the value -- maybe multiplying the possibly very large integer by 360 and so overflowing? If so either convert the value to floating point BEFORE calculating, or do at least part of the divisions first.

Regards,

Pete

##### Share on other sites

What would be the correct formula for converting the raw in-data?

is *360 / (65536*65536) used to write the data, if the input-data is the degrees from the user, or is it the other way around?

Also, when using FSInterrogate I only get 0's in all fields...

##### Share on other sites

is *360 / (65536*65536) used to write the data, if the input-data is the degrees from the user, or is it the other way around

It describes how you get degrees from the value provided. All it means is that the FS way of storing angles is to scale them so the biggest possible angle (360 degrees, or for bank +/- 180) fills the entire capacity of the space available. This gives the best precision in a fixed point number.

So, 65536 * 65536 gives the total number of different values you can store in 32 bits (65536 is the number for 16 bits), and FS wants to use all those values to represent 360 degrees. Hence the scaling, for a value occupying n bits::

FS units = degrees * (number of values you can get in n bits) / 360, or

degrees = FS units * 360 / (number of values you can get in n bits)

You have to perform these calculations in such a way that you don't lose values by overflow or by truncation. The easy way out is to use floating point, but if you only want whole numbers of degrees, or some other approximation, then doing part of the division BEFORE the multiplication would be okay.

Also, when using FSInterrogate I only get 0's in all fields...

Is FS running? Is the aircraft banking? If so you've certainly got something wrong there. Are all the values zero? Maybe you are not using the version in a recent SDK and haven't registered FSUIPC? Check the FSUIPC log.

If you get used to using FSInterrogate to check your programming you will find it much faster and come to understand a lot more, more quickly. That's why it is provided.

Regards,

Pete

##### Share on other sites

Got it working like a charm!

Thanks a bunch!

##### Share on other sites

Got it working like a charm!

Good. Did you get FSInterrogate working too?

Pete

##### Share on other sites

Well I only have FSUIPC registered for my application, so maybe the error lies in my otherwise "user"-unregistered version of FSUIPC. I only use FSUIPC for communication with this software (right now atleast) so I don't feel the need to register it. Maybe later on I'll find a use for the registered version as a user, but currently I'm happy with my FlightSimming experience, as soon as my GPWS/FA/CoPilot software is complete :P

##### Share on other sites

Well I only have FSUIPC registered for my application, so maybe the error lies in my otherwise "user"-unregistered version of FSUIPC.

But the FSInterrogate.exe I supply in the FSUIPC SDK comes with a valid access key embedded in its "properties" and will work with unregistered installations of FSUIPC. These are the details:

FSinterrogate.exe

Product = "FSInterrogate", Company = "Pelle F. S. Liljendal"

Key = 161C 7AUZ D1BV

If it isn't connecting for reason of registration, it will say so in the Log, and this would imply you have a pretty old copy of the FSUIPC SDK. However, I also give the above details in the "Freeware Key" list near the top of this Forum.

Regards,

Pete

##### Share on other sites

I will look into FSInterrogate later, as I've managed to aquire all the variables I need from FS at the moment.

## Create an account

Register a new account