Muxing, or multiplexing, is the technique of routing multiple input signals through a single output line or channel to save wiring, pins, and bandwidth. When you design a circuit with dozens of sensors but your microcontroller only has a handful of analog-to-digital converter (ADC) pins, muxing is the hardware bridge that makes the physical layout possible without upgrading to a more expensive, higher-pin-count processor.

The Core Mechanics: What Muxing Changes in a Circuit

At its core, a multiplexer (mux) is a digitally controlled analog or digital switch array. It takes n input lines and routes exactly one of them to a single output line based on the binary state of its select pins.

Think of a multimeter’s rotary dial. You have multiple measurement jacks (inputs), but only one internal metering circuit (output). The dial (select pins) routes the specific jack you want to measure to the internal meter. In a PCB or breadboard circuit, a silicon mux does this electronically at microsecond speeds.

What it changes in your installation: Muxing drastically reduces trace routing complexity and microcontroller pin requirements. However, it introduces three electrical compromises you must design around:

  • On-Resistance ($R_{ON}$): The internal MOSFET switches are not perfect short circuits; they add series resistance.
  • Charge Injection: Switching channels injects a tiny spike of charge into the output line, which can corrupt sensitive analog readings.
  • Propagation Delay: It takes nanoseconds to microseconds for the signal to stabilize after changing the select pins.
Bench Tip: Never route high-frequency RF or precision low-level thermocouple signals through a standard CMOS multiplexer without checking the datasheet's charge injection and $R_{ON}$ flatness specifications. For precision DC, you need specialized low-charge-injection muxes like the Analog Devices ADG708.

Worked Numeric Example: Expanding Arduino ADC Pins

Let’s say you are building a 3D printer heated bed and need to monitor 16 NTC thermistors for thermal runaway protection. An Arduino Nano only has 8 ADC pins (A0-A7), and you need A4/A5 for your I2C display, leaving just 6 usable analog pins. You cannot wire 16 sensors directly.

Instead, you use two TI CD4051B (or Nexperia 74HC4051) 8-channel analog multiplexers. Here is the pin math:

Signal TypePins RequiredNotes
Select Pins (S0, S1, S2)3Shared in parallel between both mux ICs.
Enable/Chip Select2One GPIO per mux to activate it independently.
Analog Output (Z)2One output from each mux routed to Arduino A0 and A1.
Total MCU Pins Used7Reads all 16 sensors sequentially.

Pin savings: 9 GPIO/ADC pins reclaimed. You successfully read 16 analog channels using only 7 microcontroller pins.

The Hidden Cost: $R_{ON}$ and ADC Settling Time

The CD4051B costs about $0.20, but its internal on-resistance ($R_{ON}$) is typically 120Ω at $V_{CC} = 5V$. If your thermistor voltage divider uses a 10kΩ pull-down resistor, the 120Ω adds a ~1.2% voltage drop error. You can calibrate this out in firmware, but the timing is where most hobbyists fail.

The Arduino's internal ADC sample-and-hold capacitor is roughly 14pF. When you switch the mux to a new channel, the 10kΩ source impedance plus the 120Ω $R_{ON}$ forms an RC low-pass filter. The time constant ($\tau = R \times C$) is roughly $10,120\Omega \times 14\text{pF} = 141\text{ns}$. To settle to 10-bit accuracy (about 7 time constants), you need roughly 1µs. If you call analogRead() immediately after toggling the mux select pins, you will read the ghost voltage of the previous channel. Always insert a delayMicroseconds(5); after switching mux pins before sampling.

Where You Meet Muxing in Practice

Multiplexing isn't just for analog sensors; it is foundational to modern digital electronics and display routing.

  • LED Matrices and Keyboards: An 8x8 LED matrix has 64 LEDs. Wiring them individually requires 64 pins. By muxing them into an 8-row by 8-column grid, you only need 16 pins. The microcontroller rapidly scans (muxes) one row at a time, relying on persistence of vision to make the image look solid.
  • I2C Bus Collisions: If you buy three identical I2C OLED displays or BME280 sensors, they often share the same hardcoded I2C address (e.g., 0x3C). You cannot put them on the same bus. You solve this by using an I2C multiplexer like the TCA9548A, which creates 8 virtual I2C sub-buses, allowing you to talk to each sensor independently.
  • Audio Routing: In mixing consoles and software-defined radios, analog audio muxes route different instrument inputs to a single DSP or ADC chain without requiring a dedicated converter for every single channel.

Common Confusions: What Muxing Is Not

When sourcing parts or reading schematics, it is easy to confuse a multiplexer with other signal-routing ICs. Here is what people commonly get wrong:

Muxing vs. Demultiplexing (Demuxing): A mux is "many-to-one" (selecting one of many inputs to send to a single output). A demux is "one-to-many" (taking a single input and routing it to one of many outputs). They are often housed in the same physical silicon (like the 74HC4051), but the signal flow direction is reversed.

Muxing vs. Shift Registers: A 74HC595 shift register is often used to expand digital outputs, but it is not a multiplexer. A shift register converts serial data into parallel latched states (all outputs can be active simultaneously). A digital mux like the 74HC151 only routes one signal at a time; it does not store state.

Analog Mux vs. Digital Mux: A digital multiplexer (like the 74HC151) only passes logic HIGH and LOW voltages. It will clip and distort an analog sine wave. An analog multiplexer (like the CD4051B) uses transmission gates (parallel NMOS and PMOS transistors) to pass continuous voltage levels within the supply rails.

Frequently Asked Questions

What is the difference between a multiplexer and a demultiplexer?

A multiplexer (mux) selects one signal from multiple inputs and routes it to a single output line, acting like a digital rotary switch. A demultiplexer (demux) takes a single input signal and routes it to one of multiple output lines based on binary select pins. In data transmission, a mux compresses parallel data into a serial stream, and a demux unpacks that serial stream back into parallel data at the receiving end.

How does analog muxing affect ADC resolution and sampling rate?

Analog muxing introduces on-resistance ($R_{ON}$) and parasitic capacitance, which creates an RC filter that slows down the signal's settling time. If your microcontroller samples the ADC before the voltage fully settles through the mux, you lose effective resolution and get crosstalk from the previously selected channel. To maintain full 12-bit or 16-bit ADC resolution, you must either add a small software delay between channel switches, use an external op-amp buffer at the mux output, or select a premium low-$R_{ON}$ multiplexer.

Can I use a standard digital multiplexer for analog audio signals?

No. Standard digital multiplexers (like the 74HC151 or 74LS151) are designed to interpret voltages strictly as logic 1s and 0s. If you feed a 1V peak-to-peak audio sine wave into a digital mux, the output will be a distorted, clipped square wave. For audio, you must use an analog multiplexer (like the CD4051B for general purpose, or a dedicated audio mux like the TI TS3A24159 which offers ultra-low total harmonic distortion (THD) and flat $R_{ON}$ across the audio band).

What is I2C muxing and when do I need a TCA9548A?

I2C muxing is the process of splitting a single I2C hardware bus into multiple isolated sub-buses to bypass address collisions. You need a dedicated I2C multiplexer IC like the NXP TCA9548A when your circuit requires multiple identical sensors or displays that share the same hardcoded I2C address and lack hardware pins to change that address. The TCA9548A sits on the main bus and acts as a traffic cop, opening a connection to only one sub-bus at a time, tricking the microcontroller into thinking it is only talking to one device.