A multiplexer (mux) is an electronic switch that selects one of several analog or digital input signals and forwards it to a single output line based on binary control inputs. Think of it as a multi-position rotary switch on an old stereo receiver, but instead of your hand turning the knob, digital logic pins dictate which channel connects to the output. In a real circuit, a mux changes the physical architecture by collapsing parallel data paths into a single-wire stream, drastically reducing microcontroller pin count, PCB trace routing complexity, and connector costs.

The Core Definition of a Mux and How It Actually Works

At the silicon level, a mux is built from an array of MOSFET transmission gates. When you apply a binary address to the select pins (often labeled S0, S1, S2), the internal logic decodes that address and turns on exactly one transmission gate, creating a low-resistance electrical path between the chosen input pin and the common output pin. All other paths remain high-impedance (disconnected).

Digital vs. Analog Muxes: A digital mux (like the 74HC151) is optimized to pass clean logic highs and lows, typically outputting a buffered, regenerated signal. An analog mux (like the 74HC4051) uses bidirectional CMOS switches that pass continuous voltage levels, meaning the signal can flow from input-to-output or output-to-input, but it introduces a small series resistance ($R_{on}$) and parasitic capacitance.

For a deeper look at the underlying logic gates that make digital multiplexing possible, the All About Circuits digital textbook chapter on multiplexers provides an excellent schematic breakdown of the internal AND/OR gate arrays.

Where You Meet This in Practice

You will rarely build a mux from discrete transistors; you will almost always use an integrated circuit. Here is where they show up on the bench:

  • ADC Expansion: Reading an array of 8 thermistors or potentiometers using a single Analog-to-Digital Converter (ADC) pin on a microcontroller.
  • I2C Bus Routing: Using an I2C mux (like the TCA9548A) to route the SDA/SCL lines to different sub-buses. This solves address collisions when you need to wire up five identical BME280 environmental sensors that all share the same hardcoded I2C address.
  • Programmable Gain Amplifiers: Switching different feedback resistors in an op-amp circuit to change the amplification stage on the fly.
  • Audio/Video Matrices: Routing multiple microphone inputs to a single recording track or mixing console channel.

Worked Numeric Example: Sizing an Analog Mux for an Op-Amp

The most common mistake hobbyists make with analog muxes is ignoring the on-resistance ($R_{on}$). Let us look at a worked numeric example where this ruins your circuit's accuracy.

Suppose you are building a programmable gain amplifier using an op-amp in a non-inverting configuration. The gain formula is $A = 1 + (R_f / R_g)$. You set $R_g = 1,000\Omega$. You want to switch between two gains using a 74HC4051 analog mux to select the feedback resistor ($R_f$):

  1. Gain of 10x: Requires $R_f = 9,000\Omega$.
  2. Gain of 100x: Requires $R_f = 99,000\Omega$.

According to the TI datasheet, the 74HC4051 has a typical $R_{on}$ of $80\Omega$ when powered at 5V. Because the mux sits in series with $R_f$, the actual resistance in the feedback loop is $R_f + R_{on}$.

Target GainIdeal $R_f$Actual Path ResistanceActual GainError
10x9,000 Ω9,080 Ω1 + (9080 / 1000) = 10.08x+0.8%
100x99,000 Ω99,080 Ω1 + (99080 / 1000) = 100.08x+0.08%

At a gain of 10x, the $80\Omega$ mux resistance introduces nearly a 1% error. If your application requires precision, you must either use a mux with a lower $R_{on}$ (like the ADG708, which boasts $<5\Omega$), or place the mux in a part of the circuit where it switches high-impedance nodes rather than low-impedance feedback loops.

Bench Scenario Walkthrough: When the Mux Fails the Signal

Here is a real-world debugging scenario that highlights the hidden parasitic properties of multiplexers.

The Setup: You are reading 16 high-impedance piezoelectric vibration sensors through two cascaded 74HC4051 muxes into a single ADC pin on an ESP32 DevKit v1. The sensors are modeled as high-value voltage dividers (two 1MΩ resistors), meaning the source impedance looking into the mux is roughly $500k\Omega$.

The Numbers: The 74HC4051 adds $80\Omega$ of series resistance. Total source resistance ($R_{source}$) = $500,080\Omega$. The ESP32's internal ADC sampling capacitor is roughly 15pF, and your breadboard adds about 50pF of stray capacitance. Total capacitance ($C_{total}$) = 65pF. The RC time constant ($\tau$) is $R \times C = 500,080 \times 65 \times 10^{-12} = 32.5\mu s$.

The Outcome: Your Arduino code cycles through the 16 mux channels and calls analogRead() immediately after changing the select pins. The serial monitor prints wildly fluctuating, noisy garbage data. Furthermore, the reading for Channel 2 seems to "lag" and mimic the voltage of Channel 1.

What Went Wrong: To achieve 12-bit ADC accuracy, the internal sampling capacitor must charge to within 1 LSB (Least Significant Bit) of the true voltage. This requires approximately $10.4\tau$. $10.4 \times 32.5\mu s = 338\mu s$. If your code switches the mux and reads the ADC 20\mu s later, the internal capacitor has barely begun to charge. It is reading a ghost voltage left over from the previous channel (hence the "lag" effect).

The Fix: You have two options. First, the software fix: add a delayMicroseconds(400); between toggling the mux select pins and calling analogRead(). Second, the hardware fix (preferred for high-speed sampling): lower the voltage divider resistors to 10kΩ, or place a unity-gain op-amp buffer between the mux output and the ESP32 ADC pin to provide a low-impedance drive. For more on ESP32 ADC quirks, consult the official Espressif ADC peripheral documentation.

Common Confusions: Mux vs. Demux vs. Decoder

Terminology in digital logic gets sloppy. Here is how to keep them straight when ordering parts:

  • Multiplexer (Mux): Many-to-one. It selects one of many inputs and sends it to a single output. (Data Selector).
  • Demultiplexer (Demux): One-to-many. It takes a single input and routes it to one of many outputs based on the select lines. (Data Distributor).
  • Decoder: Binary-to-one-hot. It takes a binary number (e.g., 011) and turns on exactly one corresponding output pin (e.g., pin 3 goes HIGH, all others LOW). Decoders (like the 74HC138) are frequently used to drive the select pins of larger mux arrays, but they do not pass the primary data signal themselves.

Frequently Asked Questions

Can I pass AC audio signals through a standard digital mux?
No. Digital muxes expect signals to be bounded between GND and VCC, and they will clip or distort AC waveforms that swing below ground. You must use an analog mux (like the 4051 series) and bias the AC audio signal at a DC offset (e.g., 2.5V on a 5V system) so the entire waveform stays within the mux's supply rails.

Do multiplexers draw a lot of current?
The quiescent current (the current the chip draws just sitting there) is negligible, often in the microamp range for CMOS parts. However, the dynamic current depends entirely on the load you connect to the output. The mux itself just acts as a pipe; whatever current the load demands must pass through the mux's internal MOSFETs. Always check the datasheet for the maximum continuous current per channel (typically 25mA to 50mA for standard 74HC logic).

What happens if I leave unused mux inputs floating?
On a digital mux, floating inputs can oscillate and cause excessive power draw and noise. Tie unused digital inputs to GND. On an analog mux, floating inputs can pick up EMI and capacitively couple into the active channel through the parasitic capacitance of the off-state switches. Tie unused analog inputs to GND through a 10kΩ resistor.