Shift Registers: How Do They Work?

14,136

125

16

About: Electrical Engineering Student. Love to make projects and learn along the way!

Recently, I was going through the pile of old projects which I had made when I had just got into electronics. I found a 24 x 6 LED matrix which was my first 'complete' project. A lot of messy wiring, not perfect but it still works fine. At the time I made this project, I never thought about the components which were used, how did they work, etc. I just wanted to complete it as soon as possible and have some fun. And I'm sure there are many like me.

One such component used in the LED matrix was 74HC595 which is a Shift Register. Yet another popular device which is used when you run out of output pins. There are 24 columns which need to be controlled individually which means that you need 24 output pins on the Arduino (or any other microcontroller) which is a lot and makes the wiring messy. That is why shift registers are used. Now we can control 24 rows (or more) by using just 5 pins on the Arduino. Clever, isn't it?

In my previous Instructable, I made an LCD Trainer Kit which won a First Prize in Electronics Tips and Tricks Contest. It got some lovely comments from the people which suggests that the idea of getting back to basics is great.

In this Instructable, let us look at the working of a shift register and at the end build a small kit to see shift register in action.

Let's get back to basics!

Step 1: Things You Will Need

1x 74HC595 Shift Register

1x 16 pin IC socket

8x LEDs

8x 1k resistors

3x 10k resistors

3x Tactile push buttons

1x Perfboard

1x micro USB breakout board (optional)

Step 2: Know Your Shift Register

The shift register we will be using is 74HC595 which is an 8-bit Tri-state Shift Register i.e. with 8 outputs. Tri (3) states mean that the output can be set to either HIGH, LOW or High Impedance. Let us have a look at the pins of the IC and their function.

Note: Rising Edge - Transition from 0V to 5V (LOW to HIGH)

Falling Edge - Transition from 5V to 0V (HIGH to LOW)


Inputs (Control Pins)

Pin 14 - Serial Data In

Data is fed into the register from this pin. Serial means data is fed in bit by bit.

Pin 13 - Output Enable (OE)

This pin turns the output ON or OFF. It is an active low pin meaning that pulling the pin LOW enables the output. We will be connecting it directly to GND to make the output always ON.

Pin 12 - Storage Register Clock (RCLK)

When this pin is pulled HIGH, the data from the storage register is transferred to the output.

Pin 11 - Shift Register Clock (SRCLK)

A clock signal is provided to this pin. The data from Pin 14 (Serial Data In) is registered only at the rising edge of the clock. In simple words, when the clock signal rises from 0V to 5V, only then the data present at Pin 14 gets stored in the register.

Pin 10 - Shift Register Clear (SRCLR)

It is an active low pin. As the name suggests, when this pin is pulled LOW, it clears all the data from the storage register. We will be connecting it to 5V permanently so that the data is never cleared from the storage register.

Output

Pin 15, Pin 1 to 7 - QA to QH

These are the 8 outputs of the shift register.

Step 3: Putting the Kit Together

In the beginning, I had planned to use a project enclosure box. But since the components used are not panel friendly I decided to go with the perfboard. Plan the layout of components. Be creative in choosing the layout as long as it is sensible.

I used a micro USB breakout board as I will be powering the kit using USB.

The schematic for the build has been attached.

Step 4: Working

Let's get this thing running. We will try to light up LEDs at Q0 and Q1 i.e. 0000 0011

Note: Pushing the button makes that particular pin HIGH (or 1) and leaving the button makes it LOW (or 0).

Steps to be followed:

1. First, data is made 1 (HIGH). Hold down the Data push button. But the data has not been stored in the register yet.

2. The data is stored in the register when the clock signal rises from 0V to 5V i.e. on the Rising Edge. While holding the Data push button, push the Clock push button once as the IC looks for the rising edge only. Now the data is stored in the storage register as 0000 0001. You can now leave the Data push button.

3. To reflect the same in the output, push the Latch button once. You should see the LED of the first bit glowing. Great!

4. We are not done yet. Again hold down the Data push button and press the Clock push button once. Now the old 1 gets shifted to the left by one bit and the newly added 1 takes its place. Now the storage register will look like 0000 0011.

5. Press the latch button to reflect the same in the output.

That's it!

Now you might be able to understand why shift registers are used. In this case, 8 outputs can be controlled using only one line. Shift registers come in handy when you run out of output pins on the microcontroller.

I have made a stop motion video to make things more clear. Check out the video on YouTube.

Step 5: Have Fun!

Since you now know how a shift register works, you can use it along with Arduino and make an awesome project! Click here to know more interfacing 74HC595 with Arduino.

Thank you for sticking till the end. Hope you all love this project and learned something new today. Let me know if you make one for yourself. Subscribe to my YouTube channel for more upcoming projects.

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • First Time Author

      First Time Author
    • PCB Contest

      PCB Contest

    16 Discussions

    0
    None
    Joe Pixie

    Question 22 days ago

    Hi , you seem to know alot about micro circuits( well alot more than i do in any event...)
    great instruct by the way.

    i have been trying to figure a way to make the sweeping effect without using arduino or anything, i have found a couple diy's on the net, but they don't explain in laymens how to build the thing. can/will you be so kind as to help me with this project?

    i have an old style Volkswagen Fox and i want to redo the lights to be similar to the new Audi design... here is a youtube link of what i would like to accomplish.

    Please help me. ...
    Ps: i have no formal training in electronics or the like. what i have learned is what i could piece together from "instructables.com" and similar sites.

    Thanx in advance

    Joe

    2 more answers
    0
    None
    Joe Pixieindoorgeek

    Reply 17 days ago

    Would you be so kind and make an instruct on it...please, please....that would help me so much...

    Regards
    Joe

    1
    None
    kn7000

    22 days ago on Step 5

    Great presentation and operation info! I have a shift register game I call 'SHIFTY'. It has 16 bi-color LEDs placed in a 4 x 4 format and played to simulate SUDOKU with colors instead of numbers. Using two buttons, one to input Red and Yellow the other for Green and 'no light' Spaces. The player first predetermines and writes down a 16-LED color combination they want each LED to be for the final display to hopefully win. Using the two buttons for selected color inputs a combined total of only 32 inputs are allowed and then, whatever colors are displayed at that time, lock into place and no further inputs are allowed until a 'reset' is made for a new challenge. Each time either button is pressed all lights displayed, and their colors, 'shift' one place forward. Each possible color combination, 16.4 billion of them, can be accomplished with exactly 32 inputs. If you like I can give you the schematic and circuit board layout. John at jfmcircuits@twc.com

    001 (2).JPG
    1 reply
    0
    None
    indoorgeekkn7000

    Reply 20 days ago

    That looks interesting. I would like to make one. Also, you can make an Instructable for it and submit it to the Puzzle Contest which is going on right now.

    0
    None
    rbrtmsr

    22 days ago

    Have you had no trouble with your (un-debounced) clock input?

    0
    None
    cordovox

    22 days ago on Step 5

    Great educational project. Very well presented. Excellent graphics.

    1
    None
    gm280

    26 days ago

    There are so many old TTL and DTL DIPs out there to play with. And each has their own story and use. The mixture of old tech and new can even make new projects that were either hard to do back then, or nearly impossible. So your project brings new life to older tech and DIPs. I like that. And the great thing about those old Tech TTL and DTL DIPs, are they are very cheap to play with as well. Thumbs Up for sure.

    2 replies
    0
    None
    KISELINgm280

    Reply 22 days ago

    There was a time when someone invented the TTL-technology.
    Back in those days there was ”allso” tech’s known as DTL & RTL, (Diod/Transistor, Resistor/Transistor), logics.
    The major problem with tfese 74xx chips was tho power to be within 4,75 ~5,25V.extreme limits.
    That would be a way of a narrow window for the power-supply.
    Then there came these ”FET-trans.”, and then them ”CMOS-trans.” and then them ”MOS-FET*s” logics.
    Luckely for us they converted the LS74595 to 74HC595, that would be the ”next best” IC ewer, the best is the 555.(which isn't actually a "logical" IC, but anyway)

    0
    None
    indoorgeekgm280

    Reply 23 days ago

    True! Old tech is the best way to learn electronics!

    0
    None
    crazypj

    Question 22 days ago on Step 4

    does this mean the shift register you used actually has 8 x 8 x 9 combinations?
    Oh, I completely agree with the 'no 3D printer needed' comment. Not everyone has one or knows how to program one.

    2
    None
    billbillt

    23 days ago on Step 5

    GREAT IDEA!!... FINALLY, SOMETHING THAT DOESN'T REQUIRE A 3D PRINTER......

    3
    None
    tatagatha

    23 days ago

    That was a great write up and a very cool explanation. I liked the stop motion paper animation. I know you are trying to keep it minimal so that it is digestible but it might be worth discussing pin 9 & 13 more. Or indicating what someone can learn next. Pin 9's overflow bit allows you to chain multiple registers together. And looking at pin 13, why would you want to disable output? What was the the high-impedance state you mentioned in the intro? Pulling it high when not in use so that noise doesn't accidentally clock the data or output. (obviously you know this, i'm being rhetorical) But even cooler is that once you view the Output Enable pin as Chip Select suddenly your interface to the register looks a lot like SPI which can really change your view of what a shift register can do.

    1 reply
    1
    None
    indoorgeektatagatha

    Reply 23 days ago

    Yes, you are right. I should have mentioned the working of pin 9. I tried to keep it simple with only one register. I will update the Instructable. Thank you!