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! 

icon
Avatar
herbiem
Posts: 57
Is it possible to use one rotary encoder for 2 function by using a switch to change the function
Am building my C172 radio panel for FSX and am up to the AP ( all the rest working fine) and would like to use a switch to change between ALT and VS and the encoder to change the values of either VS or ALT
Thanks
Ian
2018-09-03 07:01
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3862
Supporter
Hi Ian.

Yes this is possible..... Whatever in a bit advanced way.
We have a guide that include that https://www.mobiflight.com/forum/topic/652.html . EDIT: I See the Pictures are broke there. So it is not verry usefull.

NOTE: The technic will work BUT Please think about if your system is usefull. Do this with the Khz/Mhz swap of Radios all is ok.... Thats done in Real aircrafts, too.
But savety relevant Things like VS-ALT are never combine in ONE Display or via ONE Encoder.... If you will for example reduce ALT to 3000 but you make a misstake and set VS to -3000 (without realise that youreself) then you will crash and kill your pasengers !
So.... Those functions will be never combined in real world !

*****

Basic Idea.
You need a Single Config for every function in Mobiflight.
If you like to controll ALT and VS BOTH need a single config ( One use the Event/Offset of ALT ... the other use the Event/Offset of VS )
NOW you tricky use for BOTH Configs the same Encoder as device !

Problem: Now the encoder will controll both functions same time ! So we need a precondition each to tell the encoder what function he should controll at the moment.

Technic:
Mostly you use the Button on encoder for that.
Create a Input Device ... BUTTON for that with this Button of encoder.
Create a Input Config and use OFFSET 1 Byte Adress 66C0 (66C0 and the follow are free offsets ... get shure you not use it for other things)
In Value field you say : if($=1,0,1) ..... This will toggle the value on every use of your button... if 1 then 0 If 0 then 1 .

Finaly create a Output Config that readout the Offset you write in last step ( 66C0 1 Byte INT in our example) and call it for example "Toggleswitch"

Now use in the 2 Encoder Configs a Precondition.... For exmaple the ALT should only work if Outputconfig "Toggleswitch" is "0" ..... And the VS Config should only work if the same "Toggleswitch" config is "1" .

NOTE: This can be done more detailed, too. For example with a 12 Position switch that write the offset to 12 different States... So you can controll 12 things with one encoder.
Or you can make a Push button that switch through 5 different things ( First push control ALT next VS next HDG next SPD and so on)
I just explane the main logic.... With ather "Value logic" you can do lots of nice things here!
*****


I hope you understand this short guide..... If not just tell us where you get in trouble... we try to help !
Good Luck !
2018-09-03 16:22
Avatar
herbiem
Posts: 57
Thank you for your prompt reply
Yes I can see that it could be a problem having both on the same encoder ( don't want to kill anyone);)
Perhaps I need to take a different approach and use a double encoder
Ian
2018-09-04 01:14
Avatar
rodo2212
Posts: 18
iconpizman82:

Hi Ian.

Yes this is possible..... Whatever in a bit advanced way.
We have a guide that include that https://www.mobiflight.com/forum/topic/652.html . EDIT: I See the Pictures are broke there. So it is not verry usefull.

NOTE: The technic will work BUT Please think about if your system is usefull. Do this with the Khz/Mhz swap of Radios all is ok.... Thats done in Real aircrafts, too.
But savety relevant Things like VS-ALT are never combine in ONE Display or via ONE Encoder.... If you will for example reduce ALT to 3000 but you make a misstake and set VS to -3000 (without realise that youreself) then you will crash and kill your pasengers !
So.... Those functions will be never combined in real world !

*****

Basic Idea.
You need a Single Config for every function in Mobiflight.
If you like to controll ALT and VS BOTH need a single config ( One use the Event/Offset of ALT ... the other use the Event/Offset of VS )
NOW you tricky use for BOTH Configs the same Encoder as device !

Problem: Now the encoder will controll both functions same time ! So we need a precondition each to tell the encoder what function he should controll at the moment.

Technic:
Mostly you use the Button on encoder for that.
Create a Input Device ... BUTTON for that with this Button of encoder.
Create a Input Config and use OFFSET 1 Byte Adress 66C0 (66C0 and the follow are free offsets ... get shure you not use it for other things)
In Value field you say : if($=1,0,1) ..... This will toggle the value on every use of your button... if 1 then 0 If 0 then 1 .

Finaly create a Output Config that readout the Offset you write in last step ( 66C0 1 Byte INT in our example) and call it for example "Toggleswitch"

Now use in the 2 Encoder Configs a Precondition.... For exmaple the ALT should only work if Outputconfig "Toggleswitch" is "0" ..... And the VS Config should only work if the same "Toggleswitch" config is "1" .

NOTE: This can be done more detailed, too. For example with a 12 Position switch that write the offset to 12 different States... So you can controll 12 things with one encoder.
Or you can make a Push button that switch through 5 different things ( First push control ALT next VS next HDG next SPD and so on)
I just explane the main logic.... With ather "Value logic" you can do lots of nice things here!
*****


I hope you understand this short guide..... If not just tell us where you get in trouble... we try to help !



Hello.I have been thinking about this.
I have and lcd display 16x2 and one rotary enconder. By your help and seeing other topic, with one rotary i could change MHZ and HZ of the RADIO or NAV using its push button, And then with other button pass from standby to active.
For far so good. This just happen in one line off my lcd. How could I do the same thing for the second line from my lcd? B)
Regards and Happy new year.
Luis
2019-12-31 15:01
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1470
As pizman wrote and explained, It’s totally possible to have a switch write it’s position to an offset and then use the value of the offset as precondition to display values depending on its position.

It also works for the Inputs of course.

I did make a radio with one Encoder where when I pushed the Encoder and triggered the built in switch I was switching between manipulating MHz vs KHz respectively.

So please take a look at Preconditions and the possibilities that they give you.

I don’t see an issue with controlling many different values with one instrument. Look at the Saitek Multi Panel - they basically do the same thing there. You can build a panel with identical functionality easily with MobiFlight.
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - MSFS2020, FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2019-12-31 17:56
Avatar
JonLX
Posts: 6
I've been tinkering with Mobiflight for a little while.
With us all being in lockdown I have been busy on it and building 3D printed instruments etc and designing a few to.

But the dual encoders have got me stuck.
I just can;t get my head around the coding caclutations for using 2 encoders, 1 for Khz and 1 for Mhz in my Com, Nav, ADF.
I thought I had something when using 4 encoders for the Transponder to have each digit controlled by its own encoder. But It just didn't work.

Is there someone who would be able to explain these calculations to me?
I used Excel in my job and its full of Formulas but this is not making sense to me.

Many thanks in advance for any help.
2020-04-19 17:02
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3862
Supporter
@JonLX

I not understand your Request correclty.....

You say you like to use a DualEncoder ( MEans TWO Encoders) for the Radio Stuff and also FOUR Encoders for the XPDR
Then you not need difficult formula or logics to swap between functions within the Custom Offset Methode.
In your case every Encoder simply controll it own function !

Whatever AddOn Aircraft you use.... Simply use EventID or Offset Input that is controlling the specific funtion.

For Example in a FSX P3D Standard Aircraft the COM1 EventID´s are....
iconQuote:

COM RADIO WHOLE DEC 65636 (MHZ Encoder On LEFT)
COM RADIO WHOLE INC 65637 (MHZ Enoder on RIGHT )
COM RADIO FRACT DEC 65638 (KHZ Encoder on LEFT)
COM RADIO FRACT INC 65639 (KHZ Encoder on RIGHT )



NOTE: Maby your AddOn like PMDG use other Offsets .... Or it is needed to write the Offsets Itself !
Good Luck !
2020-04-20 00:06
Avatar
JonLX
Posts: 6
Hi Pizman82,

i had not even looked at Event ID's.
That looks like it will solve my problem. Thank you for pointing me in that direction.

I still have a lot to learn on Mobiflight.
I normally fly a Chipmunk (real one not sim) so this is a whole new world

JonLX
2020-04-20 11:47
Avatar
JonLX
Posts: 6
I should have rea bit more. I am Using XPlane 11. whihc Event ID does not work for.

I tried Event ID in FSX but can't get any response in the simulator.
2020-04-20 12:29
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3862
Supporter
Hi Again.

Thats why nobdoy loves Xplane expect some enthusiasts ;)

Your right. EventID are not supported there.
But there can exist commands ( Mostly by a AddOn ). With some lines of own Scripting in the XPUIPC Config file you may can fire those Commands by Mobiflight Inputs to the defined offsets. ( Google for that or read the Xplane Subforum Stuff)


Most profitable would be to use KEY Commands.
Check if you can set for Increase Decrease Com1 e.g. a Key in Xplane.
Then set in Mobilfight simply that key.... Means every turning of Encoder send that key and Xplane execute the command you need.


Another way is to make offset writes. If your AddOn use "Standard Offsets" that are supported via XPUIPC then you can use mathematical logicals.

For exmaple COM1 normaly is
"034E 2 COM1 frequency, 4 digits in BCD format. A frequency of
123.45 is represented by 0x2345. The leading 1 is assumed."

So that means in the First Byte 034E 1 Byte INT (BCD on) there should be in example frequency 123,45 here data "23" .....
In Second Byte 034F 1 Byte INT (BCD on) mut be then "45" ( the leading "1" is basicly not included in the raw data)

So you can write them pretty sure with a good logic..... Here simply "$+1" will NOT work !
For the Mhz you need a Logic that include overswap.
For example if range goes from 118-137 ( Without leading "1" raw value is 18-37 in first byte ) then we need a IF Function for increase like : if($<37,$+1,18)
This means.... Aslong Current Mhz are below (1)37 we add +1 but if value is exactly (1)37 we can not add one cause 138 not exist.... here we like to start up again with (1)18 so we set this.
Same logic inverted downwards..... for on left if($>18,$-1,37) means.... Aslong over 118 always reduce by 1. if 118 set 137 instead.
Good Luck !
2020-04-20 19:46
icon