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
Neumann63
Posts: 5
Hi all,

sorry, absolut newbie...

I'm using MSFS2020 with "Standard"-Mobiflight on Win10.

I would like to control the Magneto key switch on the screen with an analog value
Therefore I have potetiometer connected to an Arduino micro pro. For special positions I have values like

Off =441 Right =530 Left =628 Both = 719 Start = 802

I think MobiFlight-Modules are o.k. (I'm getting "good" values when I monitor the signals on PUTTY)

The problem (for me) is the InputConfigWizard: When I'm have PresetCode OnChange like (>K:MAGNETO_OFF) the key is moving on change to Off.

Now I wanted to have the If clause. Something like :
iconCode:
if(@<500,(>K:MAGNETO_OFF),if(@>=500 && @<580,(>K:MAGNETO_RIGHT),if(@>=580 && @<680,(>K:MAGNETO_LEFT),if(@>=680 && @<760,(>K:MAGNETO_BOTH),(>K:MAGNETO_START)))))


or

iconCode:
if(          @<500),(>K:MAGNETO_OFF),)
if(@>=500 && @<580),(>K:MAGNETO_RIGHT),)
if(@>=580 && @<680),(>K:MAGNETO_LEFT),)
if(@>=680 && @<760),(>K:MAGNETO_BOTH),)
if(@>=760         ),(>K:MAGNETO_START),)


or a simple test like

iconCode:
if(400>500,(>K:MAGNETO_LEFT),(>K:MAGNETO_RIGHT))


does not work !!

(>K:MAGNETO_OFF),(>K:MAGNETO_RIGHT),(>K:MAGNETO_LEFT),(>K:MAGNETO_BOTH) and (>K:MAGNETO_START) work !!


What is my problem ??

Thanks for help in advance
2022-10-23 11:58
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

Basically i will say.... This is a nice example what happen if we use the wrong device for a project.
Whatever in a real aircraft, in a simulated Aircraft and sure also not in 99 of Homebuild Cockpits there is a Poti used here. All logics are build for a Rotary Switch with detents.

To awnser question.... YES its possible, but it take some additional work and some more advanced inputs to "emulate" a Rotary Switch out of a Poti. Cause the Sim still expect Single Commands here and not accept a Linear Value as you try to do.

Solution:
As you already say... We have multiple ways.
With the single Commands like "(>K:MAGNETO_LEFT)" we can NOT do this in one config ! Cause one Input Config only can Handle just ONE Command.

For the "On change" Logic of a standard Poti Input we can for sure send different Values like we do with Flaps or with Throtlle.... BUT all of the values are send to always the same Command like " Flaps Lever Position SET" .....
You like to say In Pos 1 write command (>K:MAGNETO_LEFT) in pos 2 write command (>K:MAGNETO_RIGHT) and so on.
Thats not doable in one config!

That loogic would require a Config for each Area/Command .... So e.g. 5 Configs who all read the same Poti.... Each got a own transform to get sure its 1 if Poti is e.g. 530 (or between 500 and 550 ) and its 0 if its out of that target area.
Then a "change" now only occure if we move Poti into this area .
BUT it also occure if we move it out (swap back from 1 to 0 is also a change!)
Means We send our Command 2 times here..... What is no problem at the end cause reach the next position will also send the then needed command once again.
Maybe we need also Preconditions now.

*****
The "best way" to do this ( except to use a correct Multiswitch instead a Poti :-) ) is.....
Using a SET Command ! MAGNETO1_SET
Find out what it expect.... i think its 0,1,2,3,4,
Now we can use ONE Config.
We simply build a Formula that set the Poti Value from 0-1023 into 0,1,2,3,4
Maybe @/256 is still enough if its linear ..... Else you need something like your IF Idea.... if(@<500,0,if(@>500&&@<550,1,if( ...... And so on )
NOW we have a value that is 0-4 and it change on correct spots.
And we finally send the value (0-4) to the SET Event of Magneto.


A last idea if this not work fine is using the new Input Config Item Feature.....
But i would try it at first that way above!
Good Luck !
2022-10-24 15:00
Avatar
Neumann63
Posts: 5
Thanks for the help. OK, I know this is a little bit weird.

I didn't get exactly how I should do this...

Is it possible to make 5 inputs (MagnetoOff, MagnetoRight, MagnetoLeft,MagnetoBoth and MagnetoStart) at MobiFlight Connector/Input and every
input has something like "if(@>500 && @<=580,1,0)" as preset code for MagnetoRight ??
I'm not sure about the syntax, but then I only have ONE preset (in this case MAGNET_RIGHT) .

I tried MAGNETO, but it didn't worked. And MAGNETO_SET does not exist :mad:
As I said, I'm new on this terrain :scared:
2022-10-24 20:34
Avatar
Neumann63
Posts: 5
I tried to make it easy for the beginning:
In the main window under Inputs I have two items (MagnetosOff+MagnetosRight). Both have the device "Magnetos" as input.
The first one has the Preset MAGNETO_OFF with the PresetCode "if(@<500),(>K:MAGNETO_OFF),0)" the other one (MAGNETO_RIGHT) should have the preset code "if(@>=500),(>K:MAGNETO_RIGHT),0)" .
Why can't I execute the THEN command ? (I know "0" as "else" should be something different like NULL or NOTHING)

I didn't get the correct syntax.

Am I totaly wrong ?

By the way: The reason for choosing the potentiorameter for input was: it only uses one pin instead of 5 (or in best case 3)!!
2022-10-24 22:19
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
iconNeumann63:


I didn't get the correct syntax.
Am I totaly wrong ?



YES your totaly wrong badly in this case.....

There are 2 different type of syntax.... On is the internal MF logics.... Like code we use in Transform .... Its based on the NCALC Syntax....
The other is the RPN Code we have to use when we talk to the Sim (FS2020) itself.

So in your example....
"if(@>=500),(>K:MAGNETO_RIGHT),0)" will not work!

the if(@>=500 part is MF syntax .... We can say e.g. if(@>=500,1,0) means if its TRUE ( Value is greater or euqual 500 THEN set to 1 , else set to 0)
The Syntax we need to talk to Sim is finally..... (>K:MAGNETO_RIGHT)

So we at first say within Mobiflight "Define a situation that is 1 or 0 whatever our required condition is true" ...
And second we say in MF " If Value Change ( 1-->0 or 0-->1) then do the follow..... E.g. On Change mean always if it change.... On Press means always if its 1 On release means always if its 0.
And HERE we define e.g. that MF should send the command (>K:MAGNETO_RIGHT)

NOTE:
You meanwhile mixup the "Config Item Technic i recommend in last line, and the "SET Value" Idea i talked above.

IN easy words.... Whatever myself or a other user did this till now.... Cause nobody try to do this with a Poti.
I still say its possible. But i can not give you a perfect guide cause i need to figure out myself!

Why not join our DISCORD. There we can talk and build this together !

**********
And...

iconNeumann63:


By the way: The reason for choosing the potentiorameter for input was: it only uses one pin instead of 5 (or in best case 3)!!



Sorry about that.... But ( for me) this is not a valid argument.... I fully understand people want to save money or to save Pins.... But why not before think about the usage.
You could have a finished Panel already by using a rotary Switch. Is it really profitable to you to write 2 Requests here and to learn a lot of advanced Coding stuff just to save in whorstg case 10$ for a additional Arduino ?
I like to support.... and i will.... But i never understand why this "save Pins" is so deep in the brains. I choose for the most easy way.... not the cheapest !
Good Luck !
2022-10-25 00:08
Avatar
Neumann63
Posts: 5
OK, I understand, that my thinking is a little bit weired ...

But there is in MSFS2020 a function called "Starter Knob (Potentiometer)" which seems to be really special MS-stuff.
(Vendor: Asobo Aircraft: Cessna 172 System Engine)
But this function really works for me ! Just changing the Preset code to my potentiometer values and it runs ...
iconCode:
@ 500 < if{  0 g1 }  
@ 580 < if{  1 g1 } 
@ 680 < if{  2 g1 } 
@ 760 < if{  3 } els{ 4 } 
:1  (>K:MAGNETO1_SET) 
(A:GENERAL ENG STARTER:1, Bool) if{ 
1 (>K:SET_STARTER1_HELD) } } } } }


Thanks for the help anyway.
PS: I'm glad that someone else is so weired as me:D :D
2022-10-25 06:36
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
iconNeumann63:


PS: I'm glad that someone else is so weired as me:D :D



Yeah. Thats our Jaime Leon !

I´m sorry i not think about the 3rd alternate :-)
As we see here.... We can also do it fully within the RPN Code.

Its hard to me in case i'm also in a learning process with this syntax. I do all in MF for years via our own Logics ( long time before RPN come on the table).... So my brain always threat me to use the old know logics instead of think about if we could do it in the RPN more directly.

Summary for the future.... You see Jaime here is the better guy to talk.
Please next time joind Discord and contact him directly.
:P Or wait 2-4 Years until i learn this RPN stuff myself :P
Good Luck !
2022-10-25 10:06
icon