Digital I/O expansion.
If you have run out of digital I/O pins because you are updating an
older design or
there simply are not enough pins to add the functions you need then the
way to increase I/O is to use a serial interface.
There are several serial interfaces to choose from:
I2C (2 wires).
SPI (3-4 wires).
Dallas 1 wire (1 wire).
Johnson counter (2 wire).
Discrete Serial to parallel (3 wires, 6 for RX & TX).
RS232 (1-2 wires).
Note: Number
of wires excludes ground.
Each has its own advantages and disadvantages:
RS232
Using an RS232 interface or a software encoded UART is the most unusual
method but it gives a robust communication method and if you transmit
data in one direction it only needs 1 wire (but you need a UART to
receive either a discrete UART or a microcontroller with built in UART).
Johnson
counter
The Johnson counter 4017 (74HC4017) is a useful little chip that turns
on each output after each clock edge but it is limited to 10 outputs.
Serial to
parallel (& vice versa)
This method uses discrete chips 74HC595 (serial in
and 8 bit parallel
out) and 75HC165
(8 bit parallel in and serial out) and these can be daisy changed
indefinitely. The only problem is that you need 6 pins to use
both at the same time. (you may be able to multiplex the clock and
latch pins to share between them saving 2 pins).
SPI, I2C,
Dallas 1 wire
The three other interfaces are more complicated but still very useful
for digital I/O expansion. To use them you have to choose
devices that use the same interface protocol (that you generate from
the microcontroller).
Note: There
are many device to choose from for each type of protocol e.g. digital
pot, ADC, EEPROM etc.
I2C and SPI are supported by newer PIC chips so they can run quite fast
using the internal module (SSP or MSSP) whereas the Dallas 1 wire
system is encoded in software.
The best thing about the Dallas 1 wire system is that
you can used it over long distances whereas the other two are
intended for use within a unit (I2C) or on the same board (SPI).
Note: If you
need to add a keypad or LCD you could use I2C (using a PIC chip e.g.
16F88) on a separate board.
Copyright © John Main 2006
Free to distribute if the article is kept complete.
http://www.best-microcontroller-projects.com
Jump from Digital I/O expansion
page
to Best Microcontroller Projects home page
|