The 74HC164 Shift Register and your Arduino

The 74HC164 Shift Register and your Arduino
Shift registers are a very important part of digital logic, they act as glue in between the parallel and serial worlds. They reduce wire counts, pin use and even help take load off of your cpu by being able to store their data.

They come in different sizes, with different models for different uses, and different features. The one I will be discussing today is the 74HC164 8 bit, serial in parallel out, non latched, shift register.

Why? Well for one it is one of the most basic shift registers out there, which makes learning about it easier, but it just so happened to be the only one I had (lol!)

This instructable covers how this chip works, how to wire it, and interface it with an arduino including some sample sketches and led circuits.

I hope you all enjoy!



 
Remove these adsRemove these ads by Signing Up
 

Step 1So, what are shift registers?

So, what are shift registers?
As mentioned earlier they come in all different flavors, and I also mentioned that I am using a 74HC164 8 bit, serial in parallel out, non latched, shift register

so what does that all mean?!?

First, the name
74 -- means its part of the 74xx logic family, and since its logic it cannot directly control very much current  (16-20ma for the entire chip is common) , it only passes signals around, but that does not mean that signal is not going to a transistor which can switch a higher current load.

HC means its a high speed cmos device, you can read about that on the link below, but what you basicly need to know about that is that it is a  low power device and will run from 2 to 5 volts (so if your using a 3.3 volt arduino your ok)

Also it can work properly at high speeds this particular chip has a typical speed of 78mhz, but you can go as slow or as fast (until it starts goofing up) as you want
www.kpsec.freeuk.com/components/74series.htm

164 is the model number for this chip, there is a large chart of them on wikipedia
en.wikipedia.org/wiki/List_of_7400_series_integrated_circuits

Next, 8 bit
A shift register is made up of flip flop circuits, a flip flop is 1 bit of memory, this one has 8 (or 1 byte of memory). Since it is memory, if you do not need to update the register you can just stop "talking" to it and it will remain in whatever state you left it, until you "talk" to it again or reset power.

other 7400 logic series shift registers can go upto 16 bit

serial in parallel out

This means your arduino sends it data serially (on off pulses one after another) and the shift register places each bit on the correct output pin. This model only requires 2 wires to be controlled, so you can use 2 digital pins on the arduino, and break those 2 out to 8 more digital outputs

some other models are parallel in serial out, they do the same thing but as inputs to the arduino (for example a NES gamepad)

non latched

This may be a downfall of this chip if you need it. As data enters a shift register via serial, it shows up on the first output pin, when a clock pulse enters in, the first bit shifts over 1 place, creating a scrolling effect on the outputs, for example 00000001 would show up on the outputs as

1
01
001
0001
00001
000001
0000001
00000001

If your talking to other logic devices who are sharing the same clock and not expecting this, it  could cause issues. Latched shift registers have an extra set of memory, so once the data is done entering the register you can flip a switch and show the outputs, but it adds another wire, software, and things to keep up with.

In the case of this instructable we are controlling LED displays, the scrolling effect happens so fast you cant see it (except when you very first turn on the chip), and once the byte is in the shift register there is no more scrolling

We will be controlling bargraph type, 7 segment, and a 16LED 4x4 dot matrix with this chip and software on the arduino using only 2 digital pins (+ power and ground)



« Previous StepDownload PDFView All StepsNext Step »
18 comments
Jan 1, 2012. 7:56 AMNasmi says:
How can I open the file .tmp in arduino IDE ? it seems doesnt work.
thank you :)
Jan 1, 2012. 7:01 PMNasmi says:
Okay .. i'll try .. Thanks !
Nov 29, 2011. 3:52 PMahinkle09 says:
This is an excellent instructible! This is by far the best beginners guide to shift registers i've come accross. Thank you so much for putting this out there.
Nov 2, 2011. 7:35 PMPeckLauros says:
Nice instructables.
Sep 30, 2011. 11:48 AMEax5 says:
I hope you still answer questions for this instructable. I have finished constructing the 4x4 matrix. Everything seams to work fine, but I am having trouble lighting up the LEDs.

I can easily address an individual LED to light up, but when I do I get surroundings LEDs to turn on as well ( much dimmer then the addressed LED)

I have attacked a picture to show you what is going on. I am trying to just light up and LED that is in position (1,1) but as the same time LED (4,4) is dimly lit.

here is the piece of code that I am using.
shiftOut(data, clock, MSBFIRST, B10000001);
delay(1);

Any guess as to why?
IMG_20110930_143010.jpg
Sep 30, 2011. 8:20 AMEax5 says:
Hello Wanted to say thank you for a great tutorial, I am about to finish building the 4x4 Matrix and will let you know how it goes.
Sep 5, 2011. 9:14 PMRuss1234 says:

Great tutorial.  Thanks for making it, it's real helpful!
May 23, 2011. 10:34 AMsyntar69 says:
This is a fantastic guide!

I've been looking for something written like this for a while.
I now have a fully working 4x4 led matrix, that I've built myself, and got to show the patterns I want.

This is all thanks to you.


Cheers,

Mikey C
Apr 28, 2011. 8:38 AMMechanicalApe says:
Super rad tutorial dood!
Apr 2, 2011. 11:02 AMTheBurf says:
Great instructable, clear, easy to follow, helped alot
Oct 18, 2010. 11:26 PMTamerz says:
It has been so long since I have done any electronics. This was very helpful, much better than the one output per segment I was using!
Aug 18, 2010. 4:12 AMMCUman says:
It's a great way to add an alphanumeric LCD to a low pin count MCU. Instead of 14 pins, it drops to 4.
Jun 24, 2010. 4:23 PMmatt byrne says:
Great write up, very useful.
Jan 18, 2010. 1:07 AMn3r0 says:
 Great instructable! You gave the best explanation of shift registers that I have heard so far.
Dec 23, 2009. 6:06 PMkitecraft says:
Fantastic instructable!  Thank you :)
I made this with your help.
http://www.youtube.com/watch?v=3UNbvYED0bI
Nov 16, 2009. 1:55 AMBongmaster says:
kool ible :)
i got a bunch of shift regs to put to use :P

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
52
Followers
13
Author:osgeld