-
-
Notifications
You must be signed in to change notification settings - Fork 104
Example 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:
- 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.
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
- 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.
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:
- 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.
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!
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Using a Winwing FCU with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
- MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards