Microcontroller Tips

Microcontroller engineering resources, new microcontroller products and electronics engineering news

  • Products
    • 8-bit
    • 16-bit
    • 32-bit
    • 64-bit
  • Applications
    • Automotive
    • Connectivity
    • Consumer Electronics
    • Industrial
    • Medical
    • Security
  • EE Forums
    • EDABoard.com
    • Electro-Tech-Online.com
  • Videos
    • TI Microcontroller Videos
  • EE Resources
    • DesignFast
    • eBooks / Tech Tips
    • FAQs
    • LEAP Awards
    • Podcasts
    • Webinars
    • White Papers
  • EE Classrooms
    • Grid Infrastructure
    • Aerospace & Defense
    • Building Automation
    • Power Delivery
    • Factory Automation
    • Motor Drives
    • Medical Technology

DEMUX, MUX, and Decoders: How To Expand I/O

September 6, 2017 By Mike Parks 1 Comment

The relentless march of technological progress has given engineers increasingly smaller and more energy efficient microcontrollers to use in their designs. These benefits do come with a cost, however. Physically smaller packages have less room for I/O pins meaning fewer peripheral components can interface with the microcontroller itself. Fewer peripherals means less functionality which tends not to be a desirable tradeoff.

Even when utilizing bus-based protocols such as I2C or SPI, there is often a need for each external integrated circuit to have a pin dedicated for chip select or output enable (often notated as CS or OE on schematics, or /CS and /OE for active low variations). After accounting for power, ground, reset, and the I2C pins on a small 8-pin chip like an ATtiny85, a design might at most interface with three external peripherals using the remaining I/O pins. Of course, one option would be to explore larger chips within the same microcontroller family. Depending on component availability or design constraints this might not be a possible option. Another possibility is to incorporate an additional circuit that sits between the microcontroller and the various external components. Circuits such as multiplexers, demultiplexers, and decoders come in a variety of packages and voltage levels so they can be incorporated into a board layout with relative ease.

Figure 1A: Demultiplexer can route a data output pin to different components based on address pins. Figure 1B: A decoder takes address pins as inputs and raises the corresponding pin to a logic high. Figure 1C: A multiplexer takes inputs from multiple devices, selected using the microcontrollers address pins, and routes the desired components output to a single input pin on the microcontroller.

With a demultiplexer we can take two of the microcontroller’s I/O pins and turn them into address pins (for example A1 and A0). The third pin serves as a digital output whose signal then can be redirected to up to four external peripheral components by toggling the address pins into one of four states including < A1:A0 > = 00, 01, 10, and 11.

If there is no need for a controllable output signal then it might be more desirable to instead use a decoder. With a decoder those same three pins (the two address pins and the digital output pin) could be instead used to interface with eight peripheral components thanks to the power of binary arithmetic (23 = 8). This is extremely useful in situations such as handling chip select or output enable pins of external ICs where those pins only need to drive to the source voltage or ground. Inverters can be placed on the output of the active high decoders to handle chips that required active low enables. Practically speaking 2:4 and 3:8 decoders are most common in discrete packages. However, it is possible to cascade multiple discrete decoders into larger networks as needed. Be careful not to go too large as problems may arise from fan-in and fan-out. Issues that could arise include slowed response times or even voltage levels dropping below defined logic levels.

Lastly, it is also possible to employ a similar concept for inputs being fed into a microcontroller from external devices such as sensors or switches. Instead of a demultiplexer, a multiplexer can be employed to funnel multiple outputs into a single input pin. Special care must be placed by the firmware designer to ensure the logic is correct when handling the different inputs and the associated variables that represent them in code. Be aware that decoder, multiplexer, and demultiplexer chips may have output enable (OE) pins themselves. Depending on the circuit design these pins can be hardwired to ground or source voltage so a microcontroller pin need not be used. The tradeoff being the chip is always on which may or may not be desired. Otherwise, a microcontroller pin must be budgeted for in the design.

Filed Under: FAQ, Featured, Industry Experts, microcontroller Tagged With: basics, FAQ

Comments

  1. Jose Ortiz says

    May 17, 2019 at 4:39 pm

    I would add shift registers to the list. Cheap 74HC595 chips or development boards, for example.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

DesignFast

Component Selection Made Simple.

Try it Today
design fast globle

EE Training Center Classrooms

“ee
“ee

Subscribe to our Newsletter

Subscribe to weekly industry news, new product innovations and more.

Subscribe today

RSS Current EDABoard.com discussions

  • Slotted waveguide antenna
  • explanation about bram and ddr3
  • CMOS Fabrication process in 80s and 90s
  • Tracking Phase comparator Logic
  • Including geometric variation of transistors using Montecarlo simulation in Cadence

RSS Current Electro-Tech-Online.com Discussions

  • SIM800 Module stops registering after a few days
  • Funny Images Thread!
  • Transformer
  • Car Steering Wheel Audio Controls Board - Custom DIY
  • 12 Hour Digital Clock Project Help

Follow us on Twitter

Tweets by MicroContrlTips
Microcontroller Tips

EE World Online Network

  • DesignFast
  • EE World Online
  • EDA Board Forums
  • Electro Tech Online Forums
  • Connector Tips
  • Analog IC Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • Wire and Cable Tips
  • 5G Technology World

Microcontroller Tips

  • Subscribe to our newsletter
  • Advertise with us
  • Contact us
  • About us
Follow us on Twitter@MicroContrlTips
Add us on FacebookEE World Online
Follow us on YouTube YouTube
Follow us on Instagram Instagram

Copyright © 2019 · WTWH Media LLC and its licensors. All rights reserved.
The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media.

Privacy Policy