Skip to content

Tips And Tricks For Setting Simulator Values

Max Paperno edited this page Oct 29, 2022 · 5 revisions

Tips And Tricks For Setting Simulator Values

16384

You will see the value +/-16384 appear often, which is a common range for various simulator "set" commands, especially for things like control surfaces and levers.
Typically this translates to some percentage value within the simulator (eg. -16384 aileron deflection is 100% to the left, or technically "-100%"). So it usually helps to translate the awkward 16384 value to percentages, as demonstrated in various examples below.

As an aside here, in the SimConnect documentation, the value 16384 is commonly listed as 16383 instead. In fact I believed that at first and the first version of this page said "16383" everywhere. Turns out the docs are wrong, and, for example, setting propeller pitch to 16383 only gets it to 99.9%. And the variable values we get back from SimConnect are also in the 16384 range. 16384 actually makes a lot more sense from a programming and math perspective since it's a nice 0x4000 in hex and also evenly divisible. 8-)

Percentage of 16384

16384 * (percent / 100) or eg. for 5%: 16384 * 0.05

Examples

Set throttle to -15%

16384 * -0.15

Throttle advance in 5% increments

${value:MSFSTouchPortalPlugin.Engine.State.ThrottleEngine1} * 163.84 + 16384 * 0.05
                                                            ^^^^^^^^   ^^^^^^^^^^^^
                                         Convert % to 0-16383 range.   Add 5% of full range.

Adjust AP Hold values by custom stepping

Add 1000' to currently set AP altitude hold value:
    ${value:MSFSTouchPortalPlugin.AutoPilot.State.AutoPilotAltitudeVar} + 1000
The other AP settings work the same, just use the corresponding state variable.

Circular AP heading adjustment with custom stepping

Increments heading in 5° steps and wraps around to 0 after 355 (due to modulo operator):
    (${value:MSFSTouchPortalPlugin.AutoPilot.State.AutoPilotHeadingVar} + 5) % 360

Simple BCD

MSFS likes to use "BCD" (Binary Coded Decimal) format for radio frequencies, and in some cases the format is required to set some values (in other cases simpler decimal Hz notation can be used).

Many explanations of BCD will delve into complicated math or bit shifting, but there is a much simpler way to turn a frequency, like 339.0 MHz, into a BCD value.

The trick is that you can simply take the frequency in decimal notation and turn into a hexadecimal (base 16) value. Here is what 339.0 MHz looks like in BCD32 format but written out in base 16: 3390000

See what I mean? We basically just need to multiply the frequency by 10,000 to accommodate the decimal places and write it out as if it was a base 10 integer.

Now, to send this value to the simulator via a plugin action (an event value or setting a Sim Var) we have to indicate that the value is in base 16 (hex) notation. This is done by prefixing the value with 0x before sending, which is a typical notation style for hexadecimal values in the computer programming world. Continuing the above example, this turns into 0x3390000. The plugin will then convert this value to decimal automatically before sending it on to the simulator.

As another example, 124.85 MHz would be 0x1248500 in BCD32 hexadecimal notation.

For BCD16 we have to drop the first hundreds digit. So the value becomes 0x2485

BTW, the "16" and "32" in "BCDnn" represent the number of memory "bits" that can be stored in a value (each bit storing a binary 0/1). Each hex digit uses an even 4 bits of memory (and two digits make a Byte), which is one reason programmers like base 16 notation. To the computer, in binary notation, 0x2485, which is 16 bits, looks like 0010 0100 1000 0101.

The Windows Calculator has a "Programmer" mode where one can view different base notations of a value at the same time, among other geeky features.