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!
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.
Hallo !
Is there a possibility to get a connected led flashing ? I'm building an annunciator and want some of the leds flashing. (Outer-Middle-Inner marker).
Win 10, Mobiflight 9.1, Msfs 2020
Not sure if the software could provide solution, but I would use external chip NE555 to blink the LED when powered. Power directly from the MEGA output pin.
This is a long time Request on our wish List .....
At the moment there is NO internal "timer" or "blink sequencer" in Mobiflight !
Current solutions:
1. Like Waylander said.... Use a Hardware Solution
E.g a Electrical IC or a own Controller that simply say " aslong Input Pin is HIGH ( MF Led Output) Then let the LED blink !
2. Via a MF Calculation.... For exampe a 1 Second Interval can be done pretty easy by read the Sim internal Clock..... Here we say e.g. " If Current time in seconds is equal (0,2,4,6,8 and so on) THEN light the LED..... If time is non Equal ( 1,3,5,7,9 and so on) then not light the LED.
So a 1 Second interval can be done with a little if-else Condition !
Slower intervals are also possible..... But faster ( more then 1 second on-off) is currently not possible !
3. Via own Code....
E.g. in FSUIPC or the WASm Code Syntax you can simply define yourself that a Value should be 1/0 in case of a specific time sequence
************
Or wait.... Hopefully this long time request gets done by Sebastian or a other Programmer and we see this within the next releases as a feature in MF itself !
If I want to test the suggestion "2". Where in Mobiflight do I put the neccesary code ?
Cheers, Peter
For the WASM Code..... Here i have no knowledge about the syntax ( this would be done in the FS2020 interface)
Also for the FSUIPC Part ( Coding in LUA language) i´m not advanced.
Ask on our Discord for more informations to the Programmer guys !
About MF
This is done with a easy IF Condition.
You would read with a Output Config the "Current time in Seconds" or the "ellapsed Time in Seconds since systemstart" Offsets ( FSUIPC) or the euqivalent in FS2020.
So you have a Value that counts 0--60 or 0-xxxxxxx by 1 Second steps.
Lets say your read this information in a Config called "TIMER"
For a 1 Second Bling sequence you would simply use this raw Value within yoru Config ( from the LED) as a PLACEHOLDER!
So in this example you define a Placeholder with Symbol "a" and select the Config "TIMER" as indication.
In Formula you say for example if($=1,a%2,0)
So IF LED should be ON ( $=1 means the cureent function is active) THEN Show "a%2" .... Means the Current Time MODULO-2 .... ELSE Show 0 ( When LED must be OFF)
a%2 means..... Divide the current time through 2 and show the remaining Value..... If time is 2,4,6,8,,10,12 and so on then the divide result in "0" ( LED OFF) If Time is 1,3,5,7,9, and so on the divide show "1" and the LED is ON
In easy words.... A Blinking in a 1secON, 1sec OFF, 1 sec ON sequence..... Just by check if Seconds are Even or Odd!
Thank you for a detailed explanation. But... maybe I have missed some essential or I'm just common stupid but still I have not the faintest idea where in Mobiflight to put theese calculations/code. I have to refer to the seconds var ( 023A ) and from there do the calculations so in which Mobiflight window am I doing that. In "Sim Variable" I can only choose one. In this case Outer marker ( Fsuipc 0880 ) and I can only add one device per Arduino output pin.
The last suggestion, "Wait", perhaps is the simpliest alternative :-)
Cheers, Peter
the "placeholder" System and the "Logic Syntax" is done in the first Tab of all Output Configs ( Where you select e.g. if you like a SimVariable (FS2020) or a FSUIPC Offset or so .
Placeholder are selected in the lower Area called "Config Refferences" ..... there you can choose for a "other" Config to use its value within the current config !
NOTE: If you create just one Config this field is not vissible..... Cause there is no other config at the moment.....
If you create a second Output Config then this field include one line ( with the first one)
So this Area grown bigger with the number of Configs you create..... After 7 configs it remains ( 6 Placeholders Max in UI at the moment)
To enter the "Formula" this is done in the Transform Field ( or also in the Compare fields)
About Syntax:
Basically the DOLLAR Symbol "$" represent always the value of the Config itself you use it.
For example a Config read the Status of the Autopilot ..... It is 1 or 0 ..... So if you say for example if($=1,999,555) means..... IF Autopilot is "1" then export 999... ELSE ( So if Autopilot is NOT 1 --- Means its 0) then export 555 !
With the Placehodlers you can implement other values from other configs in this logic by give them a symbol....
Lets say you create the Timer Config..... That read seconds.... And you say there in transform "$%2" ..... then this config result in a 1 Second interval of 1-0-1-0-1-0 and so on.
If you NOW use this config value as a placeholder in your Autopilot Config (symbol "a") and you say in transform if($=1,a,0) .... Then we simply say..... ASLONG Autpilot itself ($) is "1" (ON) THEN show value of "a" ( Timer OFfset that is 1 or 0 in a 1 sec sequence) ... ELSE ( If Autopilot is not 1 -- means Off) then show "0" and disable LED at all time.
I hope you understand.
With this logic and easy code we can build nearly everthing .... Idicated to one or much more other values!
Hart example:
We can for example show SPD on a 7Seg Display.... And we say.... IF Master Switch is OFF then show Spaces, If Master is On but Gear is Down show 9999 , If Aircraft is below 5000ft then show 1234 and if Flaps are set show 8888..... Else (Inflight, No flaps, No Gear , Above 5000Ft and with Master switch ON) show Value of Speed $
( Not logical.... I just want to show what is possible !)
Understands parts of what you suggest. In "Config references " I only got the other assigned devices, Landing Light, Taxi Light aso. Is it ment to have a dummy, an "unconnected" assignment on my Mobiflight Mega with the second variable here ?
I also found it interesting to test the suggestions in the next support question about dimming the led's. I have all connected to Arduino Mega output 2-13 which are PWM:s. If I write in the "Transform" textbox ; if(€=1,128,0) ( Sorry, have no dollar sign on my swedish mac keyboard, so I have exchanged the valuta :-) But on my PC where I fly, I have DOLLARS ! ) means "compile" error. The exclamation mark only showing up with Msfs running and Mobi connected. €*128 or €*16, no visible impact.
I might add that I'm a beginner in this coding
Though I've managed to have the "low fuel" varning working when lower when fuel lower than 15% !!!
Cheers
At first... As i know every Keyboard on the world have the "$" Symbol..... In germany its obove the "4".... May its on another position in the swedish one..... But pretty sure it exist !
About Configs....
You mix up "Devices" and "Configs".
A Config in MF ( to be clear "OUTPUT Configs") NOT need to be assigned to a device.
You can for sure read a variable, Offset or something else like a Mobiflight Variable WITHOUT combine it ot a exiting device like a LED, 7Seg or so.
We use this logic to make "indicators" we use for predondition or Placeholder logics.... Or we also use this for difficult formulas we can not handle in one line..... So e.g. we do 5 math operations in Config 1..... and use this value as a variable in Cofig 2 to do another 5 mathematic calculations with it.
So.... Config NOT means Device !!!!!
***********
About the other stuff.....
if($=1,128,0) means.... If Value of Config is "1" then export 128 ( means in PWM nearly 50% brightness) ..... ELSE export 0 ( Means if Offset itself is NOT 1 (OFF) then send 0 what represent a OFF LED !
So you say simply.... OFF when OFF and 50% Bright when ON
And YES..... The Multiplication work same way..... $*128 result the same.....
If $ ( Function) is 1 then 1*128=128 ...... If Function is OFF then 0*128=0 ..... So Also a result of 128 or 0 in case of the Variable/Offset Value !
If you need help with Syntax ask me..... there are lots of more things like ELSEIF and more deeper Conditions..... and also AND "&&" and OR "||" is posible.
The dimming of led's works perfect, but only when connected to Msfs/Fsuipc. Not in Testmode.
Still don't get it how to get connected to the second variable in the "Config References" window.
I can only choose the configs I already have, six assigned visible and a few more assigned through the dropdown lists. I cannot write /code a new config or put the "023A" somewhere. What am I missing ?
Cheers, Peter
Btw.The dollar sign is not visible on my keyboard but I reach it by pressing alt-4. The more common shift-4 give me euros !
Getting closer ?! Created in Main output window a Timer ( uses # )showing seconds in Fltsim -and Output value. The qustion now is how the syntax will be.
Tested in the Transform textbox; if(#=2,4,6,8,aso) 64,0 - didn't work. Tested the same but with period, didn't work. Tested with If in capital letters and a dozen other code lines. Is it possible this way at all ?
The Dimming was no Part of MF when we implement the "Test" Mode..... This was many years before !
Also it is a little difficult in case you would need another UI Field.... Cause "how" should MF know what value you like to test ?
So simply accept.... the Test is simply 1/0 and not include PWM
A Easy way to TEST a LED Bright Setting is build a New Config.... You select the needed LED ( With a PWM Pin for sure) as Device in a Output Config.
You select a Offset or Variable.... No mater what.... And in transform you write e.g. 128
Then you press RUN.
Means now this LED show the Bright of Value 128
If you like to test 200 simply write in transfrom 200 instead of 128
In this laboratory State we not need Dollar or formulas.... We just define that the Value is fixed e.g. 200 now.
After you knwo the perfect Value load your Project MCC again and use the explored Value in your real Cofnigs !
NOTE:
You should also rethink the whole system.....
Have your LED always be in same Bright ?? Cause a Config that say $*128 or if($=1,128,0) not include a indication..... It "hardcode" the brightness to XX !
So is it correct your LED should ALWAYS light in this state ?
If YES.... Why do you use this difficult Software way ? Simply use a 1/0 Pin withpout PWM and define the Bright of the LED by using the right resistor.... As greater the resistor as much more dimmed the LED.
In easy words..... PWM only make sense if we need multiple Bright States.... If the is only one state we do this fully out of MF via electrical setups!
*************************
About last question: I not understand !
Still don't get it how to get connected to the second variable in the "Config References" window.
I can only choose the configs I already have, six assigned visible and a few more assigned through the dropdown lists. I cannot write /code a new config or put the "023A" somewhere. What am I missing ?
The 6 Lines show posibilitiy to use up to 6 other Config Values within your Calculation in THIS Config.... Means with the "$" of the Config itself you have up to 7 Values together you can use ( Technical more but not via GUI..... here a little hack is needed)
And YES.... For sure only other existing Configs can be used.... You say something like " Iwill use the value of Config xyz as symbol "x" . So Config xyz for sure must exist !
So if you need the Value of 023A within the Config.... Build "another" Config that Read this Offset.... Call it for example "SECONDS".
If you NOW need this information in your Calculation e.g. in the "Autopilot LED Config" then yue enable there one Placeholder.... Chosse from Dropdown the Config "SECONDS" and define a symbol like "a" ..... And NOW you can use in a formula the "a" same way as it would show the value of 023A .
If you need another Value..... E.g. the current altitude.... Also read this with a Config.... Call it e.g. ALT ..... And now you enable the second Placeholder and define Config ALT is now "b"
So you could write for example $+a+b ..... Means it takes the current Value of its own ($) ADD "a" ( The Value of Time Offset) and also ADD "b" (The current Value of Altitude)
Again senseless..... I just want to show the basic idea !
No problem with PWM mode led's. Just för clarifying that they work as intended but only in msfs connected mode. Indeed I must not have all my led's be of exact same brighness. Did it just for fun and as you say I can use resistors ( as everyone else ). On the Arduino Mega there is only output 2-13 that are PWM so if you have need for more led's you have to use resistors anyway
.
The blinking Led's are still unsolved though. I have no success with the "or" operator, ||. If I write if(#=2,64,0 ) I can have the led light up on "second one" in the Timer with the brighness of 64. So the question is how do I succeed with if(#=1or3or5or7or9,64,0) if(#=1||3||5||7||9,64,0 ) doesen't work. Is there another "or"-operator I can use ? # is my Timer function created in the main window below all the other functions.
The "not understand" part is the "Config Referense" part of ConfigWizard/Sim Variable window. In that part I see no use of my other functions as LandingLight, Outernmarker aso for impact in the blinking process. So that is what I not understand. I think I must refer to a Timer function and that must refer to the seconds variable in Fsuipc, 023A. That variable doesent't exist in Landing light, Inner marker or...
Thank you for your patience. I dont think I can contribute with knowledge but with stubbornness :-)
Cherrs, Peter
On the Arduino Mega there is only output 2-13 that are PWM so if you have need for more led's you have to use resistors anyway
No... 2-13 and also 44-46 .... Just 3 More. I just want to clearify.
I know some People use this PWM System´for there Backlight ..... E.g. they have 10 White LED´s and wire them as 10 LED´s in Mobiflight with the PWM System.
This works.... But i will say we plan our system for more advanced stuff.... Like the Fuel Pump Announciator in a B737 that can be dimmed or not indicated to the Fuel Pressure.
In easy words.... A Global System like Backlight is mostly done much more easy by resistors, or external with a PWM Controller. So 1000 LED´s for a Full backlight of a B737 are pretty sure not done by 100 Megas and Configs in Mobiflight..... Thats done by a external Power suply and a Controller.
The blinking Led's are still unsolved though. I have no success with the "or" operator, ||. If I write if(#=2,64,0 ) I can have the led light up on "second one" in the Timer with the brighness of 64. So the question is how do I succeed with if(#=1or3or5or7or9,64,0) if(#=1||3||5||7||9,64,0 ) doesen't work.
At first... The LED will light in the example not in "Second one" ... It light in Second 2 cause you say "IF Time Value is 2 THEN do".
You have wrong Syntax .... And finally the wrong Logic at all!
About Syntax.... If you use the OR then there must be a refference i n every OR Part again.....
So lets say If time is 3 or 5 looks like if(#=3||#=5,64,0)
You not say Time is 3 or 5 or 7 or 9 .... You must say Time is 3 or Time is 5 or Time is 7 or time is 9 !
About Logic..... THIS workes.... But its not logical and much more complex..... Would you like to write 30 "OR" in case of the 30 values 1-3-5-9- until 59 ??
Here the Key is the "Modulo" Function i explane above..... With Modulo (%) we say.... Please divide a Value through another value and show me the remaining number that can not devided at the end.....
For example 9%4 = 1 ..... We divide 9 through 4 .... This can be done with 8 ( to times) but then we remain "1" that no longer can be divide ( no float logic here).
In our example we simply use your time and Modulo with 2 ......
Result ... A Second Value of 2,4,6,8,10 and so on divide through 2 result always in a "0" Zero ..... A Time of 1,3,5,7,9 through 2 result always in a remaining 1 .
Finally its no mater where you do this.... You can e.g. do in the "Seconds" Config itself already a transform $%2 ..... So this Config output already only 1,0 in a sequence.
Much more comfortable in case if you use this in multiple other configs.
OR
You can use the "raw" time within the other config.....
So you must do the "Time Modulo2" there.... like #%2 in your example.
NOTE: With a IO Pin this workes fine..... Cause the 1/0 Blinks nice. For your Dimmed logic you need to also rework that value... In your case you must change the 1/0 into 64/0
The "not understand" part is the "Config Referense" part of ConfigWizard/Sim Variable window. In that part I see no use of my other functions as LandingLight, Outernmarker aso for impact in the blinking process. So that is what I not understand. I think I must refer to a Timer function and that must refer to the seconds variable in Fsuipc, 023A. That variable doesent't exist in Landing light, Inner marker or...
Yeah....
The "Placeholder/Config Refferences" are not Global..... they are Local within the Config you use them.
You can use one Config ( In your case the "Timer" config where you read the 023A ) in lots of other Configs ! So you NOT need to create it multiple times.
BUT
For sure you need to define this "Placeholder" in each config you need it by hand.
In your example...
You create ONE Config that reads 023A .... Call it e.g. SECONDS ..... And to make it more easy already use here in transform $%2 to have 1/0/1/0 Sequence Output.
Then you open the "Landing Light" Config.... Enable Config Refference1 .... Choose from Dropdown the Config "SECCONDS" and set a Symbol ... e.g. #
Say in transform if($=1,#,0) for a Blinking in a NON PWM LED ..... or if($=1,#*64,0) for the 64 Dimm Blinking state.
And NOW do the same in the "Outermarker" Config.... Also create a Placeholder there.... AGAIN use "Seconds" as Refference and choose the same symbol #
Then you can copy paste the if formula..... Cause its the same here, too.
And may you already understand..... If the Blinking must be PWM 64 in all Configs....: You could include this in the Seconds Config already and save work in the others.
If the Timer say..... ($%2)*64 then it gives already 0--64--0--64--0--64 now. So you not need to recalc this in the others.
***************************
Sorry for long text.... Hope now most questions are awnserd.
Just keep testing. It´s not so difficult like it seems..... And ask if you need more help !