-
-
Notifications
You must be signed in to change notification settings - Fork 107
Beginner's guide to input multiplexers
In MobiFlight, multiplexers are currently used as multipliers of digital inputs. In other words, they allow to read up to 16 physical inputs with the expense of a single Arduino pin.
Multiplexers are a sort of “electrically controlled” rotary switches; they have a set of switched terminals (usually 8 or 16), only one of which is connected to a single (common) terminal on the other end.
In order to determine which terminal is connected, a set of selector inputs is provided: the signals on these inputs form a binary code corresponding to the input number. For a 1-to-16 multiplexer (the most common type for our application), the binary code requires 4 bits, therefore there are 4 selector lines.
The selector lines select the channel; they can be seen as the position indicator for our "rotary switch".
It is important to know that:
- all unselected, switched terminals remain unconnected.
- Multiplexers have no polarity: all terminals can be both inputs and outputs.
If the common terminal is an input, then switched terminals are outputs, and vice-versa.
As mentioned, they are used to connect many physical inputs to a single Arduino pin.
Switched terminals are used as input lines from physical buttons and switches, while the common terminal is connected to an Arduino pin configured as input; of course, the MobiFlight software takes care of driving the selector lines as necessary.
This is currently the only mode supported by MobiFlight, with the additional limit that these inputs can not be used to connect "fast" inputs like encoders (though this limitation will probably be removed in the near future);
however, multiplexers can be used to "multiply" other types of inputs (e.g. analog ones) or devices (e.g. LED or display drivers). If you're interested to know more, please refer to the document Generics about Multiplexers in-MobiFlight.
This application of multiplexers looks similar to the purpose of a shift register - and indeed it is; in fact, in practice they could be considered almost equivalent alternatives.
However, a shift register also seems to require less control lines: 3 pins vs. the 4+1 pins (4 selectors + 1 input) required by a multiplexer. So, what's the deal?
-
First of all, multiplexers have a distinct advantage over shift registers (not mentioning the fact that they're not limited to digital inputs): their inputs can be addressed directly, so groups of them - or individual inputs - can be read more frequently than others, or at request, allowing faster and special inputs to be processed.
Currently, this advantage is not exploited in Mobiflight, but it will be probably soon, e.g. for encoders. -
The selector lines can be shared by any number of multiplexers; any added device only requires one more Arduino pin (for the additional input). The Arduino pin occupation can then become comparable (if not better) to that required for an equivalent number of shift register chains. This might become no longer true if shared pins are introduced in MobiFlight also for shift registers and display drivers.
-
Multiplexers are very popular because they are used in a home cockpit system (RealSimControl, formerly named SimVim) as its only means of input expansion; a fairly large number of home cockpits use this system, and a better support of these devices by Mobiflight would offer an alternative with interesting new features (for instance, the native compatibility with several flight simulators, or a higher support for customization).
In practice, the most commonly used multiplexer is the 4067 (the exact part number is usually 74HC4067); this is available both as bare component or as breakout board where the component is mounted. The breakout board version is more easily available, cheap and generally convenient; it contains very little more than the component itself, so there is little difference in usage. This is the schematic for a common breakout board:
This is how it is connected:
Data, S0, S1, S2, and S3 can be any available pins on the Arduino; as always, it is recommended to avoid pin D13 (connected to the onboard LED) to prevent malfunction issues.
To add more than one multiplexer module, only one additional pin is required for each (the respective "Data" pin); selector pins S0... S3 are shared between all multiplexer modules.
Currently, there's a limit of 4 multiplexers for the Arduino Mega and RaspberryPi Pico, and 3 for the other Arduinos; however this is mostly an arbitrary limit that can be easily increased (and will likely be soon).
Some important notes:
- There is no such thing as a "daisy chain", or series, connection for multiplexers: rather, they are connected in parallel, sharing the four selector lines and using just one more reserved pin each for their output (i.e. Arduino input).
- As inputs, multiplexers draw very little current; their power supply (5V and GND terminals) can therefore be connected directly to the Arduino board.
- The EN terminal must be connected to GND (directly or through a resistor) for the device to be enabled.
On breakout boards, a 10k resistor is already mounted for this purpose, but keep it in mind if you happen to be using the "naked" component. - Since the buttons, switches or other input controls work by short-circuiting the respective input to GND, the corresponding Arduino input (in this case, the common terminal of the multiplexer) requires a pull-up resistor.
This is already integrated in the Arduino board (and activated by MobiFlight); however, for (electrically) noisy environments or long connection wires, it can be useful to connect an additional pull-up resistor ("R" in the picture). This can be soldered directly on the board pads. - Multiplexers also handle "push-pull" inputs (even mixed with the "regular" ones), i.e. inputs that do not short to GND but supply a voltage both for the high and the low level (like outputs of logic ICs or e.g. other Arduinos). However, inputs that only supply a voltage for the high level but are disconnected for the low level cannot be mixed.
Finally, this is how a multiplexer input module should be configured: the labels in the pin selection boxes correspond to the connections picture above.
Remember that, if there is more than one multiplexer, the selector lines are in common: therefore, while the S0..S3 pins appear in the panel of every multiplexer (for reference), they can only be modified in the panel of the first one. A button, highlighted in the picture, will take you there quickly; changes will automatically be reflected in the other panels.
v1.0 - 2023-03 by Giorgio Croci Candiani (@GioCC) for 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
- 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