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! 

Go to page 1Go to page 012Go to page 2Go to page 2
Avatar
tobypham
Posts: 13
I can not find dual rotary encoder in my place so I made precondition in Mobiflight Connector to deal with single rotary encoder
I chose KY-040 model because it has the pushbutton function



As you know the radio frequency has 02 part: MHz and KHz splitted by decimal point (for example: 126.07 in COM 1 Standby )
In this tutorial I will guide you how to tune both of them with single rotary encoder (KY-040)



Prepare
1- Mobiflight Connector software
2- Arduino Mega 2560
3- 7 segments LED module MAX7219
4- Rotary Encoder with push button KY-40

Connection
1- Connect LED to Arduino card:
VCC-5V (on top of pin #22)
GND-GND
DIN-#22
CS-#24
CLK-#26

2- Connect Rotary Encoder KY-40 to Arduino card:
CLK-#2 (for rotary)
DT-#3 (for rotary)
SW-#30 (for push button)
+-5V
GND-GND



3- Config with Mobiflight Connector software (MF)
+ Open MF software
+ Click Extras/Settings
+ Select MobiFlight Modules tab
+ Config LED
- Right click on Mega2560 and select Add Device/LED 7-Segment
- Set all number as following
- DIN-22
- CS-24
- CLK-26
- Num-1 (the number of LED, default is 1)
- Set the brightness, name as required



+ Config KY-40
- Right click on Mega2560 and select Add Device/Button
- Set Pin number: 30
- Set Name to "Push Button"
- Right click on Mega2560 and select Add Device/Encoder
- Left Pin: 2
- Right Pin: 3
- Set Name to "Rotary Encoder"


+ Click Upload and OK when you done (the popups show "Upload finished")

4- Config with Output and Input
+ Output:
- Create "COM 1 STB" (shows COM1 Standby Radio to LED)
More detail about how to connect LED with Arduino card in this topic
https://www.mobiflight.com/en/tutorials/seven-segment-display.html

- Create "COM 1 Precondition" (to make condition when push the Pushbutton)


Edit "COM 1 Precondition" with Custom Offset: 0x66C0 (number Zero, not character O)


+ Input
- Create "Push Button". When you push it, it will select MHz or KHz to tune freq
- Create "MHz" to tune freq (ex: 126)
- Create "KHz" to tune freq (ex: 07)


Edit "Push Button"
Chose right Module (ex: Mega2560) and Device (ex: Push Button)
On Press tab, set Custom Offset: 0x66C0 (number Zero, not character O) the same with COM 1 Precondition in Ouput tab
Set value: if($=0,1,0)


Edit "MHz"
Input tab:
Chose right Module (ex: Mega2560) and Device (ex: Push Button)
Use preset according to FSUIPC Offset or Input Event ID
On Left: Radio - COM1 Standby Freq MHz (-) Decrease
On Right: Radio - COM1 Standby Freq MHz (+) Decrease
Click Use button when done

Precondition tab:
Select type Config item and chose config COM 1 Preconditon with value = 1
Click Apply when done


Edit "KHz": following edit MHz with preset or input Event ID
On Left: Radio - COM1 Standby Freq KHz (-) Decrease
On Right: Radio - COM1 Standby Freq KHz (+) Decrease

and Precondition
Select type Config item and chose config COM 1 Preconditon with value = 0


Exit from Mobiflight software and restart again. I always close and restart MF after programming.
Click Run and start FSX

When you push the Push Button, the value will change from 0 to 1 and then 0 again
When value = 1, it will activate "MHz" for you to change freq or value = 0, it will activate "GHz"

Because I have just start doing with MF, Arduino then if I have anything wrong, please let me know. I will correct soon. Tks

I upload mcc, mfmc file to my host, you can download to test it
https://drive.google.com/file/d/0B-uFMfVSULd0WFVyb0syNllfZzQ/view
https://drive.google.com/file/d/0B-uFMfVSULd0ek1CR01IaGpieWM/view

Thanks pizman82 to give an instruction about precondition function in MF :thumbup:
[Last edited by tobypham, 2017-03-09 10:11]
2017-03-08 14:41
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3710
Supporter
NICE WORK, SIR !

Thanks for youre support. I will sticky this, and hope we can use it for a official tutorial soon.

2 Little things i would change a bit....

1. Offset 66C0 is a custom Offset This is not specific... you can use for example 66C1 and many others too. Maby you will describe with youre own words that fact. Just that the user not mean he HAVE to use THIS Offset.... official Range is 66c0 - 66FF (64 Byte)

2. At the "Set Encoder Config" you say....
iconQuote:

On Left: Radio - COM1 Standby Freq MHz (-) Decrease
On Right: Radio - COM1 Standby Freq MHz (+) Decrease



Maby you should say here that these are "EVENT ID" . Maby with sepcific number.

************
But finaly.... Big Thank you ! Wonderfull work !
Good Luck !
2017-03-08 18:02
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3710
Supporter
@ Toby

I still forgot to tell you theres a alternative way to set this function.
Maby THIS is more realitic and you love it much more as the first technic.....

How to do....
In the INPUT Config of the Pushbutton you need to change some things:
On PRESS value: Delete the "If($=0,1,0) and use simply 1 for the value
Create a "On Release" in the same Config and use same Offset (66C0 in this example)
Here you set as value 0

Reslut:
Now you not longer toggle the Mhz/Khz with pushing the button.....
If you Turn the Encoder without touching the Button you change Khz
*
If You Push the Button and HOLD it in pushed Position while turning the Encoder you set Mhz
When you release the Button you already change Khz again.


Just for youre information. Maby this is better for you !
Good Luck !
2017-03-11 16:21
Avatar
tobypham
Posts: 13
Hi pizman82,

Thanks for your 2nd way but I like the 1st
Because in 1st way, I dont need to keeping the button while tuning the radio freq :D

And another question about custom/free offset 66C0-66FF
I have searched someone said there are 64 free offsets, is it true?

iconQuote:

Free offsets are:
66C0->66CF (66C0 ;66C1 ; 66C2 ; 66C3 ; 66C4 ; 66c5 ; 66c6 ; 66c7 ; 66c8 ; 66c9 ; 66ca ; 66cb ; 66cc ; 66cd ; 66ce ; 66cf)
66D0->66DF
66E0->66EF
66F0->66FF

They are 16 free by line ; so, 64 offsets for the 4 line.
It's right?

2017-03-12 12:02
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3710
Supporter
Yes and No.

first you not need to count youreself..... Read the FSUIPC Offset Mapping.pdf....
iconQuote:

66C0.... 64Byte .... Free for general use,



So Yes its 64 Byte in this Free Range. BUT You got Hundrets of Bytes additional in other Areas, too like i discribe some weeks ago here in a Topic.
If you not use the Project Magenta AddOn you can use this Area. If you not Use PMDG you can use this Area for example.

To Save Offsets you already can work with Bits..... for our Switch/Pushbutton Example we can use a bit to.... So we not Say 66C0 =1 We mask the Value and Say "Only Bit:0 of Offset 66C0 will be written and readout" so we can use 1 Byte 66C0 for 8 Different switch/Pushbutton Combinations.
A other way to save Offsets (And Configs) is maby to use one offset for all "Double Encoders" ! In radio Panel you can define for NAV1. NAV2 COM1 COM2 everytime the same offset for the Button. So if you push one of the 4 Encoder Buttons ALL 4 Encoders switching between Mhz and Khz. So you only need One Readout Config.... And only one Byte or bit for all switches with this toggle function in youre cockpit.
Good Luck !
2017-03-12 16:37
Avatar
jlr91
Posts: 6
Hi,
The images are no more available and I need them to follow this tutorial.
Thanks,
Regards,
Jean-Luc
2019-08-28 11:39
Avatar
jlr91
Posts: 6
OK. I made it with your documentation.
Thanks
2019-08-28 14:59
Avatar
ivota
Posts: 3
iconjlr91:

Hi,
The images are no more available and I need them to follow this tutorial.
Thanks,
Regards,
Jean-Luc



Can project images be reuploaded?
2019-09-15 02:38
Avatar
ivota
Posts: 3
I made it.

https://youtu.be/b55E6hZYx0s
2019-10-15 20:30
Avatar
rodo2212
Posts: 18
This is just greattttt. Like this with on rotary enconder and in push button you can use radio or nav, instead of getting a dual rotary.
Thank you.
Regards Luis
2019-10-30 15:36
Avatar
alpan
Posts: 8
Hello Guys,
I'm becoming crazy with these configs that don't work for me, using one encoder for both Mhz and Khz. I'm running windows 10 with P3DV4.5. I downloaded ivota's example and here is the problem. When I push "PushButton com2" the Com2 precondition output status doesn't change from 0 to 1. 1 appears quickly and diseappears. It is the same problem with Com1. I hope semebody will be able to help me. Thanks
2020-04-14 14:47
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3710
Supporter
iconalpan:

I downloaded ivota's example and here is the problem.



Hi
I´m sorry but look like the pictures are gone.... So the Guide above is verry confusing without screenshots.

Please tell me what file you download where.... Then i can check it myself and test it.
Good Luck !
2020-04-14 16:08
Avatar
alpan
Posts: 8
Thank you for your fast replys, here you can find the link:
https://www.youtube.com/redirect?redir_token=TOoKBpaMlsPpHg5ZWW_JWeg4mY58MTU4Njk2MDEyNUAxNTg2ODczNzI1&q=https%3A%2F%2Fwww.mediafire.com%2Ffile%2Fi5aj0x803bg4atb%2FRotary_Encoder_IVO.mcc%2Ffile&event=comments&stzid=UgyMIuQdsFwF2xAiKu14AaABAg.90iGdg9Drav90iZdoK_ooC
Best regards
Albert
2020-04-14 16:16
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3710
Supporter
Hi

I not test the file live in sim cause i move from FSX to P3D some day ago and so i have no access to my homecockpit hardware at the moment.

BUT
I check the code and it looks good on first view.


Possible Issues:

1. The Display Configs are a bit Untidy.... they incluide a non active Transform and a "strange" Compare.
I would use here simply tranform $+10000 and would not use Compare ( let it empty)
BUT : I not think this is the problem.... this is just a optical fact.... Not a Bug.

2. Wrong sequence in formula:
I don´t know why but in other situations some less User report a strange bug.... Whatever it is not logical and BOTH should work they tell me the sequence of formula is important.... so if($=0,1,0) maby not work and those users need if($=1,0,1)
AGAIN This is technical the same and should result same way.... But some users say only one of the two formulas work in there System!

3. Usage of Offset by 3rd Party AddOn. (Here i think thats your problem !!)
Also other AddOns or configs in your system can use a Offset same time.
If Offset 66C0 or as you said Offset 66C1 is swapping directly back to "0" after you press the button then "maby" a oher programm use this offset already and write it back.

For testing you can simply change the Offset:
Please use in the INPUT Config Push Button Com 2 for example 66D0 instead of 66C0. Also get sure in the Output Config COM2 Precondition you also rework the data to 66D0.
As i know mostly the first Offsets are used by Trafic and Weather Addons in rare cases.... So 66D0 should work. BUT sure.... If you use for example a Lua Script that use already Offset 66C0 and follow bytes then they are no longer useable.... Check this please !

Maby this solve the Problem.

Please report experience.
Good Luck !
2020-04-14 19:37
Avatar
alpan
Posts: 8
Thank you very much Pizman, Grey answer. I'll try all that tomorrow.
Best regards
Albert
2020-04-14 20:57
Go to page 1Go to page 012Go to page 2Go to page 2