I have found that a wide variety of designs present a legitimate need for I/O expansion. Some people might be inclined to think that I/O expansion parts are somewhat outdated or simply unnecessary, but in my opinion that’s really not the case.
When to Use an I/O Expander
It’s true that nowadays engineers have access to an enormous variety of microcontrollers and FPGAs, and in many cases it makes sense to simply choose a device that has an adequate supply of input/output pins. On the other hand, there are certain situations in which you should consider using an I/O expansion part:
- Sometimes you really cannot find a microcontroller or FPGA with enough pins. If the system needs to monitor numerous sensors or input devices, an IC that is specifically designed for I/O expansion is a straightforward solution.
The BD3376MUV-M from ROHM is an I/O expansion IC that is intended for monitoring pushbuttons.
- I highly recommend that you limit your designs to a small number of microcontrollers (preferably from the same manufacturer). I realize that a limitation like this is not always practical, but it’s a good objective to keep in mind, because it accelerates board design, simplifies the development process, and reduces the number of (sometimes maddening) firmware bugs that must be sorted out. If the only thing that is preventing you from using one of your standard microcontrollers is the required I/O count, I suggest that you consider an I/O expander before you start reading the datasheet of an unfamiliar processor.
- An I/O expander is also a simple and low-risk way to incorporate additional I/O functionality into an existing design. When I have a PCB that works exactly the way I want it to, I prefer to make as few changes as possible when it comes time to create version 2. This means that I might add an I/O expansion device rather than replace the original microcontroller or FPGA with a higher-pin-count variant.
I/O Expansion Techniques
An “old-fashioned” but by no means obsolete approach to output expansion is a digital device called a decoder. The input to a decoder is an input code, that is, a group of digital signals that represent a number. The decoder converts this number into a logic-high signal that appears on only one of several output pins. This allows, for example, 4 coded signals to control 16 output pins.
This is a diagram of a 2-to-4 decoder, adapted from this image created by BlueJester0101.
An encoder performs the reverse operation and therefore can be used for input expansion.
A more complicated, but also more versatile, approach is to use an FPGA or a CPLD as a customized I/O expansion device. This idea might have some merit in certain applications, though I suspect that in most cases it would be better to use an off-the-shelf I/O expansion IC.
This 16-bit I/O expander from Diodes Incorporated offers an interesting collection of features. The board’s microcontroller or FPGA reads and writes the additional I/O pins via an I2C interface, such that two I/O pins from the processor provide access to 16 I/O pins on the expander chip.
Diagram taken from the PI4IOE5V6416 datasheet.
Also, the PI4IOE5V6416 has a pin that allows you to choose between one of two I2C slave addresses, which means that you can place two of these ICs on the same I2C bus and thereby control 32 additional I/O pins using the two I2C signals.
The PI4IOE5V6416 integrates logic-level translation into its I/O expansion functionality. There are two separate supply-voltage pins, one for the I2C interface and one for the GPIO signals, and both support a VDD range extending from 1.65 V to 5.5 V. This is a handy feature, and it makes the PI4IOE5V6416 a good choice for applications in which additional I/O capability must be incorporated into a legacy design.
An external hardware interrupt allows a microcontroller to vector to an interrupt service routine in response to some sort of voltage change on an input pin. These types of interrupts are a good way to improve the quality of your code, and the PI4IOE5V6416 allows you to expand not only your I/O capacity but also your hardware-interrupt capacity: it includes an active-low output signal that can be used to notify the processor whenever there is a change in the logic level applied to one of the device’s I/O pins (this occurs only if the pin is configured as an input).
Have you ever decided to use an I/O expander instead of a higher-pin-count microcontroller or FPGA? If you have any part recommendations, feel free to let us know in the comments section below.