-
-
Notifications
You must be signed in to change notification settings - Fork 126
Using a servo motor for an elevator trim indicator
This tutorial will cover how to configure Mobiflight with a servo motor to control an elevator trim indicator gauge, like in a Cessna C172. We will not go into any details about how the elevator trim gauge internal mechanism should be built. In general, the servo will move a needle in a limited range, controlled by Mobiflight depending on the value of the elevator trim position given by the flight simulator.

A 9g servo can be used for this example. In addition to the 5v and GND wires, only one Arduino digital pin is needed to connect the servo. In this tutorial we show pin 9 being used, but it can be any available pin.
Even small servo motors like the 9 gram type typically use 500 mA to 750 mA. This is a relatively high current for an Arduino, so use of an external power supply is recommended. Note the external power supply GND wire is also connected with the Arduino GND.

Create the device configuration for the servo motor in Mobiflight Modules. Specify the data pin where the servo motor was connected. In this example, it is pin 9.

Create an output config in Mobiflight, to display the value of the generic variable using the servo we connected.
Sim variable tab
The sim variable can be selected from the Mobiflight presets dropdown menus. For custom variables not available from the menus, you can directly enter the code into the code box (tick on the "Show preset code" opens this box).
For the generic elevator trim position, use this variable.
(A:ELEVATOR TRIM PCT, percent over 100)
Please note that this variable takes values in the range from -1.0 to +1.0.

Modify tab
Because the simulator variable range is -1.0 to +1.0, it is necessary to change this value to a positive integer scale for use in the servo movements. The servo only takes non-negative integer values.
In this case, we have chosen to use an interpolation modifier that takes as input the -1.0 and +1.0 in the left column, as received from the simulator. Here we define the output to be 255 and 0 in the right column. Please note that by specifying 255 first and 0 second, we are setting the movement to be inverted. If this inversion is not required, then specify 0 first and 255 second.

Display tab
The display tab is where the parameters for the servo motor movement are specified.
As mentioned before, the servo requires a non-negative ascending scale. This means that both Min and Max values need to be 0 or greater, and Max must always be greater than Min. As we have chosen to use a servo scale of 0 to 255, as given by the output of the interpolation table defined in the previous section, we specify the same scale in the Min value and Max value boxes.
The Max rotation parameter is the percentage of the maximum movement that the servo motor can achieve, which typically is about 180 degrees. In this example, we are setting a max rotation of 50% which will correspond to about 90 degrees rotation. In other words, the 0 percent position of the servo scale is matched to the Min value of the sim scale and the Max rotation percent position is matched to the Max value of the sim scale.

You may now set a test value at the bottom of the output config specification. Press the Test button and the servo motor should move accordingly. It is important to note that the zero position of the servo motor needs to be manually set to the minimum value in the gauge scale. This implies detaching the needle and resetting it accordingly.
Mobiflight will move the servo to the zero position on every exit and move to the current elevator trim position whenever it goes into run mode.
Congratulations.
You should now have a properly configured servo that will move according to the value of the elevator trim wheel position given by the simulator.
- 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
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers 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
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- 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