Digital IO Expansion
By: John Main
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.
There is more detailed information on the website here and how to build a website like it here.
Copyright ? John Main 2006 |
