-
-
Notifications
You must be signed in to change notification settings - Fork 109
MSFS2020 Configuring an External Chronometer in Mobiflight
The purpose of this tutorial is to show how to configure a virtual Chronometer for your Mobiflight panel. This virtual device will be independent of the virtual cockpit in MSFS2020, but with minor additions, could be made to synchronize with the sim. However, we will not cover how to do in this document. We will only focus on the chronometer function: starting, stopping and resetting the timer and displaying minutes and seconds in a 7-segment module.
We will take as model for the behavior of our chronometer the unit found in the FBW A320 aircraft. The chronometer in this airplane has only two buttons: one for Start/Stop and one for Reset. The Reset button restarts the time count if the timer is running or will turn off the display if the timer is not running (Stop mode). The display is of minutes and seconds in a four-digit display.
Hardware side
You will need the following parts to build this chronometer:
1 Mobiflight compatible Arduino board (Mega, Uno, or Pro Micro)
2 button switches
1 8-digit 7-segment max7219 module (only four digits are required)
wiring as required
We assume you are familiar with how to wire the hardware. If not, there are other tutorials that cover these details. Buttons have two legs, one goes to an Arduino pin, the other leg goes to ground. The 7-segment displays have five pins: VCC goes to the Arduino 5v pin, GND goes to ground, DIN, CS, and CLK go to Arduino pins. Make a note of which pins you have used to connect buttons and display module. Any pins can be used. The only exception being that pin 13 on a Mega or Uno board should not be used for an input device because it has the builtin LED connected there.
Configure the Mobiflight hardware specifying the pins used to connect your hardware. You will create one hardware config for each button and another config for the LED module. Test that your newly connected and configured hardware is detected by Mobiflight by activating the logging mode in Settings and verifying that the log registers when you push the buttons.
Mobiflight Configuration
Now create one input config for the Start/Stop chronometer button and map it to the first hardware button.
Create another input config for the Reset button and map it to the second hardware button.
Start/Stop Button input
In the Input tab, select the Arduino board and the first hardware button config you created previously. In the On Press tab, select Action type is Microsoft Flight Simulator 2020. You don't need to select any presets, as we will be using custom code in this project. Check the Show Preset Code box and copy the code below to the code box.
On Press tab
(L:myChrRun) ! s0 (>L:myChrRun) (L:myChrTime) -1 == if{ 0 (>L:myChrTime) }
l0 if{ (E:SIMULATION TIME, second) 1 + (>L:myChrStart) }
els{ 0 (>L:myChrStart) }
### Here goes the specific aircraft chrono start/stop event ###
### In the case of FBW A320 it is (>H:A32NX_CHRONO_TOGGLE) ###
Notes on the code:
- myChrRun is flag that is toggled with each press of the button to signal that the chronometer is running.
- If the chronometer has just started myChrTime is equal to -1. If so, this variable is set to 0.
- myChrStart is a timer tick of 1 second that stores the time for the next chronometer time update.
- If the chronometer has been stopped, myChrStart is set to 0.
- Optional, include the specific aircraft chrono toggle event to sync with the virtual cockpit
Reset Button Input
Repeat the same procedure above for the other button configuration.
On Press tab
(L:myChrRun) if{ 0 (>L:myChrTime) (E:SIMULATION TIME, second) 1 + (>L:myChrStart) }
els{ -1 (>L:myChrTime) } }
### Here goes the specific aircraft chrono Reset event ###
### In the case of FBW A320 it is (>H:A32NX_CHRONO_RST) ###
Notes on the code:
- If the chronometer is running (myChrRun is equal to 1, then the running reset is made, only myChrTime is set to 0.
- If the chronometer is not running, myChrTime is set to -1 to signal that the display should be blank.
- Optional, include the specific aircraft chrono reset event to sync with the virtual cockpit
7-Segment Output Display
Create an output config in Mobiflight for the 7-segment display as shown below. Do not select any preset, as we will be running custom code with this project.
(L:myChrRun) if{ (E:SIMULATION TIME, second) (L:myChrStart) > if{
(L:myChrTime) 1 + (>L:myChrTime)
(L:myChrStart) 1 + (>L:myChrStart) } }
(L:myChrTime)
Notes on the code:
- myChrRun is monitored constantly to detect whether the chronometer is running or not.
- If true, then check if it is time for the 1 second update. If not, nothing is done.
- If it is time for an update, myChrTime (the elapsed time value) is incremented by 1.
- The next update time is setup in myChrStart.
- The output value is always set to myChrStart for display.
Transform
if($=-1,' ',Floor($/60%60)*100+$%60)
- The transform formula checks for a value of -1 to blank the display if true.
- If not equal to -1, then the elapsed time in seconds is parsed into minutes and seconds for the display.
The End.
- 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