A multiplexer (often abbreviated as MUX) is an electronic switching circuit that selects one of several analog or digital input signals and forwards it to a single output line based on a binary control code. In a real circuit or microcontroller installation, a multiplexer fundamentally changes your hardware architecture by drastically reducing the number of physical wires, traces, or GPIO pins required to read multiple sensors or route parallel data. Instead of dedicating eight separate microcontroller pins to read eight digital switches, a MUX allows you to read all eight using just four pins (three for selection, one for reading).

The Core Definition and Common Circuit Confusions

To understand the definition of a multiplexer in physical terms, think of the input selector on a home AV receiver. You have multiple sources (HDMI 1, HDMI 2, Optical, Bluetooth) but only one set of speakers. The receiver's internal switching matrix routes the single selected audio stream to the output based on the button you press on the remote. In silicon, a MUX does exactly this with voltage levels or data streams, using logic gates or transmission gates controlled by binary address pins.

Common Confusions: MUX vs. DEMUX vs. Encoder
  • Multiplexer (MUX): Many inputs to one output. (Data routing / selection).
  • Demultiplexer (DEMUX): One input to many outputs. (Data distribution / decoding).
  • Encoder: Many inputs to a binary code output. An encoder does not route the actual data signal; it merely outputs a binary number representing which input line is currently active (e.g., a priority encoder).

When designing with Texas Instruments signal switches and multiplexers or similar logic families, it is critical to distinguish between digital multiplexers (which pass discrete logic HIGH/LOW states) and analog multiplexers (which pass continuous voltage waveforms using internal MOSFET transmission gates). Using a digital MUX for an analog audio or sensor signal will clip your waveform and destroy the data.

Reference Table: Common Multiplexer ICs and Specifications

Selecting the right IC depends on whether you are routing logic levels, analog sensor voltages, or digital communication buses. Below is a specification matrix of the most common MUX ICs you will encounter on the bench.

IC Part Number Type Configuration VCC Range Key Characteristic / Typical Application
74HC157 Digital Quad 2-to-1 2.0V - 6.0V ALU data routing, switching between two 4-bit data sources
74HC151 Digital 8-to-1 2.0V - 6.0V Logic function generation, parallel-to-serial conversion
CD4051B Analog 8-to-1 3.0V - 15V Audio routing, low-speed sensor switching (High $R_{ON}$ ~120Ω)
CD74HC4067 Analog 16-to-1 2.0V - 6.0V Large analog sensor arrays, battery voltage monitoring
TCA9548A I2C Bus 8-channel 1.65V - 5.5V Resolving I2C address collisions on a single master bus

Worked Numeric Example: Routing with a 74HC151 8-to-1 MUX

Let's look at a concrete numeric example using the 74HC151 8-to-1 digital multiplexer. This IC has eight data inputs ($D_0$ through $D_7$), three select inputs ($S_0, S_1, S_2$), and one output ($Y$). It also features an active-low Enable pin ($\overline{E}$).

Target State: Route the signal from input pin $D_5$ to the output $Y$.

Step 1: Determine the Select Binary Code
To select $D_5$, we need the binary equivalent of the decimal number 5.
Decimal 5 = Binary 101.
Therefore, our select pins must be set to: $S_2 = 1$ (HIGH), $S_1 = 0$ (LOW), $S_0 = 1$ (HIGH).

Step 2: Set the Enable Pin
The $\overline{E}$ pin is active-low. To turn the MUX on, this pin must be tied to GND (0V). If it is pulled HIGH, the output $Y$ is forced LOW regardless of the select pins, and the complementary output $\overline{W}$ is forced HIGH.

Step 3: Signal Propagation and Timing
Assume we are running the 74HC151 at a $V_{CC}$ of 5.0V. According to the standard digital logic characteristics, when $S_2, S_1, S_0$ are set to 101, the internal AND/OR gate matrix connects $D_5$ to $Y$. If the signal at $D_5$ transitions from LOW to HIGH, the output $Y$ will reflect this change after a typical propagation delay ($t_{pd}$) of roughly 18 nanoseconds. If you are multiplexing a 20 MHz clock signal (50ns period), this 18ns delay introduces significant phase skew that must be accounted for in your timing margins.

Where You Meet Multiplexers in Practice

You will rarely use a MUX just to save a single wire on a breadboard. In modern embedded systems and power electronics, multiplexers solve specific architectural bottlenecks.

1. Resolving I2C Address Collisions (TCA9548A)

Suppose you are building an environmental monitoring array using four BME280 sensors. The BME280 only supports two I2C addresses (0x76 and 0x77). You cannot put four of them on the same ESP32 I2C bus. By wiring a TCA9548A I2C multiplexer between the ESP32 and the sensors, the ESP32 sends a command to the MUX to open "Channel 0", talks to the first BME280, closes Channel 0, opens "Channel 1", and repeats. Adafruit's TCA9548A guide highlights a critical wiring detail: you must include I2C pull-up resistors (typically 4.7kΩ) on both the master side and every downstream channel, or the bus will float when the MUX switches.

2. Reading Analog Sensor Arrays (CD74HC4067)

If you need to read 16 analog soil moisture sensors but your Arduino Mega only has 16 ADC pins (and you need some for other tasks), a CD74HC4067 16-channel analog MUX routes all 16 sensors to a single ADC pin (e.g., A0) using 4 digital select pins.

Bench Warning: Analog MUX On-Resistance ($R_{ON}$)

Analog multiplexers are not perfect short circuits. The internal MOSFETs have an "on-resistance" ($R_{ON}$). For a CD4051B at 5V, $R_{ON}$ is roughly 120Ω. If your sensor has a high output impedance (like a high-resistance voltage divider for a thermistor), this 120Ω adds to your source impedance. When the microcontroller's ADC samples the voltage, its internal sampling capacitor must charge through this combined resistance. If the resistance is too high, the capacitor won't charge fully within the ADC's acquisition time, resulting in ghosting (where the current reading is skewed by the previous channel's voltage). Fix: Add a 100nF ceramic capacitor between the MUX output (SIG) and GND to act as a local charge reservoir, or increase the ADC sampling delay in your firmware.

Frequently Asked Questions

Can I cascade multiplexers to get more channels?
Yes. You can wire the outputs of eight 8-to-1 MUX ICs into a ninth 8-to-1 MUX to create a 64-to-1 multiplexer. However, be aware that the propagation delay and on-resistance will stack, which can degrade high-speed digital signals or introduce severe voltage droop in precision analog circuits.

What happens to the unselected inputs in a digital MUX?
They are electrically disconnected from the output by the internal logic gates. However, you should never leave unused digital inputs floating on a CMOS IC (like the 74HC series). Floating pins act as antennas, picking up EMI and causing the internal transistors to oscillate, which drastically increases power consumption and heat. Always tie unused inputs to GND or VCC.

Is a multiplexer the same as a solid-state relay? No. While both switch signals, a solid-state relay (SSR) is designed to switch high-current or high-voltage loads (like 120V AC mains or 30A DC heaters) using optical isolation. A multiplexer is strictly a low-voltage, low-current signal router designed for data and logic-level sensor voltages.