Demuxing (demultiplexing) is the process of taking a single digital input signal and routing it to exactly one of several output lines based on the binary state of selection pins. In a physical circuit, demuxing fundamentally changes your architecture by allowing a microcontroller with severely limited GPIO pins to control, address, or communicate with many distinct endpoints without requiring a dedicated physical wire for every single target. Think of a railway switchyard where a single incoming train track splits into eight destination tracks; the signal tower (select pins) dictates which specific switch aligns to send the train (the input signal) to exactly one destination, while the other seven tracks remain blocked.
The Core Mechanism: How a Demultiplexer Routes Signals
To understand demuxing on the bench, we look at the standard workhorse IC: the Texas Instruments SN74HC138 3-to-8 line decoder/demultiplexer. This chip features three select pins (A, B, C), three enable pins (G1, G2A, G2B), and eight active-LOW outputs (Y0 through Y7). While often sold as a 'decoder', tying your data stream to one of the enable pins converts it into a demultiplexer.
Assume VCC is 5.0V and we want to route a digital data stream into output Y5. First, we set the select pins to the binary equivalent of 5: C = HIGH (1), B = LOW (0), A = HIGH (1). Next, we tie our data signal to the G2A pin (which must be LOW to enable the chip). If the data stream on G2A pulses LOW, the internal logic gates pull the Y5 output LOW, while outputs Y0-Y4 and Y6-Y7 remain HIGH. The signal has been successfully demuxed to a single destination.
The critical specification to watch here is propagation delay ($t_{pd}$). For the 74HC138 at 5V, $t_{pd}$ is typically 14ns. If you are demuxing a high-speed SPI clock or a fast PWM signal, this 14ns skew between the select pins changing and the output stabilizing can cause transient glitches on the unselected lines if your timing margins are tight.
Demux vs. Mux vs. Decoder: Clearing Up the Confusion
When sourcing parts or reading schematics, engineers frequently conflate three distinct digital logic functions. Understanding what people commonly confuse demuxing with will save you from wiring up the wrong IC.
| Component | Directionality | Primary Function | Common Part Number |
|---|---|---|---|
| Demultiplexer (Demux) | 1 Input $ ightarrow$ Many Outputs | Routes a single continuous data stream to one selected destination. | 74HC138, 74HC154 |
| Multiplexer (Mux) | Many Inputs $ ightarrow$ 1 Output | Selects one of many input signals to pass through to a single line (e.g., reading 8 sensors on 1 ADC pin). | 74HC4051, 74HC151 |
| Decoder | Binary Input $ ightarrow$ One-Hot Output | Converts a binary address into a single active line. No continuous 'data' input is routed; it just asserts a state. | 74HC42, 74HC138* |
*Note: As mentioned, a decoder with an enable pin (like the 74HC138) functions as a demux when the data stream is fed into the enable pin rather than the select pins.
Where You Meet Demuxing in Practice
You will rarely see a demux labeled explicitly as 'the demuxer' on a modern schematic, but the topology is everywhere in embedded systems and digital design:
- Memory Addressing: Selecting specific SRAM or EEPROM chips on a parallel bus. The microcontroller sends a binary address to the select pins, and the demux asserts the Chip Enable (CE) pin on exactly one memory module.
- SPI Chip Select Routing: If your microcontroller only has two free GPIO pins but you need to talk to eight SPI sensors, a 2-to-4 or 3-to-8 demux expands your Chip Select (CS) lines without consuming more MCU pins.
- LED Matrix Scanning: Sinking current through the columns of a large LED matrix. The row drivers provide the data, while a demux selects which column is currently grounded to complete the circuit.
- Interrupt Routing: Funneling a single hardware interrupt pin on a microcontroller to one of several external peripheral alert lines, depending on the current system state.
Bench Scenario: Routing One PWM Signal to Eight Motor Drivers
Abstract theory only gets you so far. Here is a real-world walkthrough of a bench project where demuxing solved a pin-shortage problem, but introduced a subtle logic inversion bug.
- The Setup: We are using an Arduino Nano (ATmega328P) to control eight separate DC motors via TB6612FNG dual motor drivers. We want independent speed control, but only one motor will run at a time. To save GPIO pins, we route a single 490Hz PWM signal from Arduino Pin 5 into the G2A pin of a 74HC138 demux. The eight Y-outputs connect to the PWMA pins of the motor drivers.
- The Numbers: The 74HC138 operates at 5V logic. The Arduino outputs a 5V PWM signal. The TB6612FNG PWMA pin requires a 0-5V active-HIGH signal to dictate duty cycle (0V = 0% speed, 5V = 100% speed). We set the select pins to binary 3 (C=0, B=1, A=1) to target Motor 3.
- The Outcome: We call
analogWrite(5, 127)for a 50% duty cycle. Motor 3 spins up to roughly half speed. The other seven motors remain perfectly still. The demux is successfully routing the signal. - What Went Wrong: When we changed the code to
analogWrite(5, 25)(expecting 10% speed for a slow crawl), Motor 3 violently spun up to 90% speed. The culprit? The 74HC138 outputs are active-LOW. When unselected, the Y pins sit HIGH (which correctly disables the TB6612FNG). But when selected, the Y pin outputs the inverse of the G2A input. Our 10% HIGH PWM signal was inverted into a 90% HIGH PWM signal by the demux. The fix was simple: invert the logic in software usinganalogWrite(5, 255 - speed), or add a 74HC04 hex inverter on the breadboard.
Frequently Asked Questions
Can I use a digital demux to route analog audio or sensor signals?
No. Standard logic demuxes like the 74HC138 will clip and distort analog waveforms because they rely on digital threshold voltages (VIL/VIH). To demux analog signals (like routing a single audio source to multiple amplifiers, or one ADC to multiple thermistors), you must use an analog multiplexer/demuxer with pass-transistors, such as the CD4051 or 74HC4051, which pass continuous voltage levels up to their VCC rail.
Does demuxing introduce latency that affects high-speed protocols?
Yes, but usually negligibly for hobbyist speeds. A standard 74HC-series demux adds about 14ns to 20ns of propagation delay. For I2C (400kHz) or standard SPI (up to 10MHz), this delay is invisible. However, if you are demuxing a 50MHz SPI clock line, that 14ns delay represents a massive 70% phase shift, which will cause data corruption. For high-speed clocks, use dedicated high-speed bus switches (like the SN74CB3Q3245) rather than standard logic demuxes.
What happens to the unselected outputs on a demux?
On an active-LOW demux (like the 74HC138), all unselected outputs remain HIGH. On an active-HIGH demux (like the 74HC154), all unselected outputs remain LOW. Always check the datasheet's truth table to ensure the 'idle' state of the unselected outputs matches the 'disable' or 'safe' state of the target components you are driving.






