loading

Problems & Objectives

A lot of Dev Boards like Arduino, STM, ChipKit etc (Even micro computers like Raspberry Pi) have a limited number of Digital input and output pins, which is a serious problem for the makers while creating them projects, especially when the Dev Board should be connected to an important number of peripheric (Exemple: the 5x5x5 LED Cube where you need to control more than 100 LED). Our goal is to satisfy the users desires by making a Hardware and Software solution to add more Digital I/O pins to your Dev Boards.

The solution

The IOExtension module is based on four shift registers (74HC595) to provide 16 Digital Inputs and 16 Digital Outputs, you will need only four pins in your Dev Board to control the module, plus the Vcc and the Gnd pins.

The use of this module is so handy because the MEGA DAS community developed an Arduino software library to grant you using the module with a minimum code instructions.

Step 1: What You Need to Make This Project

The hardware:

4 pcs 74HC595 shift register

4 pcs 16 Pin DIP IC Socket

16 pcs 1N4001 Diode

1 pcs 40Pin Header Connector 2.54mm

2 10K resistors

1 330 resistors

1 5mm LED

A PCB that you can order it for less than 5$ from easyEDA

The software:

Arduino IDE

MegaDAS_IOExtension library

Step 2: About the Main Component (74HC595)

The Hardware part is so simple and based on the 74HC595 shift register, it is an easy and inexpensive way to increase the number of digital I/O pins on your Dev board. This integrated circuit is inherently digital, like the digital pins on the Arduino it means that they can only read or write HIGH or LOW logic levels, they should not be used to read data from analog sensors or potentiometers.

We can find a lot of hardware and circuits based on this kind of shift registers like the Adafruit motor shield, 7 segment module. The use of this circuit is so handy and a great hands-on approach of the multiplexing an efficient technique for controlling many components wired together.

you can order 5 pics of 74HC595 online for less than 6$ : Amazon order link.

So how to use the 74HC595!!

  • The circuit provides three interfacing pins which are the SHIFT_CLOCK (SH_CP), the LATCH_CLOCK (ST_CP) and the Data pin (DS).
  1. The first step consist on storing the data in the storage register and to do so we need set latch pin to LOW to disable the outputs, this way the output pins won't change as we are sending in new data to the 74HC595.
  2. The next step is sending the data bit by bit serially, by pulsing the clock pin and sending each byte of new data out the data pin.
  3. The last step is setting the latch pin high. This way the register will update the (parallel outputs).

You can find more details about this integrated circuit in its Datasheet.

I’m just explaining how the shift register operates but, we’ll not do all this work because we gonna use the Arduino SPI library to control the whole thing and don’t forget that you will have a library to control the module, just a last information about the shift register it has 8 parallel outputs (Q0-Q7) and one serial output (Q7') for cascading.

Step 3: The Hardware Design (The Circuit)

The IOExtension module is based on four shift registers (74HC595) to provide 16 Digital Inputs and 16 Digital Outputs, you will need only four pins in your Dev Board to control the module, plus the Vcc and the Gnd pins.

In order to have 32 I/O pins we will use four shift registers (74HC595) as showed in the schematic. The four registers should have a synchronised Data and update the all outputs and the inputs at the same time, this is why we should connect all the LATCH_CLOCK pins together and all the SHIFT_CLOCK too, but the Data pin of your first register will be connected to you Arduino board and the rest of registers will be connected to each other through the serial output (Q7') that means connect the serial output of your first shift register to the data pin of the next shift register and so.

I highly recommend the easyEDA website to make your PCB.

BUT What is the easyEDA!

It's a free online Electronic design automation community that allows the creation, testing and editing of schematics and PCBs.

Find the link to the easyEDA platform here.

This online program is supported in all platforms even android, with easyEDA you can make a Schematic Capture for your documents, Circuit Simulation, Online PCB Designing with the ability of importing PCB and Schematic files, so from this point we can understand that we can create the PCB in this online designer or just make it with another software and upload a gerber file to easyEDA to place an order.

The collaborative designing is the best part of easyEDA where you can collaborate and comment on designs easily with public or private access. The community came with a Perfect Cloud Development and this is not all of it we still have this great google chrome extension to keep you updated with all your chat mates and partners activities.

After the login start a new project give it a name and select its privacy, don’t forget that a short description is always good for your partners, then the auto assistance will guide you to start with the options and tools. In this project we will make the circuit showed in the picture above. There are some unavailable components in easyEDA libs like the 74hc595 shift register so you should search for it in other public project, just write the label and click on search and when you find it, select it then place it in the blank sheet but you need the package representation to complete your PCB design so click in the blank space of the package and update it.

After complete the schematic you can download a pretty PDF or image of it for your documents. About the PCB, click on convert project to PCB an you will get the appropriate PCB for your circuit, what I really liked in this platform that it range the components for you so can place them the way you want. The easyEDA solve the problem of manually routing and gives you the ability to make an auto router just over one click.

After finishing the rout you can add some options like images to improve the appearance and some indicator labels then click the fabrication output button if you want to place an order for your PCB. Our module costs less than 30$ for 5 pics, it's a good price for purchasing.

PCB Well recieved

Just 6 days and I got my order delivered and I was really impressed by the quality of the PCB that easyEDA community made, I didn't expect anything less from such talented makers.

Step 4: The Software (The Library)

The IOExtension Library was developed by MEGA DAS community in order to facilitate the use of the Digital Extension module (Based on 74HC595 shift regisrters) made by the same community.

This is a Github link to download the library.

This library contain all the necessery APIs that can be used in your code written in the Arduino IDE for sure after adding this library to your libreries directory. The package contain also the exemples file where you can find some basic exemples to demonstrate how to wire the module to your Board and how to exploit the APIs like the DigitalRead and DigitalWrite exemples that shows the same behavior as the Arduino digitalRead and digitalWrite APIs.

The DigitalRead exemple:

#include // Include the MegaDAS_IOExtension header file

const int SH_CP=13; // 13 or ICSP-3 (for Arduino Uno, Nano, Leonardo and 101) 52 or // ICSP-3 (for Arduino Mega2560 and Mega1280)

const int DS=11; // 11 or ICSP-4 (for Arduino Uno, Nano, Leonardo and 101) 51 or // ICSP-4 (for Arduino Mega2560 and Mega1280)

const int ST_CP=3;

const int IN_P=4;

const int LED=13;

IOExtension myExt(SH_CP, DS, ST_CP, IN_P); // Make instance and named anything you want (in this // example the instance is myExt)

void setup() {

pinMode(LED,OUTPUT); // Configure LED pin as output pin

}

void loop() {

if(myExt.DigitalRead(1)==HIGH) // Read the first input pin of the Extension module digitalWrite(LED,HIGH) // Set LED output to HIGH if the Extension input is HIGH

else

digitalWrite(LED,LOW); // Set LED output to LOW if the Extension input is LOW

}

The DigitalWrite exemple:

#include // Include the MegaDAS_IOExtension header file
const int SH_CP=13; // 13 or ICSP-3 (for Arduino Uno, Nano, Leonardo and 101) 52 or // ICSP-3 (for Arduino Mega2560 and Mega1280)

const int DS=11; // 11 or ICSP-4 (for Arduino Uno, Nano, Leonardo and 101) 51 or

// ICSP-4 (for Arduino Mega2560 and Mega1280)

const int ST_CP=3;

const int IN_P=4;

const int LED=2;

IOExtension myExt(SH_CP, DS, ST_CP, IN_P); // Make instance and named anything you want (in this // example the instance is myExt)

void setup() { pinMode(LED,OUTPUT); // Configure LED pin as output pin }

void loop() {

myExt.DigitalWrite(LED,HIGH); // Set the fifth extension module pin to HIGH

digitalWrite(LED,HIGH); // Set the fifth Arduino board pin to HIGH

delay(1000);

myExt.DigitalWrite(LED,LOW); // Set the fifth extension module pin to HIGH

digitalWrite(LED,LOW); // Set the fifth Arduino board pin to HIGH

delay(1000);

}

We tried to make sure that you will not find any coding errors caused by this library after testing it with a lot of exemples and different uses combinations.

The library allows users to write the minimum of code to control all the inputs and outputs, so using only two simple instructions like DigitalRead(Pinx) or DigitalWrite(Pinx, value) you can directly make the module operates the way you want and for sure the MEGA DAS community created this Arduino library to explain the use of the module through some exemples.

Step 5: Make Some Tests

After testing the module and following the wirring discription above we got a satisfying results and we can use our new GPIO pins with no problems.

Don't forget to share this project to support MEGA DAS cimmunity and tell us through a comment if there is anything you want to now.

<p>keep it up ;)</p>
<p>thank you :)</p>
<p>how to download the library!</p>
<p>you can download it through this link: <a href="https://github.com/BEEMB/MegaDas_IOExtension" rel="nofollow">https://github.com/BEEMB/MegaDas_IOExtension</a></p><p>And you will find some basic examples to guide you :)</p>
great
<p>Thank you :)</p>

About This Instructable

1,608views

18favorites

License:

Bio: MEGA Development of Automated System is a free community responsible for creating electronic projects and automated systems standing on robotics engineering field which is a ... More »
More by MegaDAS:Led Cube 5x5x5 (Arduino Project) Line Follower Robot (PICTO 92) Increase Digital pins of your Arduino using the 74HC595 (IOExtension Module with Arduino library) 
Add instructable to: