Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello!

I like to build my own ruder trim display (trim Axis vie joystick and FSUIPC works very fine).

In Offste $2EC0 the Value is given as Float64 in Rad´s. FSinterrogate shows it in propper way. How can I convert this to a byte or to a word (0-255 or 0-65k) meaning minimal value is 0 maximum value is 255 or 65k.

I have to do this in VB6 (sorry). I read the example of getting Latitude in SDK section VB, using the Currency as faked 64 bit value. But it seems that I am not able to convert it after reading it without any problem.

I am using Code like this:

Dim FSUIPC_Dec As Currency

Dim FSUIPC_Adress As Long

Dim dwResult As Long

FSUIPC_Adress = &H2EC0

If FSUIPC_Read(FSUIPC_Adress, 8, VarPtr(FSUIPC_Dec), dwResult)Then

If FSUIPC_Process(dwResult) Then

Debug.Print FSUIPC_Dec

End If

End If

Near the middle value I got something like -922337203685477,5808

Just a little bit trimming right value jums to 457181508797632,3482 and going on to the right, value slightly increases to 459565997674557,6039

Simmilar by trimming to left only with negativ values.

Can anyone help me?

Thanks a lot!

Peter

Posted

In Offste $2EC0 the Value is given as Float64 in Rad´s. FSinterrogate shows it in propper way. How can I convert this to a byte or to a word (0-255 or 0-65k) meaning minimal value is 0 maximum value is 255 or 65k.

You may need to design this for a specific aircraft, because the extent of the trim available is probably aircraft-dependent. If you want to use it with a variety you'll need to measure that value (in radians) for those and select the maximum.

The it is merely a matter of simple arithmentic to scale the value. For example, if the trim varies from -0.2 to +0.2 radians and you want a range from 0 (for -ve extreme) via 128 (centre) to 255 (+ve extreme) you would need to do this:

ScaledValue = (RadiansValue + 0.2) * 255 / 0.4

The "+0.2" is to get the -ve maximum to your zero, giving a Radians range of 0.0 to +0.4. Then the * 255 / 0.4 merely scales that to the range 0-255.

As for the rest, I'm sorry but you need someone who knows Visual Basic. I have no idea why you are using this "currency" type when I am pretty sure VB supports double floating point numbers as a type on its own. Isn't "currency" a way of faking 64-bit FIXED POINT numbers, like the latitude/longitude, not floating point doubles like this? Are you perhaps getting confised between totally different 64 bit representations?

I expect someone who knows VB will jump in.

Regards,

Pete

Posted

Thanks a lot Peter!

it was my mistake to mix FIXED POINT and double float (both 64bit)

I changed datatype dec to double, and now it works fine.

Peter

Austria

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.