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! 

Posts: 8
I'm very new to Mobiflight but what I've accomplished so far is amazing. At least I think so... What I'm trying to do is to have an led turn on when the level in the fuel tank reaches some percentage, lets say 10% fuel left. I don't know how or where to specify the offset 0b7c and 0B94 formula which is % * 128 * 65536. I've got the output leds working, but right know they are always on. Does this need to be a precondition and if so, what does it look like and how is it formatted. Any help would be so appreciated. If I can get a handle on this I can then put the knowledge towards the same sort of ideas for minimum oil pressure and maximum oil temperature. This round is for FSX but hope to move on to x-plane.

Thanks in advance,

I was thinking that maybe using Compare would be the answer? I don't know how to write it, but the logic would be: if the current value <=10% of the tanks capacity, then set to 1, else set to 0. I'm now thinking I need to know the tank size. I was hoping the size could be known from the offset so it would work for different planes.
[Last edited by ifrpilot89, 2019-04-25 06:36]
2019-04-25 04:33
From: ETSI, Germany
Posts: 6010
Hi Steve !
Welcome to Mobiflight !

Its verry interesting to me, see how other brains work ;)
Your on the Right way..... Whatever to difficult .
I hope its OK if i explane this detailed (longer text). So you "learn" more and can build your next projects youreself !


Basic Knowledge.

1. Think about your Sim and your Aircraft.
The Offsets you say are standard Offsets for P3D and FSX (FSUIPC) . So your System will work 100% for FSX/P3D Standard Aircrafts
If you use a AddOn Aircraft then this Offsets "can" work but they not must work.... Cause a AddOn can use Own Fuel System it the developers decide for that. Normaly not!
If you use XPLANE then it can be different at all. Here you must find out yourself if "XPUIPC" Tool include the Fuel System and it work correct. Most functions work also in Xplane but not all. If the wont work you must do some scripting work to implement them.

2. Number of Tanks.
You must know the Number of Tanks in Use for your Aircraft. Your logic will not work correctly if your Aircraft got also a center, Aux or Tip Tank.
Here i recommend to tank your Plane 100% and then you must observe all Fuel Offsets 1 Time..... so you see what Tanks are in Use internal in the Sim Logic.

0B74 4 Fuel: centre tank level,
0B7C 4 Fuel: left main tank level
0B84 4 Fuel: left aux tank level
0B8C 4 Fuel: left tip tank level
0B94 4 Fuel: right main tank level
0B9C 4 Fuel: right aux tank level
0BA4 4 Fuel: right tip tank level

Just Chekc what offset is Zero and what offset have a High Value to see what tanks are in Use.

3. Forget the Capacity !
Here you have a thinking issue. The Capacity is not important here. What you need is warning light if Fuel is BELOW a Percent Value. So Normaly your right.... If you have a Value that show Fuel in Liters or Galleons then you need to know the Capacity of Tnak to define the 10% Point.
BUT: In our case we already got it ..... "0B7C 4 Fuel: left main tank level, % * 128 * 65536" This Offset already give us the ammount of Fuel in PERCENT !
So whatever your tank have 1000 or 8000 liters quantity.... if it reach 100 or 800 Liter in Both examples..... the Value of the Offset is the same cause its already percent !
But sure.... If you like for example a System that light a LED if exactly 100 Liters of Fuel are left.... then you need to calculate the capacity and how many Percent will represent 100 Liters.... So you get a value finaly. ( AGAIN.... Thats not needed in your example)

4. Value in a Clear form.
FSUIPC Values are sometimes (often) not in a clear syntax.... This Offset not show a value from 0 to 100 representing the percents.

0B7C 4 Fuel: left main tank level, % * 128 * 65536

This mean.... The Value is the TankLevel in Percent multiply with 128 and again Multiply with 65536 .
So a Value of 10% Fuel will show 10*128*65536 = 83886080
(I know thats confusing.... But FSUIPC work in Binary and Hexadecimal internal....So the Decimal Values often make no direct sense and must be reworked by user finaly. )
To get finaly a Value in Percent in clear numbers you must reversed that Calculation. .... In That Case you must divide this through "8388608"
(or in to Steps you say divide throgh 65536 and then divide the result through 128 ...... Both result in the same number)

5. LED Logic.
Here its easy.... a LED is Bool. It have only 2 States. ON or OFF . If Value of Config is ZERO "0" then its OFF. If Value is not Zero (Whatever number) it is ON.
So you need no Compare like IF xxx then 1 cause it light also at xxx . The Only thing you need is to define the non ligthing Situation with "0" . ( But sure its also not wrong to define the "1" if you like..... Its just not needed)
In Your Case you can use COMPARE Tab OR You can use TRANSFORM Line ( In Transform you must write a If Condition.... In Compare this is Done in the GUI)
As we find out in Point 4 a Fuel of 10% represent a Offset Value of 83886080
So Say in Compare : IF Value LESS < 83886080 THEN 0 ELSE 1 ( The ELSE is not needed basicly as i explaned above)
For Transform Field the correct Syntax would be if($<83886080,0,1)

6. Multiple Logic.
All till now is for ONE Tank. If you like to do this for Multiple Tanks with only ONE Led then its a bit more difficult.
Easy Solution is to use a single LED for each Tank.... (Maby combined in ONE Anounciator. Then you need no Software logic here.
If you like ONE Led then we need in that example 4 Configs.
Config 1 Read the Left Tank ( But have no Own LED ... Its just to get a Value )
Config 2 Read the Right Tank ( Also no LED in use here)
Config 3 Manage the LED to get ON ( With a Precondition that say "Whatever Tank 1 or Tank 2 is below 10% please go ON
Config 4 Manage the LED to get OFF ( With Precondition that say "If both Tanks are over 10% please go OFF)

This is a bit advanced. If only ONE Config controll a LED it workes fine. If you like to "Precondition" 2 Configs to conroll 1 LED then we got a problem cause the LED will "hold" its status whatever the config that controll it is Disabled. Thats why you need here 1 Config for ON and one Config for OFF. In a future Release of Mobiflight we will implement a new Feature that make this much more easy !
If you need help here please request again.


Hope that was all. Have fun my friend !
Good Luck !
2019-04-25 12:11
Posts: 8
You're the MAN!! Thank you so much for the help. It worked like a champ. I've now got a better understanding of how to look at the data from FSUIPC and what to do with it in Mobiflight. I'm sure I'll have more questions, and I look forward to your informative and constructive answers.
Thanks again my friend.
2019-04-25 22:48
From: EDDG, Germany
Posts: 1867
Small correction:

FSUIPC sends the value 8388608 as the default value when the tanks are full. This applies to each tank individually, provided that they have the same capacity.
If I want this value in percent, the transform line must look like this: $/128/65536*100

At a multiplier of 100 only the pure integer value is displayed. With a multiplier of 1000 the value 3 digits is displayed and with a multiplier of 10000 4 digits. It is thus possible to display 1 or 2 decimal places for a display with 7 segments - based on the percentage value.

Then the value of the full tanks is 100%. This value is output for each existing tank. An output on all tanks is not provided.

For LED control would then, as pizman has already said, be changed to the TAB comparison and the values ​​are correspondingly AND-linked, for which the LED should display less than 10%. This can then be up to 8 links. It is important to note that the tanks will be flown evenly, otherwise the links will not work. With a corresponding fuel management, the tank contents can be pumped, if the aircraft offers this possibility.
In the Mooney Bravo, e.g. only be switched between left and right tank. These specific circumstances must also be taken into account.

I tested this with P3DV4 and an AC-130H USAF
Stephan (Time: UTC+2)
2019-04-25 23:55
From: ETSI, Germany
Posts: 6010
I´m Sorry about that.

I not test this .... Just "read" the List. For me a Fuel Level in percent means a value from 0-100 ..... But as Stephan said it will need a 100 Multiplyer THEN looks like FSUIPC here work wit 0,01 to 1,00 . Whatever..... Then my explaned system must be just reworked....
If "8388608" represent "1,00" and that mean 100% Full Tank then simply 838860,8 roundet to 838861 represent 10 Percent ! ( Hope thats correct now)

About the Multi Tank use....

Here Stephan also think correct.

You can include more then 2 Tanks in the Logic.
Here you need simply a AND Logic for the OFF Config. LED should be OFF if Tank1 AND Tank2 AND Tank3 AND Tank 4 and so on have MORE then 10 % of Fuel.
For the ON Config you need a OR Logic. here you say LED should be off if Tank 1 OR Tank 2 OR Tank3 and so on have Fuel LESS then 10 Percent.

Recommend workflow to get experience with those logics.
Not use the Fuel System..... Cause refuel takes a lot of time and click work. Use easy things like Parking Brake, Lightstatus GEarstatus Flaps etc..
Read this things in multiple Configs and then build a Logic....
For example a LED should be ON if Landing Light is On or Parking BRake is set.
It should be OFF if Both are not Set/On.
With this "improvisional" technic you can easy change the status of the functions by one click to make your testings!

Sound maby strange.... But if i do testings for users or for new features.... I use in 90% of situations the ordinary Parking Brake tutorial Config ! ;)
Good Luck !
2019-04-26 02:51
Posts: 8
Thank you both for the correction. I did end up trying the 838861 earlier when the longer value didn't work, but the explanation certainly helps in understanding the why. I want to say that I am very impressed with this, your program. But mostly, your eagerness to help is amazing. You both should be very proud!!

Thanks again,
2019-04-26 06:21
Posts: 8
I thought I had it all working fine, which it is....sort of. When I push the button that tests the annunciator lights, it cause the Parking Brake to be set then upon release of the button it releases the Brake. It also turns the Alternator switch off, and it empties the fuel tanks. I've looked everywhere, but can't find the answer.
So I've got the "Output" led defined for each light. I've got the "Input" button defined so when pushed the offset for that item is called and given a "1", and when released, a "0".
This controls the annunciator lights as wanted. But, it also can affect the device it's monitoring. I'm sure I'm somehow telling it to do this, but I can't figure out where.

Have a great weekend!
[Last edited by ifrpilot89, 2019-04-27 06:48]
2019-04-27 02:33
From: ETSI, Germany
Posts: 6010
Wow ... Do you remember what i said last time...

Its verry interesting to me, see how other brains work ;)

In that case your brain workes verry "strange" .... But again. Its high interesting to see how new users try to solve Problems.... that show us how we can make things more easy or how we can explane things better to the users.

About Problem:

Your technic is completly wrong here.
Please correct me if i understand/translate your request wrong.... You like a TEST Button in your Cockpit that let all LED Light up if its pressed.
In That case its wrong to "change" the Status of the Function.... You just must "simmulate" the situation.

Simple example.... If a B737 or Airbus Pilot do the "Fire Warning Light Test" then he will not take a Molotov Cocktail or a rod of dynamite and throw it in the Engine :cry:
He simply press a Button that "simmulate" that situation and then the Lights will go ON.
Same if you use the Light Test Button in a B737.... All Lights go ON.... For example also the Fuel Punp Low Pressure Light ..... But this not mean that there is a real Low Pressure Situation at the moment... So you will not reject your fuel here to make the pump go dry.

Back to your Setting. You try to controll the Lights by creating a situation that will bring the lights ON . ( For example you say your "Test" Button will write on Press the Offset of Parking Brake to "1" and on Release the Parking Brake Back to "0" .
So here your Light will go ON and OFF..... But sure... You will also Set and Release the Brake ! .
Same with Fuel..... Your Fuel is for example full (8388608) with Press you set to "1" with Release to "0" .... This will Light your LED.... But it will also set your Fuel to 1 or 0 what represent maby <1 Liter of Fuel in your Tank !

For Light Testings we NOT change the Real Offsets in any way ( That would also NOT be done in a Real aircraft)
We just "bypass" the LED´s

Do the follow..... ( 3 Ways)

1. If your Aircraft/AddOn have a internal Light Test Function then use THIS Offset.... This will also light up all LED ( Change there Offset Staus Temporary) but it turn back to the "real" Status after release the button.
NOTE: This is not supported in much Aircrafts.... Whatever proffesional Sims like PMDG will NOT support that.

2. Build a Hardware Solution
Here your LED are powered by 2 Systems... The Sim (That show Status of Function) AND a second Line directly 5v that is powered if your Button is used. So your Button Light teh LED whatever it is normaly OFF at the moment.
For THIS you need a special wire Logic with Diodes.... So Both Systems are indipendend and not "kill" each other.

2. Build a Logic in Mobiflight.
At First: Mobiflight is at the moment a bit uncomfortable here. As i said in last post we plan for a new feature that make those things (preconditioning) moch more easy. A.t.m its needed to build 3 Configs for each LED to Build a realistic system. Additional you need a Global Config to Define the Lighttest Switch.
(You can also include the Master Battery switch to let all LED get OFF if no Power is in Aircraft.... But this is much more difficult..... So i explane just the Lighttest.

Basic Logic ( With current Mobiflight Version)
Config A Read the Lighttest Switch ( A Global Status that is used for all LED Configs in your Aircraft)
Config 1 Read the Status of your Function ( For example The parking Brake Offset)
Config 2 Set your Parking Brake LED to ON ( You use here a Fake Offset and say in Transform simply "1" to make it always ON)
Config 3 Set your Parking Brake LED to OFF (Also a Fake Offset but thistime you say Transform "0" to make it OFF all time )

Now you use Preconditions in that Configs....
Config 2 should work if Config 1 (Status of Parkingbrake) = ON (Value more then 0 : >0) OR If Config A (Lighttest) = 1
So it will light Always when lighttest is in progress and it also light if Status is ON (while no lighttest is in progress)
Config 3 should work if Config 1 (Status Brake) = OFF (Value 0 ) AND if Config A (Lighttest) = 0
So it will deactivate the LED if Function is OFF at the moment.... But it NOT act if Lighttest is in progress.

I Hope You understand !

With battery Off Status included you will need more Preconditions and a special sequence of OR/AND Settings to make this work.Think about if you realy need this a.t.m.
If the new Feature come (hopefully this year) we will do this in ONE Config Finaly.... THEN we simply include all Preconditions in ONE Command in Transfromfield.
Then it looks like if([BAT]=0,0,if([LTEST]=1,1,$)) .... Then This simple Codeline is used in ALL Led Configs same way.
(Not try this Code.... This NOT work with current version ;) )
Good Luck !
2019-04-28 01:47
Posts: 8
Hey pizman82, I followed your instructions and it seems to work except that the led flashes when the Pitot Switch is turned on. Let me show you the configs.
Config1: Master Battery: 0x281C Int/2, no Compare, no Display, Precondition: pitotON= 1 (AND)

Config2: Testlight pushbutton, 0x6004 Int/2, no Compare, Display to pin 2, no Precondition

Config3: PitotSwitch, 0x029C Int/2, no Compare, no Display, Precondition is:batt=1 (AND)

Config4: pitotON, 0x66C0 Int/2 with Transform 1, Compare: if value = 0, set to 1, else set to 1, Display to pin 2, Precondition: batt=1 (AND) PitotSwitch=1 (AND) Testlight=0 (AND)

Config5: pitotOFF, 0x66C0 Int/2 with Transform 0, Compare: if value = 1, set to 0, else set to 0, Display to pin 2, Precondition: batt = 0 (AND) PitotSwitch=0 (AND) Testlight=0 (AND)

With all switches off, all FSUIPC and Output numbers are 0 except pitotON which is 1 for the Output.
Turning on Battery causes both its numbers to go to 1.
Pressing the Testlight switch causes its numbers to go to 1 and the led lights up until the switch is released.(Light goes out and numbers return to 0.
Turning on the PitotSwitch causes its numbers to go to 1 and the led lights up(and flashes) until switched off with its numbers going back to 0.
Turning the Battery switch off anytime causes the led to go out if on.
Except for the flashing, it works perfectly.

I though I followed your instructions, but maybe I missed something.
I tried unchecking the Compares in the pitotON & pitotOFF but it didn't change anything. I also tried using the $ and no $ in the Transform since I'm not really sure what it's for, but no change.
Also, If the PitotSwitch is on, and the led is flashing, if the testlight pushbutton is pushed, the flashing stops and the led stays solid until released.
I thought it might be the Input pushbutton, pbtest, On Press: 0x6004 Int/1, Set Value 1. On Release: 0x6004 Int/1, Set Value 0. The precondition is: batt = 1 (AND), but when I removed the On Release portion and turned on the PitotSwitch, it still flashed. Of course when I pushed the Testlight pushbutton it came on and stayed on. So the release going to 0 doesn't appear to be the issue.
So any help would be appreciated.
Thanks in advance,
[Last edited by ifrpilot89, 2019-05-04 05:07]
2019-05-03 02:38
From: ETSI, Germany
Posts: 6010

There are some "misstakes" . You try "another" way like i recommend.... Not basicly wrong but also not 100% functional ( flashing LED e.g.) .
I try to figure out.


Config1: Master Battery: 0x281C Int/2, no Compare, no Display, Precondition: pitotON= 1 (AND)

Config2: Testlight pushbutton, 0x6004 Int/2, no Compare, Display to pin 2, no Precondition

Config3: PitotSwitch, 0x029C Int/2, no Compare, no Display, Precondition is:batt=1 (AND)

Config4: pitotON, 0x66C0 Int/2 with Transform 1, Compare: if value = 0, set to 1, else set to 1, Display to pin 2, Precondition: batt=1 (AND) PitotSwitch=1 (AND) Testlight=0 (AND)

Config5: pitotOFF, 0x66C0 Int/2 with Transform 0, Compare: if value = 1, set to 0, else set to 0, Display to pin 2, Precondition: batt = 0 (AND) PitotSwitch=0 (AND) Testlight=0 (AND)

1. What is Offset 6004 ???
In my Lists this is a Offset to set the GPS Data of internal FSX GPS Navigation.
I not understand the usage here for your Lighttest Button. If THIS is your AddOn Lighttest Offset ( i don´t think so) then its ok. If NOT then use a Free Custom Offset (66C0 +) for the Lighttest Button !

2. Do i understand correct, that the INPUT Button for Lighttest Switch is not included in the Configs above..... So these are just the Outputs ???

3. Why it flash.... Simply rebuild the Situation what happen if you press PITO to ON.... Then Config 4 Work and Light the LED .... But also Config 2 Work and try to deactivate the LED cause this config controll SAME LED with the Lighttest Offset..... Its "0" at the moment so it try to deactivate the LED

Always remember a basic Logic.....
- A LED "should" be controlled ALWAYS by a Config. So if you disable a Config via Precondition then a other Config must be controlling the LED from now. Uncontrolled LED simplay stay in last Status aslong a new config is get activated ( or the old one)
- A LED should be NEVER controlled by 2 Configs same Time if the Configs show different status. So its no Problem if both Configs are ON or both are OFF. But it will "flash" if one is OFF and the other is ON.

4. Issues i see at the moment:

a ) Config 1 and 3 are just "ReadOuts" that give us a Information we use in the Real LED Configs. ( 1 Read Master Bat.. 3 Read Pito Heat)
So there is no logic of a Precondition here. ( Not a issue cause Mobiflight read the Configs whatever they are deactivated ) Simply remove these 2 Preconditions here.

b ) Config 2 should be ALSO a ReadOut that we use for Precondition in the "Real" Outputs . Here you should NOT use Pin2 as a Output. This Config should NOT controll the LED.

c) Double Transform/Compare in Config 4 and 5
If you use Transform 1 in C4 then you not need the Compare.... It is still "1" and can never be 0 again.... The Compare is unless. Or Inverted... If you use the Compare you can leave the Transform. This is no issue but also not needed.
Also you use Costom Offset 66C0 Here.... Basicly here a "Fake" Offset is used. 66C0 is not wrong (Whatever i would ot use Size 2 Byte here) . But i hope you understand, that you not need Individual Offsets here for every LED. If you Build this System for 10 LED´s e.g. then each 2 Configs ( for each LED) will also use 66C0 in that case. This Offset is just needed cause Mobiflight say it MUST exist a Offset for a Output config..... In Real we not need it here cause we transform it "always" to 1 or 0. So finaly not make misstake and use different Offsets here in future configs !

d) Config 4 and 5 must be reworked with this new situation. Here i already said the Problem is the "poor" logic of the current Precondition System. The AND/OR Logic worke fine for 2 Conditions..... But it is verry tricky if we need 3 or more.
For Example : "A" AND "B" work.... "A" OR "B" work too. If you like now That a LED should light aslong A is ON and one of B or C is on then we got the First Problem.
If you use "A" AND "B" OR "C" this sound logical.... But it will not work 100% cause now your LED will also Light if Only "C" is ON (Whatever we say "A" MUST be ON)
If you use it Inverted .... "B" OR "C" AND "A" ..... This will work 100% .
Thats why i´m said its "difficult" if you include also Battery Status and Lighttest same Time.

Syntax for C4 : Transform 1 ( For always ON)
Precondition: Lighttest=1 OR Pito =1 AND Battery=1

Syntax C5 . Transform 0 (Always Off)
Precondition: Lighttest = 0 AND Pito = 0 OR Battery = 0

The Sequence of AND /OR is the Key.... Not change it !!!

Hope thats Correct. Please test it all Posible Ways and report.
[Last edited by pizman82, 2019-05-04 09:38]
Good Luck !
2019-05-04 09:31
Posts: 8
Thanks pizman82, It all worked as wanted. No more flashing!!!
I've included the code below incase anyone else needs it.
Thanks again,


MasterBattery, 0x281C, No Compare, No Display, No Precondition

Testlight, 0x66C1, No Compare, No Display, No Precondition

PitotSwitch, 0x029C, No Compare, No Display, No Precondition

pitotON, 0x66C0 Transform=1, No Compare, Display=Pin 22, Preconditiion: Testlight=1 (OR) PitotSwitch=1 (AND) MasterBattery=1 (AND)

pitotOFF, 0x66C0 Transform=0, No Compare, Display=Pin 22, Preconditiion: Testlight=0 (AND) PitotSwitch=0 (OR) MasterBattery=0 (AND)


PBTest, Button, Button

Precondition: MasterBattery=1 (AND) PitotSwitch=0 (AND)

Input: On Press, 0x66C1 Int/1, Set Value=1
On Release, 0x66C1 Int/1, Set Value=0
[Last edited by ifrpilot89, 2019-05-07 19:40]
2019-05-06 17:57