[Circuitsville logo]
[ Home ] [ Services ] [ Anadigm ] Micro Controllers [ Contact ] [ About ] [ Links ] [ Atmel Microcontroller & Arduino Hardware  ] [ Applications for Arduino - Real Time Clock ] [ Applications for Arduino - Pseudo Random Numbers ] [ Applications for Arduino - Extended Input/Output ] [ Arduino Shield Starter Templates ] [ ] [ ]


Extending the Outputs of a Microcontroller

There are several places on the web, including the Circuitsville Blog, that discuss using the 74HC595 or similar circuits to extend the Output capability of any microcontroller. There are other circuits such as the Microchip MC23S17 that offer both input and output and these will be discussed in the future. The '595 chip is a "serial in - parallel out" chip that can be accessed via an Serial Peripheral Interface (or SPI) bus. The simplified operation is that a byte of data is clocked in via the serial channel then made available as individual bits through parallel outputs.

For a complete and detailed explanation of this whole process with wonderful graphics see the ermicroblog page

The bus consists of four signals:
  1. MOSI or Master Out, Slave In (Data out of the Master into the Slave(s))
  2. MISO or Master In, Slave Out (Data out of the Slave(s) into the Master)
  3. SCLK or Serial Clock
  4. SS or Slave Select

The basic sequence is that the Master chip makes the Slave Select, also known as Chip Select, go low then starts to clock the data out of the MOSI master's serial shift register and into the slave shift register while clocking the data out of the slave shift register and into the MISO to the master shift register. When 4, 8 or 16 bits have been transferred the Slave Select goes high and the transfer is complete.
It is possible to have multiple slaves off of the same set of SCLK, MOSI, and MISO. This would be done by taking individual Slave Select signals as I/O pins of the Master,
Taking three I/O pins from the Master into an "Eight-to-One" chip, such as a 74HC138, which would use the eight digital combinations of three bits to generate eight different SS signals.

Now why would anyone go through all this trouble?
Consider this:

The Arduino Nano uses an Atmel ATmega328 chip. The Nano has, allegedly, 14 digital I/O pins and 8 analog input pins. But two of those pins are used by the USB interface so you are left with 12 usable digital pins. The ATmega328 costs $1.57 in quantities of 100.

The other extreme in Arduino is the Arduino Mega which uses an ATmega2560 chip. The Mega has 52 digital I/O pins (but two are used for USB) and 16 analog input pins. The ATmega2560 costs $10.15 in quantities of 100 and, at this writing, has a 13 week lead time. So that is $8.58 for an additional 38 digital outputs.

The 74HC595 costs $0.35 in quantities of 100 for 8 digital outputs. To get the equivalent 38 outputs would require five 74HC595 and cost only five times 35 cents or $1.75. Adding an 74HC138 so that you only need six I/O pins of the microcontroller costs $0.26 so the total is $2.01. So a six dollar and change savings. Per assembly.

Here is the schematic of the test circuit: [ 74HC595 Demonstration Circuit ]
Code to Download is here (for Arduino 1.0.1) A print of the code as PDF is here
Arduino claims that there is support for SPI. I was not able to find the SPI.h file. Working around that was easy so with or without Arduino help talking to a '595 isn't a big problem.

Back to top
Contact Us
©Copyright 2006 - 2016 Circuitsville Engineering,
revised 25 January 2016