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
gmcallis
Posts: 28
There have been a number of posts, including some of my own, where cockpit builders have queried how to get potentiometers to work with Mobiflight.

I now have my entire PMDG 737NGX overhead panel working, including potentiometers for the Air Temp and Circuit Breaker and Panel dials. This can easily be done to also get MIP dials working for the left and right display units on the MIP.

Here's what you will need.

a) a potentiometer.
b) Either a Arduino Micro or Leonardo.
c) the joystick.h library from https://github.com/MHeironimus/ArduinoJoystickLibrary
d) the code to upload to the either Micro or Leonardo.
e) a licenced copy of FSUIPC.
f) the document PMDG 737NGX Custom Event ID's available in your /Modules/FSUIPC Documents/ folder within either P3D or FS.

Wire the potentiometer with the two outside pins wired to, one to ground, the other to the 5v pins on your board. The center pin should be wired to an analog port on the board, most likely A0. In my case I have three potentiometers so I have daisy chained the ground and VCC pins and used pins A0, A1 and A2. The ground and VCC are common to all three potentiometers.

Following the link to download joystick.h, click on the green "Download or Clone" button, then click on "Download Zip". This will download a zip file, ArduinoJoystickLib.zip to your downloads folder. When you open the downloaded zip file there is a folder ArduinoJoystickLibrary-master, again click on this folder to open it.

Contained with this folder is a folder named Joystick. Drag this folder to your Arduino Library folder, usually %Documents%\Arduino\Libraries\

Next open your arduino.exe.

Go to Tools/Boards/Board manager and select the correct Arduino board you are using, either "Arduino/Genuido Micro" or "Leonardo".

Next open again Tools/Port and select the correct Com port for the Arduino board your using.

Lastly copy and paste the following code, then save, then upload.

Here's the code:

#include <Joystick.h> // Reference the Joystick Library.

// Create Joystick
Joystick_ Joystick;

unsigned int xAxis = 0;
unsigned int yAxis = 0;
unsigned int zAxis = 0;

// Set "initAutoSendState" to true for "Auto Send" mode or false for "Manual Send" mode.

const bool initAutoSendState = true;
//const bool testAutoState = false;

void setup() {

Joystick.begin();

}

void loop() {
xAxis = analogRead(A0)/4;
xAxis = map(xAxis,0,255,-127,127);
yAxis = analogRead(A1)/4;
yAxis = map(yAxis,0,255,-127,127);
zAxis = analogRead(A2)/4;
zAxis = map(zAxis,0,255,-127,127);

Joystick.setXAxis(xAxis);
Joystick.setYAxis(yAxis);
Joystick.setZAxis(zAxis);

//Joystick.setState(); // this updates the "Joystick" library and
// therefore your computer of all the current
// joystick and button states determined above
// all at once. YOU ONLY NEED TO USE THIS LINE
// IF const bool initAutoSendState = FALSE (the
// code for initAutoSendState is a few lines
// above the "setup" section of code)
}

Note: this code sets up three joystick axes, X, Y and Z. If you don't require three axis you can either rem or delete the lines referring to the yAxis and/or zAxis to get the number of axis you require.

You can test you now have the Micro or Leonardo set up as a joystick by opening Control Panel / View devices and printers and your Arduino Micro or Arduino Leonardo should be listed. Right click on the relevant icon you have and select "Game controller settings". Your Arduino board should be listed along with any other joystick peripherals you have be them joysticks, (obviously), rudder pedals, yoke or throttle quadrants, etc.

The final step is to assign each axis to EventId's using FSUIPC.

Open FSUIPC and menu item "Axis Assignment".

Click on the "Rescan" button and move the required potentiometer until the Joystick# and Axis# are correct. For me the Arduino Micro was Joystick number 4 and the X axis. Now you simply need to tell FSUIPC what action to take.

In the "Type of action required" box, leave the radio button as "Send to FS as normal axis", check the first box and select "custom Control" from the drop down box. Another box appears within which you key in the required EventId for the function you wish the joystick/potentiometer to action. For my three actions for the Temperature controls are EventID's 69937, 69938 and 69939.

Once completed rotating the potentiometer should be reflected on the virtual control in FS or P3D.

I've written this as correctly as possible. If anyone becomes aware of typos I'm happy to amend.

Hope this helps others achieve what I have and am extremely happy with. There's very little can't be achieved using Mobiflight.

Cheers, Graham McAllister
[Last edited by gmcallis, 2018-06-11 18:55]
2018-02-20 11:38
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3709
Supporter
Thanks Graham for that Information !

We talk last week in a little "meeting" about that stuff with Sebastian. And i think THIS is the way we should go.

Include Potentiometer detection in Mobiflight can be done easy.... But the problem is the software side.
For Mobiflight we would need the same system, that is exist in FSUIPC already.
So Question is simply.... Should sebastian work hundrets of hours to reproduce this system and write it again for Mobiflight.... Whatever it sitll exist in a perfect way in FSUIPC ??
I think "NO" .

My last Note.
The Problem finaly is, that THIS Technic you describe is a bit difficult for new Users. So i think since long time that we need a "Programm" that do it for us.
Maby in the future a guy like "Mr Heironimus" will give us a tool that generate those sketches automaticly and we users not must write it ourself.

I think here about a tool that is look like the "Mobiflight Device settings Tab"
So the Software should detect a empty Leonardo/Micro and will upload a "firmware" on it and change it into a "BlaBla#Joystick"
Then we can work in a GUI and can say we like for example a AXIS and will set it on Pin A01 ( Selected in a dropdown menu like in Mobiflight) or a Button on Pin 7 for example
Finaly i push "Upload" and the Programm will generate the difficult sketch-code itslef and will upload it to the Board.
And THEN we only connect the board in a USB port and it is already a perfect Joystick that can be used in FSUIPC.

The most comfortable solution would be if THIS can be done with a MEGA instead of Leonardo/Micro cause a Mega got lots of additional Pins.... BUT The Mega can not be used as a HID Device ( Only with a change of Bootloader by the user) and the Joystick_H library is also NOT Compatible with Mega, too.

So at the moment we can use "Your" technic or we need to buy a LeoBodnar for 50$.... That will be perfect and not need own sektches.... But its expensive !
Good Luck !
2018-02-20 16:44
Avatar
gmcallis
Posts: 28
Hi Pizman and thanks for the comments.

I think you're right if the software can be setup similar to Mobiflight.

The thing is, Arduino software is open source which is also expressed in the copyright notes of the joystick library by Matthew Heironimus. Within the code it states:

<quote>Copyright (c) 2015, Matthew Heironimus

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA</unquote>

Frankly I do believe people such as Matthew and indeed Sebastion deserve more credit for their contribution than to simply use their software and manipulate it for anothers own purpose, but legally, it appears there is no issue. There's just something immoral about it to me.

For my part I'm a happy person. My 737NGX overhead has everything working, from switches, dials, electrical read outs, Flight and Landing pressurisation altitudes and now even the temperature controls and Circuit Breaker and Panel lighting and it's all been done with Mobiflight, about ten Arduino Mega's and a couple of Arduino Micros. Through our discussions a couple of weeks ago I now also have the Engine Start switches auto return once reaching 56% N2.

I'm sure any complaints about Mobiflight would be few and far between, and if what I've been able to achieve can assist others I'm happy to have contributed. If others feel the instructions can be simplified, or better explained, I'd be happy to make changes if appropiate.

I'm sure Sebastion and yourself will come up with the best workable solution sometime in the future as time permits.

Cheers
2018-02-20 22:51
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3709
Supporter
Thank You again....

We already said, this is the next step for us.... Sebastian is working at the moment for a new release with some new features (verry usefull) . He get also some basic new ideas for the future to implement some wonderfull new things we still waiting till years ( Whatever the Poti Support is not a part of it)
There are also some OpenSource supporters in the project , that work with the code !

And Stephan and Myself are still planing for a new "Tutorial Area" external of the Forum... Maby in a new section of the www.mobiflight.com Webside.
If possible we want to rework the existing LED/Switch/7Segment Tutorials to current 7.4 state.... And we like to write new guides for Servo, Stepper and LCD.
Also we like to make some Sub sections for the most poplary AddOns like PMDG, Jeehell and Prosim.
Maby we can support some Example Files there like a Full B737 PMDG MCP Config with all switches and LED for example.

But you still know.... those projects take time and need lots of hours..... Maby we find some more supporters in the future to help us !
Specialy some guys with a 100% English Mainlanguage.... Cause mine is not the best :blush: Maby just for readback a turtorial and bring it in right gramatic !
Good Luck !
2018-02-21 00:42
Avatar
giocc
Posts: 7
iconpizman82:

Thank You again....
We already said, this is the next step for us.... Sebastian is working at the moment for a new release with some new features (verry usefull) . He get also some basic new ideas for the future to implement some wonderfull new things we still waiting till years ( Whatever the Poti Support is not a part of it)
There are also some OpenSource supporters in the project , that work with the code !



Hi pizman82, sorry if I hijack this thread, but I think I'd give it a shot...
As you might recall, I wrote a few weeks ago in the Firmware forum about some modification I was working on (https://www.mobiflight.com/forum/topic/1058.html).
I tried to contact Sebastian, but without success yet; in the meantime, I have finished the coding on the Arduino firmware (where I have done some pretty important modifications) and now I'm starting to work on the Connector.
From your post, you seem to be somehow aware of what is going on in current development, or have the chance to get to Sebastian now and then... I would greatly appreciate if you could help me to get in touch with Sebastian, or at least let him know what I'm working on, and possibly avoid unnecessarily wasting development efforts.

Thanks
2018-02-22 13:50
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3709
Supporter
@giocc

Sebastian was verry bussy in the last months.... Last week i talked to him first time since Oktober 2017. Please understand he need a lot of time for his family and kids.... Also he get a verry hard job ( At the moment he is on Buisness trip in Europe and pretty shure have no time or possibilty to work on the code).
But he said in February/March he will take the time to build V7.5 and will inlcude the stuff that is supported by the openSource guys ( Joystick and Encoder stuff)
He know himself that he was verry rare last time and apollogy for that!

To Contact him you got two ways....
Write a email to him..... info@mobiflight.de
Or much better.... Present or discuss your impressions in the Devleoper Page .... there he can see and work with your code directly. https://bitbucket.org/mobiflight/mobiflightfc

I´m a bit confused cause i not find anything from you on the Bitbucket page.... As i said in the other topic.... It´s nice if you and other guys work on the code and bring new features.... But this should be done in direct comunication with the devleoper ( Via that page in that case) ....
What happend if Sebastian said a full part of your code like the Shift Register Input/Output is not ok for him and he don´t allowed to implement it.... then all your work was unnecessary here.....
Or other direction.... What happend if you work 50hrs for a feature that is already finished by him but still not released.... Same again lots of unnecessary worktime.
I high recommend to make the hole process from the Idea over planing and programming until the implement and release in direct collaboration with him !
Good Luck !
2018-02-22 19:49
Avatar
giocc
Posts: 7
Hi pizman82,
yes, what you are describing is exactly what I was saying all along... I needed to get in touch with him to explain what I have in mind and get his feedback before I start pushing contributions.
That's the reason why I wasn't on bitbucket yet.
Luckily, just yesterday I managed to get in touch (yay! :D ), and after just a few clarifications (unfortunately my changes are not trivial) with a little luck I'll be able to get started soon, taking as little of Sebastian's time as possible.
Thank you for bearing with me and for being helpful, I'm really looking forward to see Mobiflight grow.

GiorgioCC
2018-02-23 16:38
Avatar
vicvans
Posts: 1
HI
every one.

I am using mobiflight with mega Arduino and is really simple to use it.....Thanks to every one involved in this work.

I'M TRYING TO CONNECT THROTTLE AND MIXTURE,

Using lineal potenciometers and Arduino Leonardo but
using your code and follow the instructions step by step always appears

'Joystick ' was not declared in this scope.......ANI IDEA TO SOLVE THIS

THANKS
BEST REGARDS

IVAN SILVA
2018-05-12 23:29
Avatar
Pietrogramma
Posts: 19
Hi every one,
I can follow this tutorial for connect a potentiometer but Arduino give me this error:

"Arduino:1.8.5 (Windows 10), Scheda:"Arduino/Genuino Micro"
D:\Users\Documenti\Arduino\Mobiflight\Mobiflight.ino: In function 'void setup()':
Mobiflight:14: error: 'Joystick' was not declared in this scope
Joystick.begin();
^
D:\Users\Documenti\Arduino\Mobiflight\Mobiflight.ino: In function 'void loop()':
Mobiflight:22: error: 'Axis' was not declared in this scope
Axis = map(yAxis,0,255,-127,127);
^
Mobiflight:26: error: 'Joystick' was not declared in this scope
Joystick.setXAxis(xAxis);
^
exit status 1
'Joystick' was not declared in this scope"


How I can solve this error?
Thanks and ciao
2018-05-16 14:18
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3709
Supporter
Hi.
THIS is not a part of Mobiflight ! ( MF not supports Potentiometers at the moment and not in the near future)

For help you must talk to gmcallis himself or you have to search the web for those things ( Maby in the Arduino Websides or in the project Github pages)
Good Luck !
2018-05-16 15:53
Avatar
gmcallis
Posts: 28
Apologies, amended code including the lines
//Create Joystick
Joystick_ Joystick;

Be sure to download the Joystick library from https://github.com/MHeironimus/ArduinoJoystickLibrary

Here is the full code to copy and paste.

#include <Joystick.h>

// Create Joystick
Joystick_ Joystick;

unsigned int xAxis = 0;
unsigned int yAxis = 0;
unsigned int zAxis = 0;

// Set "initAutoSendState" to true for "Auto Send" mode or false for "Manual Send" mode.
const bool initAutoSendState = true;

void setup() {
Joystick.begin();
}

void loop() {
xAxis = analogRead(A0)/4;
xAxis = map(xAxis,0,255,-127,127);
yAxis = analogRead(A1)/4;
yAxis = map(yAxis,0,255,-127,127);
zAxis = analogRead(A2)/4;
zAxis = map(zAxis,0,255,-127,127);

Joystick.setXAxis(xAxis);
Joystick.setYAxis(yAxis);
Joystick.setZAxis(zAxis);

//Joystick.setState(); //this updates the "Joystick" library
//and therefore your computer of all the current
//joystick and button states determined above
//all at once. YOU ONLY NEED TO USE THIS LINE
//IF const bool initAutoSendMode = FALSE (the
//code for the initAutoSendState is a few
//lines above the "setup" section of code.
}

Graham
2018-06-11 18:35
Avatar
paul_max
From: United Kingdom
Posts: 70
Supporter
Pizman82

I don't think you fully understand the development process. Bitbucket is an open source collaborative system that many developers can be involved in. We do not have to wait until Sebastian is ready next March for a new build.

What is typical in software development is a beta build, with beta testers to evaluate the beta and provide feedback. Also there needs to be a test system, to methodically test each feature for inclusion in a release candidate.

Developers can use git to produce the beta source. Git stores the entire history of all edits, and can merge many developers work into one sucessful build. Therefore no work is lost. With sensible archtitecture the software can be in decoupled modules...for example 1:2 and 1:4 encoders in a module that can easily be added/removed from a build.

This process allows the product evolve quickly. For example the encoder support can be quickly improved without compromising the code. Plus encoder support is very important to users - many of the high quality encoders are 1:2 or 1:4. In my opinion this is not a feature to delay.

Regards
Paul
2018-07-15 00:14
Avatar
StephanHo
From: EDDG, Germany
Posts: 1539
Supporter
Hi Paul,

If I have taken something from a 45-year career, then it is the experience that software development takes time.
I do not want to offend any developer, but they mostly develop software whose frontend they do not fully understand. Nothing against the work itself, but it lacks the understanding of the application itself. They have development experience, but no application experience.

MobiFlight looks a bit different, also in connection with Bitbucket. Here the developers are also users and that is the decisive advantage, which is absolutely effective. The developers can think into the processes and program accordingly.

If I do not like software, it's beta releases. Even official releases that are sold for good money leave the end user as a beta tester. If Microsoft were to develop cars, not a single car would have come on the market without error. But that's another topic...

With MobiFlight, however, no money is earned and so you MUST set different standards here! It is not developed on a part-time basis, but in leisure time, next to work and family. You can not expect a developer here to throw new features on the market within a month. The time of development must be left, as in a hobby. To set the standards of development groups, I consider missing!

For a paid company product, I can make quite different demands than with a freeware project.

Of course, the time factor plays a role. Anyone who, as a user, however, engages in such a private "freeware project" must first be aware that such a thing is not even developed overnight, and on the other hand, the time for development must be present and it can take much longer.

The issue you mentioned with the encoders should be obsolete since Wednesday, because since MobiFlight 7.5.0 is available and this topic thus history.

Whether the MobiFlight Potentiometer evaluation will come once is no problem for me. MobiFlight does not have to be able to do everything, especially if these things already exist (not in MF) (see FSUIPC). Why reinvent the wheel when it is already round and rolling? Make it even rounder? Then the wheel would not be a wheel;)

To get back to your initial thesis, Bitbucket needs a coordinator who distributes the threads of each feature and monitors their production, otherwise, as we say here, "many cooks spoil the broth". And also this coordination means time expenditure. Again, you can not do it, because both the coordinator and the developers work pro bono, at least as long as MobiFlight is a non-commercial project.
Grüße,
Stephan
2018-07-15 12:30
Avatar
DocMoebiuz
Moderator
From: NW of KPWK, United States
Posts: 1468
Hey guys

I just wanna add something to the discussion: everybody is invited to contribute to MobiFlight!

The current 7.5 release included contributions from different community members.

It took me too long for some of them to approve this time, but I promise I will do better in the future.

With this being said: if you want to contribute, branch the code from the repository and create a pull request. I will try my best to provide feedback, merge the pull request and eventually build a new release as soon as my time permits.
Have a great day!
Sebastian

MobiFlight - Simply build your own home cockpit for your favorite flight sim - FSX, Prepar3D (FSUIPC), X-Plane (XPUIPC)
2018-07-15 18:19
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3709
Supporter
iconpaul_max:

Pizman82
I don't think you fully understand the development process.



Hi Paul.

Maby you missunderstood my intentions.
I´m not against Bitbucket and i´m verry happy if you and other guys work on new features or support MF with writing Manuals and Tutorials!

What i mean:

If You ( or another one) make a new feature and create a beta state version that can be load on Bitbucket.... Then YOU must do the support for that version.
If a user got a Problem he will mostly not request help in your bitbucket account.... He will ask HERE in Forum for help ! ( And mostly will not tell me that he use your Beta)

Summary.... I try to help the users here as good as i can..... But i NOT looking forward to do that for different Versions or for own Projects.

If a Problem is reported while useing a "custom Beta version" i will recommend the user to test the same thing in the official release. If Problem exist, too i pretty shure try to help !
But if problem is in beta only then the guy who make the beta should do the support..... not me.

Apollogy for that.... But my time is verry limmited.... i can not observe multiple projects additional to the current support process. If a new feature get "live" i will check it out and try to support it, too..... But not while Beta Status.

But Finaly..... Thank you for your Impressions.... I hope we find more Users in the future that like to support us !
Good Luck !
2018-07-18 06:22
Go to page 1Go to page 012Go to page 2Go to page 2