74HC595 Shift Register Tutorial | Arduino with 7 segment

Hey, what's up, Guys! Akarsh here from CETech. 

Have you ever been stuck in between of any project because of a limited number of GPIO pins on your microcontroller? This is a very annoying and frustrating situation and can come up as an obstacle in your project development. But don't worry as we have the answer to your problem which is the 74HC595 Shift register IC. A single 74HC595 IC can be used to provide outputs to 8 different points apart from that we can also connect a number of these ICs and use them to control a large number of devices that too by consuming just 3 GPIO pins of your microcontroller.

In this tutorial, we will be going through the working of the 74HC595 Shift register IC its pinout and at the end, we will also understand the working of the IC with the help of a small project. 

 So let's jump straight into it.

About 74HC595 Shift Register

projectImage

A 74HC595 Shift Register is a 16 Pin SIPO IC. SIPO stands for Serial In and Parallel Out which means that it takes input serially one bit at a time and provides output parallelly or simultaneously on all the output pins. We know that Shift registers are generally used for storage purposes and that property of the registers is used here. The data slides in through the serial input pin and goes on to the first output pin and remains there until another Input comes inside the IC as soon as another input is received, the previously stored input shifts to the next output and the newly entered data comes on to the first pin. This process continues until the storage of the IC is not full i.e until receiving 8 inputs. But when the IC storage becomes full as soon as it receives the 9th input the first input goes out through the QH' pin if there is another shift register daisy-chained to the current register through the QH' pin then the data shifts on to that register otherwise it gets lost and the incoming data keeps coming in by sliding the previously stored data. This process is known as Overflowing. This IC uses only 3 GPIO pins to connect to the microcontroller and hence by consuming only 3 GPIO pins of the microcontroller we can control infinite devices by daisy-chaining a number of these ICs to each other.

A real-world example that uses shift register is the ‘Original Nintendo Controller’. The main controller of the Nintendo Entertainment System needed to get all button presses serially, and it used a shift register to accomplish that task.

Get PCBs for Your Projects Manufactured

projectImage

You must check OurPCB to get PCB's for your project manufactured online. 

They use reliable components sourced from accredited suppliers such as Arrow, Avnet, Future Electronics, etc. and offer reasonable prices ultimately maximizing the user's profit margins. Specialized in Multilayer and Rigid-flex Technology their priority is to maintain high-quality standards.

OurPCB focuses on small to medium volume orders and provides a very competitive price for the volume from 1-100 sq. meters. You just need to upload your files in either of the available formats(Gerber, .pcb, .pcbdoc, or .cam) and the PCB prototypes will be delivered to your doorstep. 

You can also check out their partner WellPCB for good deals.

Working of the IC

projectImage

The 74HC595 has two registers, each with just 8 bits of data. The first one is called the Shift Register. The Shift Register lies deep within the IC circuits, quietly accepting input.

Whenever we apply a clock pulse to it two things happen: 

1)The bits in the Shift Register move one step to the left. For example, Bit 7 accepts the value that was previously in bit 6, bit 6 gets the value of bit 5, etc.

2) Bit 0 in the Shift Register accepts the current value on the DATA pin. At the rising edge of the pulse, if the data pin is high, then a 1 gets pushed into the shift register. Otherwise, it is a 0.

On enabling the Latch pin, the contents of the Shift Register are copied into the second register, called the Storage/Latch Register. Each bit of the Storage Register is connected to one of the output pins QA–QH of the IC, so in general, when the value in the Storage Register changes, so do the outputs.

 In a nutshell, we can say that Inputs to the IC are accepted at the rising edge of the clock cycle and but they are stored only when the latch is enabled, and hence to see outputs changing we must enable the Latch as well.

Pin Diagram of 74HC595

projectImage

Though this IC is available in a number of varieties and models we will be discussing here the Pinout of Texas Instruments SN74HC595N IC. For more detailed information on this IC you can refer to its datasheet from here.

The Shift Register IC has the following pins:-

1)GND - This pin is connected to the Ground pin of the microcontroller or the power supply.

2)Vcc - This pin is connected to the Vcc of the microcontroller or Power supply as it is a 5V logic level IC. 5V power supply is preferable for it.

3)SER- It is the Serial Input Pin data is entered serially through this Pin i.e. one bit at a time is entered.

4)SRCLK- It is the Shift Register Clock Pin. This pin acts as the clock for the Shift Register as the Clock signal is applied through this pin. As the IC is positive edge triggered so to shift bits into the Shift register, this clock needs to be HIGH.

5)RCLK - It is the Register Clock pin. It is a very important Pin because in order to observe outputs on the devices connected to these ICs we need to store the inputs into the latch and for this purpose, the RCLK pin needs to be HIGH.

projectImage

6)SRCLR- It is the Shift Register clear Pin. It is used whenever we need to clear the storage of the Shift register. It sets the elements stored in the Register to 0 at once. It is a negative logic Pin hence whenever we need to clear the register we need to apply a LOW signal at this pin otherwise it should be kept at HIGH

7)OE- It is the Output Enable Pin. It is a negative logic pin and whenever this pin is set to HIGH the register is set into a high Impedance state and Outputs are not transmitted. To get the Outputs we need to set this pin to low.

8) QA-QH - These are the Output Pins and need to be connected to some sort of Output like LEDs and Seven Segment Display etc.

9) QH' - This Pin is there so that we may daisy-chain these ICs if we connect this QH’ to the SER pin of another IC, and give both ICs the same clock signal, they will behave like a single IC with 16 outputs. Of course, this technique is not limited to two ICs – you can daisy-chain as many as you like if you have enough power for all of them.

Using the IC to Control 8 LEDs Together

projectImage

So now as we have the knowledge about the working of the IC and its operation, therefore, we can now move ahead and get a demo over how to use it in circuits and in this way we will also be able to understand its working.

What we will be doing is that we will control 8 LEDs together with different ON-OFF states through this IC and also provide inputs to look over the shifting mechanism of the register.

Steps to connect the circuit are as follows:- 

1) Connect the Vcc and GND pins(Pin No. 8 and Pin No. 16) of the IC to the Vcc and GND of the power supply. 

2) Connect the SRCLR pin(Pin No. 10) to the 5V supply and the OE pin(Pin No. 13) to the GND pin. 

3) Connect the LEDs to the Output Pins QA-QH(QA=Pin No. 15 and QB-QH=Pin No. 1 to Pin No. 7) Make sure that the LEDs are connected in an order that the first LED is connected to the QA pin and the last one connected to the QH Pin. 

4) Now we need to connect three pushbuttons to the SRCLK, RCLK, and SER Pins of the IC which are Pin No. 11, 12 and 14 respectively. The Connections should be made according to the Circuit Diagram shown above. These are used to send HIGH Clock pulses and Logic level one at the Input.

projectImage

As the circuit gets completed we will see that the LEDs will turn ON in an order previously stored in the register it can be any random sequence and it can be all zeros as well. In my case, it is 01111000 where zero means OFF, and ONE means ON. 

Now in order to send a logic level ZERO first we need to press the button connected to SRCLK input this will send a ZERO to the register as the SER pin is already at the ZERO level but this will not show any Output because to get Output we need to send a ONE at the RCLK Pin or the latch input as soon as we press the button connected to this pin we will see the pattern will change to 00111100 i.e. a ZERO enters from the left and ZERO exits from the right.

projectImage

In a similar way if we want to send a ONE as Input we just need to press the button connected to SER pin and while keeping it pressed we need to push the button connected to SRCLK Pin and after that, we can leave both the buttons as the one has been sent and to see that on Output we need to press the RCLK button which will push in a ONE from the left side and pops out a 0 from the right side making the sequence 10011110.

Some Applications of 74HC595 With Arduino

One of the applications of this IC is to control the Seven Segment Display you can head over to that project page from here.​ Some more applications are listed below:- 

 1) Holding Data for a long time period 

 2) Serial to Parallel Data Conversion 

 3) General Purpose Logic 

 4) Controlling LED’s

Now You Are Good to Go

projectImage

So as now you have the information about this IC and its working you can now go ahead and use this IC to solve the problem of GPIO pins shortage. This IC is a great tool when you need to control a large number of LEDs and Seven Segment displays. Although it is generally used with microcontrollers you can use it without them as well but in the latter option, you might see an error known as debouncing which is caused when more than one clock cycles are sent to register instead of sending only one. This is will send more than a single ONE or ZERO and hence may result in a pattern not expected but that's not a matter of worry as it not occurs while using it with microcontrollers.

Hope you enjoyed the tutorial.

License
All Rights
Reserved
licensBg
0