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
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: 2921
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: 2921
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: 2921
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: 4
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: 4
OK. I made it with your documentation.
Thanks
2019-08-28 14:59
Avatar
ivota
Posts: 2
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: 2
I made it.

https://youtu.be/b55E6hZYx0s
2019-10-15 20:30
Avatar
rodo2212
Posts: 9
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
icon