MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
paul_max
From: United Kingdom
Posts: 74
Supporter
The heading value from FSUIPC is in integer space, every degree is a step of 182.

However the definition of the preset "Autopilot - Heading" in MobiFlightConnector 7.4 is to multiply by a floating point number, 0.0054931640625
This is mathematically wrong, as the floating point calculation will never exactly lie at the correct heading. Several values were one degree different from the default FSX 737 MCP Heading display. For example an FSUIPC value of 128 displays as "0", when it is clearly 1 degree.

The correct solution is to perform the Transform in integer space, for example:
Divide the FSUIPC number by 182, i.e. $/182. That transform produces correct angles, verified from 0 to 360 manually, that match FSX SP2.

Regards
Paul
[Last edited by paul_max, 2018-01-09 11:18]
2018-01-09 11:12
Avatar
StephanHo
From: EDDG, Germany
Posts: 1867
Supporter
Which offset do you refer to?
Grüße,
Stephan (Time: UTC+2)
2018-01-09 19:40
Avatar
paul_max
From: United Kingdom
Posts: 74
Supporter
Stephan,

As I said, its the "Autopilot - Heading" preset. You can find it in presets.aip:

<config>
<active>true</active>
<description>Autopilot - Heading</description>
<settings msdata:InstanceType="MobiFlight.OutputConfigItem, MFConnector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<source type="FSUIPC" offset="0x07CC" size="4" mask="0xFFFF" multiplier="0,0054931640625" bcdMode="False" />
<comparison active="True" value="0" operand="=" ifValue="360" elseValue="" />
<display type="Display Module" trigger="normal" ledAddress="0" ledConnector="1" ledModuleSize="8" ledPadding="True" ledDigits="0,1,2" />

</settings>
</config>

It references offset 0x07CC with a multiplier of "0,0054931640625". That fails completely when rounded to an integer; 1/182 is a recurring number also. Verboten ;)
The correct transform is divide by 182, as each degree in the FSUIPC offset is 182.

Nearly all the FSUIPC offset values are integers, bytes or bits, so there is no need for (slow) floating point arithmetic.

Best regards
Paul.
2018-01-09 20:44
Avatar
StephanHo
From: EDDG, Germany
Posts: 1867
Supporter
Hi Paul,

Sebastian, the developer of MobiFlight has often calculated the calculations and entered the result in the Transform area.

So also for the offset 0x07CC.

In the FSUIPC list this is at the offset:

iconFSUIPC:

Autopilot heading value, as degrees * 65536/360



Now if you change the calculation rules of Pete Dawson, then the value is right.

1/65536 * 365 = 0.0054931640625

1/182 of course gives the same.

So Sebastian just kept to the target.
I assume that he himself will say something about it.

If you look into FSUIPC's offset status list, you will certainly see a lot of interger values, but at least as many floats, especially in terms of ups, courses, flaps, speeds, etc.
Grüße,
Stephan (Time: UTC+2)
2018-01-09 21:24
Avatar
paul_max
From: United Kingdom
Posts: 74
Supporter
iconStephanHo:

Hi Paul,

iconFSUIPC:

Autopilot heading value, as degrees * 65536/360



Now if you change the calculation rules of Pete Dawson, then the value is right.

1/65536 * 365 = 0.0054931640625

1/182 of course gives the same.



Stephan, No it is not the same, you must understand floating point to integer rounding in microprocessors and computer languages. A floating point number of 1.9999 becomes 1 not 2 because the mantissa is removed (the part after the decimal point), when converting a floating point number to an integer number. The majority of FSUIPC offsets use integer parameters, so conversion between real and integer is very important.

Look at the FSUIPC value in MobiFlight for Headings of 1, 2, 3, 10, 100, 359 degrees, it is 182, 364, 546, 1820, 18204, 65354
Division of (FSUIPC value) / 182 gives a very accurate result because of integer arithmetic 100% accurate compared to the FSX 737 MCP.
But conversion of the real number (value * 0.0054 etc) to an integer will give errors, up to one degree from FSX.

regards
Paul

BTW I have many years experience in Z80/6502/8086 machine code, FORTRAN, C++ and JavaScript, so I am interested in fixing these problems. A pull request to change presets.aip would be required, which Sebastian and other developers could review and approve.
[Last edited by paul_max, 2018-01-10 14:41]
2018-01-10 13:12
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi Guys

Please Note:
The PRESETS are a relic of the first Hours of Mobiflight !
Its high recommend to build the Configs Yourself !!!! Sebastian not support the hole Preset List until now and stop after this 30-40 "examples"

Additional information about that strange Multiplication Float value.....
THIS is also a relic of a older System.... before Mobilflight 6.?? there was no "TRANSFORM" Field.... In the Past there was a "MULTIPLY" Field on same Spot.
In the Past it was not possible to use expressions (divide) like $/10.... So it was nessesary to use $*0,1 to get same result cause ONLY Muiltply * was allowed !

****
Finaly....

I not try out if it´s possible at the moment to use transfrom $/65536*360
Maby Yes....
But in some Offsets we get a Override problem..... If We need to Multiply a high value with another high Multiplicator we reach the Value Limit of a DWord 32Bit.
(I think Mobiflight or the expression itself not allow numbers bigger then "4.294.967.295" ( Whatever its just a temporary step of calculation) )
so in some cases we MUST use a Float Multiplyer instead of a formula.

Last Note:
iconpaul_max:


The correct transform is divide by 182, as each degree in the FSUIPC offset is 182.



Thats also NOT correct !!!!

iconFSUIPC:

Autopilot heading value, as degrees * 65536/360



65536/360 is NOT 182 ... its 182,044444444

The final question is.... How is the rounding?
FSX Not show the FSUIPC Value 1:1 ... its Roundet ( Whatever by FSX or by FSUIPC )
Good Luck !
2018-01-13 02:00
Avatar
paul_max
From: United Kingdom
Posts: 74
Supporter
Pizman

With respect, you do not seem to understand that real to integer conversion will often discard the mantissa.

FSX is indeed rounding. But look at my results - I get 100% perfect match with FSX display. Integer division is very fast.

So my solution is fast and 100% accurate with FSX..

Regards
Paul

PS: MobiFlight is an excellent tool for sim builders. I have sucessfully prototyped a 777/787 MCP using it. Pictures soon.
[Last edited by paul_max, 2018-01-13 08:14]
2018-01-13 07:43
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi. I´m sorry if i understand wrong.... But i think we talk about 2 different things (and mean the same result maby)

Please look at your statement....

iconQuote:

Look at the FSUIPC value in MobiFlight for Headings of 1, 2, 3, 10, 100, 359 degrees, it is 182, 364, 546, 1820, 18204, 65354
Division of (FSUIPC value) / 182 gives a very accurate result because of integer arithmetic 100% accurate compared to the FSX 737 MCP.
But conversion of the real number (value * 0.0054 etc) to an integer will give errors, up to one degree from FSX.



I not check this values but i trust in you the data is correct.....

Now look at 10° ... Value is 1820 (10*182=1820) All Ok......
But now look 100°... Value is 18204 !! (100*182=18200 .... But 100*182,0444 = 18204 (Without the floating)!
Same occures in 359° .... Your system say 359*182 must be 65338 BUT Offset you said is 65354
******************

If i´m right then FSUIPC not show a 100% correct value of fsx.... It just read the raw value of the sim and support it in a Offset.... The Sim Itself have already a own "rounding" logic finaly.

Solution can be to use the rounding in Mobiflight, too.


You say yourself.... A System like Mobiflight just ignore the floating Point sometimes ( For example in 7 Segemnt Display)
Here a Value of 1,9876 will be shown as 1 ( All behind the decimal is ignored)
BUT we can use "Round" Command in the Syntax.
Maby like: round(($*0.0054931640625),0)

Now $ get multiply..... But a Result like 1,999 Now will be rounded to 2 instead of ignoring the decimals without rounding)

****

Hope my input is correct.... I´m sorry my english is not perfect to understand you complete. Thats a bit difficult to learn something new in a different language!
Good Luck !
2018-01-13 15:20
Avatar
paul_max
From: United Kingdom
Posts: 74
Supporter
Pizman

If you look at Sebastian's introduction videos on You Tube, he divides the raw heading by 182 just like I do. End of discussion! ;) :lol:

I still think MobiFlight has an amazing future!

-Paul
2018-01-17 12:44
Avatar
petergl
Posts: 1
Hi all

try this in Output
FSUIP.TRANSFORM = ($ * 360) / 65500
Compare.comparison setting
If current value < 0
then $+361
else $
it looks good.
2021-03-05 17:20
icon