Skip to content

Example Servo motor

krok edited this page Jul 12, 2021 · 1 revision

Ok - let's start!

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.

This is what you need for the tutorial

The following items are needed to complete this tutorial by yourself:

  • Current version of MobiFlight Connector (min. 6.0.0)
  • A Arduino Mega 2560 mit aufgespielter MobiFlight Firmware - or say a MobiFlight Board :)
  • A 5V Servo Motor with 180° degrees of rotate from rc model area. If you search for "servo motor micro" on eBay it is likely that you find the exact same ones as I own for very low price.

Connect Servo Motor to Arduino Mega

The connection of a servo motor can be directly to the pins of your Arduino Mega:

Verbindung Servo Motor mit Arduino für MobiFlight Konfiguration

As you can see in the picture, the servo needs the following connections

  • red - A voltage supply 5V via pin at your Arduino Mega (e.g. on top of pin22)
  • black - a GND connection
  • yellow - the control line, which can be any digital pin of your Arduino, in the picture it is pin2

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.

Configuration of MF Connector

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.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-02.png

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.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-06.png

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:

  • DIN line - the control line
  • Name - The label for the device. This label appears later in other config dialogues and makes it easy for you to distinguish it from other devices

In this tutorial you use pin2 for the control line and "Servo" as label.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-09.png

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.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-12.png

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.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-14.png

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.

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-16.png

Click "OK"-button next to the Drop Down.

Now all settings are automagically set for you with the values from the preset. Easy, huh?

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-17.png

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).

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-27.png

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".

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-20.png

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

https://www.mobiflight.com/tl_files/bootstrapbase/img/tutorials/servo/tutorial-servo-step-28.png

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.

Congratulations!!!

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!

Installation

User Interface

Examples and tutorials

MSFS2020

X-Plane

Workshops

Community Boards & Devices

Additional Information

Firmware

Clone this wiki locally