![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|
Custom Search
Readers
comments
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Digital I/O ExpansionHow to expand your interfaces using digital I/O using serial techniques.You are probably here because you have a problem either - you have just run out of pins and need to add more functions to your microcontroller or the I/O you need is far more than the number of pins available on your microcontroller. The way to add more functions to a pin limited system is to use serial communication. As long as you have at least one pin available all is not lost. There are several methods and each has different tradeoffs. Here is a list of possible methods, in order of the number of pins needed (excluding ground), but not in any other particular order of importance.
Digital I/O expansion: RS232Perhaps the most unusual one is the RS232 serial comms method - for one way communication you only need one wire. You won't need a level translator if you just communicate between two chips on the same board and because it will be over a short distance you can run it fast.The best way to use it is with the built in UART in each microcontroller but you could use a software version if absolutely necessary. You can find more information by clicking the following links for RS232 pinouts, usage and details. Using the built in USART is easy and this method gives you a good communication system between two microcontrollers but you do need a microcontroller at the receiving side and so this is a more complex solution (You also have to decide on the command set and how that operates). Digital I/O expansion: Dallas 1 wireThis is a proprietary communication system created by Dallas Semiconductor (part of Maxim www.maxim-ic.com). Each device has a unique laser engraved address etched into it so that you can put multiple devices on the same wire network. It uses a single bus master (your microcontroller) to control all slave devices and is powered by the driving signal (you can add circuitry to provide additional power at the device).Typical devices you can use include:
Note this is not the full list - there are lots more devices! Although you might think that the 1 wire system is for long distance control and measurement you can use it in a single board and you can use 100s of devices on the same wire network. Digital I/O expansion: Johnson counterOne chip I like to use for very simple I/O expansion is the 74HC4017 original the CMOS version but also available in HC etc. It is a Johnson counter that sequentially turns on one of 10 outputs. All you need to drive it is two controls reset and clock. It does not have a lot of output current drive so you may need transistors to provide more current.Its is a useful chip for multiplexing seven segment displays. Digital I/O expansion: Serial to parallel/parallel to serial chipsYou can use the discrete chips 74HC595 (serial in and 8 bit parallel out) and 75HC165 (8 bit parallel in and serial out). All you need for each type is 3 controls:latch (to get or set stable data), reset and clock.The advantage of these two devices over simple shift registers e.g. 4094 is that the latch control signal loads data from the internal shift register to the outputs. This separates the output signals (595) from the shift register so you can setup all the serial data, clocking it into the device without changing the outputs. When you are ready you latch the data through to the output using the latch control signal. This ensures that the data never changes until you are ready for it to change and a similar operation happens for the parallel to serial device. Note: You can easily cascade these devices to provide more I/O using the same set of controls. Digital I/O expansion: I2CThis is one of the more flexible ways of interfacing using only two pins and the most important point is that it gives data transmission in both directions to/from slave devices. The SPI protocol does this in a more limited way.You can add devices onto the bus limited by the addressing scheme ~120 devices and the capacitance that each device adds to the total capacitance. Addresses are fixed for manufacturers and device family and some have extra pins to set the lower address range e.g. for extra serial EEPROMS of the same type. For more information on I2C click here.
Note: There are many more I2C devices! Digital I/O expansion: SPIThis is the Serial Peripheral Interface using 4 wires (3 if data is only sent in one direction). It is basically a shift register based protocol - (because of this it can run fast). For more information on SPI click here.
Note: There are many more SPI devices! I/O port expansion : Summary and a look at speed issuesThe SPI interface is the fastest (>10MHz) but uses the most pins while an I2C interface is medium speed (100kHz-400kHz) and RS232 is the slowest. RS232 uses two pins for communication in both directions but if you need only transmit data to a peripheral then you can use one pin.Digital I/O expander : speed
Jump from digital I/O to Best Microcontroller Projects Home page |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||