In this tutorial, you'll see how to connect and configure a servo motor with the help of MobiFlight.
At the end you are going to display the current flaps position using a servo motor.
In this tutorial you will connect a simple and cheap servo motor to a Arduino Mega 2560.
The MobiFlight firmware has been tested with really cheap servos with a rotation of 180 degrees that are intended for rc models. You can get them for a low price at eBay and so.
You will configure the servo motor with the help of MobiFlight Connector in such a way that the current motor's position is in sync with the current flaps' position in your flight sim. You'll use the adequate FSUIPC offset to achieve that.
First, you'll learn how to connect the servo motor to the MobiFlight Board. Second, the configuration in the MobiFlight Connector Application is explained step by step.
The tutorial takes approximately 10 minutes.
The following items are needed to complete this tutorial by yourself:
The connection of a servo motor can be directly to the pins of your Arduino Mega:
As you can see in the picture, the servo needs the following connections
I recommend to use the PWM capable pins from 2-12 - maybe I can optimize the control through these pins in the future. However, currently it does not make any difference - you can use any of the digital pins PWM or not.
The images in this tutorial are taken from the german version - I am pretty sure you can find the corresponding items in your english interface. Thanks for your understanding.
After starting the MobiFlight Connector, you'll see an overview of your current configuration. In this example it is empty, because nothing has been defined, yet.
Now you open the Settings Dialog, because you have to configure your MobiFlight first. You must tell it on which pin your servo is connected.
Hence, choose Extras > Settings > MobiFlight Modules-Tab
Choose your desired MobiFlight Board in tree view on the left.
There are several different actions available in the below the tree view. For adding a servo click on New Device > Servo. As you can see in the image, there is also a context menu available where you can choose the same option from.
Now a servo motor has been added to your arduino based MobiFlight Board.
On the right side of the tab, you now provide some additional information - these vary for the different device types.
For a servo motor the available options are:
In this tutorial you use pin2 for the control line and "Servo" as label.
There is one step missing: You have to upload the updated configuration to your selected board. Click on the upload-button in the toolbar. The button is the first one.
A message appears that tells you that the upload has been successful. Now your MobiFlight restarts and knows that a new device has been attached and that it is a servo motor.
You close the settings dialog by clicking on the "OK"-Button. You are back to the overview - which is still empty.
Now you are going to create a new configuration for the flaps position of your airplane in your flight simulator.
First, you assign a name in the "Description"-field. In this tutorial this is "Flaps Position".
Click on the "..."-button at the end of the row. The Config Wizard shows up.
Choose the correct FSUIPC preset, in this case we take "Flaps - Position 1" as a good starting point.
Click "OK"-button next to the Drop Down.
Now all settings are automagically set for you with the values from the preset. Easy, huh?
Go to the "Compare"-Tab and deactivate the checkbox, because in this case we don't need any comparison since all values are used to control your servo. (The preset was intended to be used with a led).
Now go to the "Display"-tab.
In the Display Type section, choose the correct MobiFlight Board from the list.
From the next "Use Type"-Drop-Down select "Servo".
The Display Settings section automatically refreshes.
Choose "Servo"-Item from the DropDown "Servo".
Hit the Test-button. The servo motor now should rotate until the maximum deflection of 180 degrees.
If you like you can reduce the full rotation amount by adjusting the value for "Max. rotation". The less the value the less the servo rotates. This makes sense if you don't want to use the full 180 degrees or if you like to prevent that the servo turns too much and makes some strange noises. Try out your settings by clicking the test button.
If your motor does not respond, then please check the control line connection to your MobiFlight Board. Check also Voltage Pin and GND.
If the servo moves as expected, click the stop-button again.
Set the Min. Value to zero - this is the smallest value that the FSUIPC offset holds for the flaps.
Set the Max. Value to 16383 - this is the greatest value that the FSUIPC offset holds for the flaps.
These settings might be different for aircrafts others than the default ones - so please first try with a default plane
Close the ConfigWizard-Dialog by clicking the OK-Button.
Activate the newly added config row by clicking the checkbox in front of it.
Start your favourite flight simulator, e.g. FSX.
Load your flight.
Wait a moment until the FSUIPC-Connection has been established. This is indicated by FSUIPC status icon in the statusbar.
Let the MobiFlight Connector run by clicking the Start-button in the main toolbar.
Once you are in your airplane and master battery switch is turned on, start to change the flaps position.
Your servo should move accordingly.
Within a couple of minutes and some simple steps you managed to built a flaps indicator. O yes - that was easy!
Please let us know how the tutorial worked for you on the forums and tell us more about the things you build with the help of MobiFlight!