Unlocking Shift Registers: Arduino Guide to 74HC164 with 74HC595 Comparison!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
over a year ago I created the video about shift registers 595 shift register chip to be exact I thought I covered this topic thoroughly and I was not planning to revisit it anytime soon but recently my workshop was in such a mess that I'm in process of tidying it up right now and while doing it at the bottom of my electronic part organizer I found this shift register breakout Port I looked more closely at it this time and to my surprise I realized that there is a different chip on it it is not 595 it is 164 and this is the chip I have never came across before so I was really eager to find out how does it work how does it differ from this most popular 595 chip so here I am creating yet another shift register tutorial I hope you will find it useful at the end of this video I will try to give my owner's opinion which chip I consider to be a better one so stick around until the end foreign [Music] here is the breakout board with the 164 shift register on board all the output pins are conveniently positioned on the right side of it here's how the pins of that module map to the actual legs of the shift register chip please note that it has just 14 legs two less than the most popular 595 shift register I will in detail explain what each individual pins are responsible for later in this video before we look at 164 shift register chip here is a quick reminder how the most popular 595 chip Works let's start with chip pinout DS is the serial data input pin the output enable is used to turn off the outputs must be held low for normal operation next is master reset it resets all outputs as low must be held high for normal operation then we have a clock pin a data is shifted from the serial input pin to the the 8-Bit shift register on every positive transition of that clock signal the latch pin is used to update the data to the output pins it is active High when the latch pin goes from low to high the current content of the shift register is copied to the storage register and the bits of the storage register are propagated to the 8 output pins when you think of a storage register think of it as the snapshot of the shift register State Storage register remains unchanged when we continue shifting new input to the shift register it only changes again when the signal at latch pin goes from low to high the initial value of both clock and large pins is set to low last is the Overflow pin that enables us to chain connect shift registers we do it via connecting the Overflow pin of one register to the DS pin or the second one so let's say we want to control seven segment display without chip here is the simple digit to display you can see segments a to g plus decimal point and how they map to shift register output pins so to display digit 4 for instance we would have to provide following serial input to the DS pin please note that we are entering data in reverse order so we start with decimal point segment and finish with a segment also that would be the sequence for the common cathode 7 segment display in which we lit each segment by sending High signal to it in this video however I will be using common anode display where anodes of all the segments are connected together and we lit individual segments by connecting them to ground in this case the input sequence would need to be inverted let's send that sequence to the DS pen to start shifting it into the register we need to use clock pin to send impulses whenever clock goes from low to high a single bit is pushed into the shift register eight impulses would move the whole input sequencing if now we send High signal to the latch pin the sequence of bits we have just entered to the register gets saved into the storage register and that causes seven segment display to show digit 4. what's going to happen if we push another sequence representing different digits into the register let's take the digit 9. the process looks the same bits of Digit 9 find their way into the register but you see the bits that were already in the register being pushed out via overflow pin if you connect that PIN to the DS pin on the next shift register which is tacted by the same clock signal those bits are going to be loaded into that register please notice that all that time the digit displayed on the 7 segment display did not change as it reflects what is in the storage register so now having the bits representing digit 9 in the shift register we could display that digit simply by changing the signal on latch pin from low to high which will update storage register values so having this recap of 595 chip out of the way we can look at 164 chip let's start with pointing main differences in chip pinout the serial input pin is renamed to a actually the chip has two serial input pins A and B only one can be used for inputting data so pick one and then the other one has to be either connected to the primary input pin or to 5 volts I chose to use pin a and send High signal to pin B there is no output enable pin master reset pin is labeled as CLR clear pin needs to be set to high for normal operation there is no latch pin good reason for this as there is no storage register set is not needed whatever data is pushed to shift register is immediately visible at output pins and that is the main difference between both chips there is no dedicated overflow open if we are planning to daisy chain several shift register we use Q7 output pin as overflow pin and connect it to input pin a of the next shift register let's look at functional modes of 164 chip as they are defined in the chip data sheet looks complicated let me break this down for you in the first row you see that when CLR pin is set to low then regardless of kind of signal you sent to clock pin and input pins A and B all output pins are reset to low any other behavior requires CLR pin to be set to high next you see that low signal at clock pin does not affect the output pins and they remain unchanged no matter what we send to data input pins but if the signal at clock pin changes from low to high and we have a high signal on both input pins then one is shifted into the shift register and all the bits already existing in the register are shifted to the right by one position then if on a positive transition or the clock pin we send low to input pin a then regardless of the value at Pin B the 0 is shifted to the shift register and all the existing bits are shifted to the right by one position as well in this situation A is a primary input pin in the last row we also should zero to the register but in this scenario B is the primary input pin let's run the simulation similar to the one we did for 595 chip third sequence of bits represent digit 4. you will see that each change of the values in the shift register is immediately reflected at the output pins after all eight bits are pushed in we have digit 4 shown on the 7 segment display now let's load 8 more bits representing digit 9. again the output dynamically changes each time content of register is updated Q7 is serving as an overflow pin so at the end the seven segment display is showing 9 and if Q7 pin is connected to the next shift register it will be loaded with the bits representing digit 4. to be able to demonstrate how this works let's build the Prototype we'll start without Arduino the project would be powered by this micro USB adapter as mentioned before I would use the common anode 7 segment display and here is how the shift register output pins map to the input pins of the display then we need two push buttons the left one would be used to select what signal we want to push into the register so whatever state we select would be sent to input pin a I connected an LED so we can at all times see which state is currently selected we also need pull down resistor for the button to function correctly LED off means zero and led on means one the right button would be our clock so by pressing it we would change the signal from low to high and that would get the bits moving into the register here also I am adding the LED and pull down resistor and here is the setup connected on the real breadboard we are still missing few connections first we need to connect input from the first push button to the register input pin a the input from second push button goes to clock pin so by pressing that push button we'll be able to provide clock impulses and finally we connect CLR pin to 5 volts otherwise all output pins would be reset to low the last thing we need are those small diffusion panels for the LEDs so they do not mess up with our video footage I will power the circuit from this little power bank we are ready to test this thing the left LED is off so when we press the right button we will be loading zeros to the register and that in turn will lit corresponding segments now let's change the input signal to 1 and start loading the register again you see that this time we would turn off segments one by one one more test let's push a single zero in which will lift the segment a and then continue pushing High signals in this will push that zero down the register lighting individual segments in the process in the same way we can fill in the register with zeros then push a single high signal to the register that will turn the a segment off and then continue pushing zeros which would result in individual segments being turned off so our little shift register testing device works fine let's check if we can push in the sequence of bits that will display a single digit let's take digit 4. here is this sequence done let's do another one three for instance done again so having full understanding how the 164 should register Works let's connect it to Arduino we can get rid of the push buttons and LEDs here is the Arduino Nano let's connect with ground and 5 volts to the register the serial data pin is connected to Arduino digital pin 2. clock is connected to digital pin 3. we also need to connect CLR pin and secondary data input to 5 volts this is how it looks connected on the breadboard so it is time to look at the code basically the same code you'd use for 595 chip would also work for the 164. Starting by declaring pins controlling the shift register we have data pin a digital pin 2 latch pin used only for 595 chip a digital pin 4 clock is connected to digital pin 3. then we have digit table that contains bit sequences for digits from 0 to 9. in setup function we declare all three register control pins as output I wrote the custom function called display digit that extracts the right bit sequence for the digit passed as the function argument here's how this function works we start by setting the latch pin to low then we have a for Loop which Loops through the bit combinations of the selected digit in the loop we first set the clock pin to low then we set the value of a data pin to the inverted value of the currently processed bit y inverted value might I remind you that we work with a common anode displays so zero lights up the segment and one turns it off next we set the clock pin to high and this pushes the value of the data pin into the register when we go through all eight segments then we set the large value to high and that updates the storage register and the selected digit is displayed that is of course required for 595 chip only since we are working with 164 shift register both large altering commands can be commented out I will additionally add the delay of 100 milliseconds in the loop so you can clearly observe how the register works in the loop function we have a for Loop that executes display digit function for digits from 0 to 9 waiting 800 milliseconds in between each digit let's load the code to the microcontroller and there you see the actual process of pushing bits sequence for each digit one bit at a time this can be used as a feature of EG digital clock to make time change look cool but if you do not want this visible transition from digit to digit all you need to do is get rid of that 100 milliseconds delay let's reload the code and there the glitch effect is gone well it is still there but it is so fast that your eye does not register it now let's daisy chain two shift registers I actually do not have the second 164 shift register but we can connect the one I have to the 595 one we need to connect it to 5 volts while doing it we will send High signal to a master reset pin as well we also need ground connection here is yet another seven segment display we connect 5 volts to Common anode through current limiting resistor and then connect eight segments to shift register pins like shown here to start let's also feed the data to that register from the Arduino digital pin 2. just like we do for 164 register and then the clock pin goes to Arduino digital pin 3 and large pin goes to Arduino pin 4 just like we stated in the code this shift register has also an overflow pin that will not be used here as we do not have any more shift register connected behind 595 register when testing this setup we will disconnect the 595 shift register serial data input from Arduino digital pin 2 and connect it to Q7 overflow pin over 164 shift register this should be interesting let's have a look good thing I created those diagrams as this is the tangle master of wires not very transparent but you have to take my word for it that everything is properly connected we are loading the same code like in previous test and does not look good only 164 should register works the display connected to 595 shows nothing why simple answer we commented out large pin altering commands let's reinstate them and reload the code this time it looks great both shift registers receive the same data as both serial data pins are connected to Arduino digital pin 2. and now for the ultimate test I am disconnecting serial data input of 595 chip from Arduino and redirecting it to Q7 overflow pin of 164 shift register and have a look the digit shown on the display connected to 595 is lagging behind by one and that is what we would expect to see right this concludes this tutorial so which chip do you think it's better I think they are very similar as far as coding is concerned they are pretty much the same the Glitchy transitions of 164 shift register from one state to the other is not really a problem for me and please keep in mind that this chip has 14 legs instead of 16. so I think in my future projects I would be leaning towards using 164 chip what do you think let me know in the comment section below alright so that's it as always like share subscribe to my videos if you're feeling generous today support my channel either by becoming my Patron or via PayPal or super thanks donations I'm not gonna lie even the smallest contribution would help me a lot I'm counting on you don't disappoint me I will see you in my next video which should be in about two or three weeks ciao [Music] [Applause]
Info
Channel: Mario's Ideas
Views: 11,171
Rating: undefined out of 5
Keywords: Arduino, nano, shift register, 74hc164, 74hc595, 74hs164d, shiftout, daisy chain, 7seg, 7 segment, seven segment, tutorial, how to, instructable, simple project, breadboard, microcontroller, circuit board, hardware programmer
Id: sQfghvHYTlk
Channel Id: undefined
Length: 18min 26sec (1106 seconds)
Published: Wed Nov 09 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.