When working through practice boards and schematics very early on in my education, I remember more than once thinking about simply increasing the board size so that I could fit my components properly and make routing easier. It definitely would not have helped, and I’m glad I persevered in finding solutions through the challenges, but there are still times in my career where I’ve looked at the necessities of devices and wished I could just make their boards bigger.
The same applies for microcontroller input and output. Unfortunately, there’s no belt to loosen when a microcontroller hits its input or output limit. In applications where you need to interface with a number of sensors and solenoids, the input/output (I/O) pins may be insufficient. In such situations, there are a number of options available, each with its own set of implications.
I/O pins in a microcontroller are often grouped in ports. A single port may consist of 8 to 32 individual I/O pins, depending on the microcontroller architecture. Upgrading the microcontroller to a higher pin count seems like the simplest solution. However, choosing a higher pin-count microcontroller usually involves increased component costs. Furthermore, depending on the type of migration, the underlying firmware may be greatly affected.
I/O pin varies with different microcontrollers.
When upgrading within the same family of microcontrollers, firmware modifications are minor or unnecessary. However, an upgrade from an 8-bit microcontroller( like the PIC18F25K20) to a 32-bit ARM-based microcontroller (like the LPC1768) involves coding the firmware for an entirely different architecture with a separate set of development tools.
In general, 32-bit microcontrollers cost several times more than 8-bit microcontrollers. Therefore, upgrading simply for the sake of more I/O pins may be an overkill.
To avoid porting your firmware to an entirely new platform, there are a few integrated circuit (IC) options in the 7400 series logic family that are excellent for I/O expansion. For instance, the 74HC4051 is a 3:8 CMOS multiplexer/demultiplexer that can also be used for analog signals. Of course, using multiplexers does not entirely solve the problem of limited I/O pin on the microcontroller, as every single IC would occupy 3 pins.
TPIC6C595 open drain output shift registers in cascade connection.
A more elegant solution is to use serial clocking shift registers like the 74HC595 for output and 74HC165 for input. These ICs can be cascaded to each other with the limitation being the latency to shift the bytes to all the ICs. Using shift registers only involves three I/O pins on the microcontroller, regardless of the number of ICs.
You can also use I2C expansion GPIO chip to increase the limit of I/O pins on the PCB. As the name implies, the microcontroller interfaces with the expander chip using I2C protocol. The advantage of using an I2C expander is the ability to configure individual pins as input or output using the provided command.
You can also connect multiple I2C expanders by setting the hardware address pin to a unique address on each IC. I2C expanders usually have special interrupt functions where an interrupt can be generated if the input pin changes from its previous state. The microcontroller polls the I2C expander for the new input values only when the interrupt is triggered.
In a way, the interrupt driven polling method is more efficient than constantly shifting the values from cascaded shift registers to check value changes.
Both cascaded shift registers and I2C expanders required clock and data signals between the microcontroller and IC. It is important for interfacing signals to be routed closed to each other with equal lengths to prevent glitches from occurring in the clocking signal. The traces should also be kept away from other high-speed signals to prevent cross-coupling issues.
You can use multiple net routing features in Altium Designer® to ensure the connections are positioned in accordance with the best practices. Not sure what’s the best option for your I/O pin constrained design? Talk to an expert at Altium.