Connect with us

SN74HC595N Shift Register Problem

Discussion in 'General Electronics Discussion' started by BlackMelon, Oct 29, 2014.

Scroll to continue with content
  1. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    Hello,

    I'm testing the shift register. The circuit is the same as the attachment pdf file. I want to be able to control one bright led and shift it from QA to QB (Only 1 led will be bright at a time step)
    To be clear, I'll press the switch S1(SER/Data In pin) to input 5V data to the shift register. Next, I'll press S3 (SRCLK) to shift 5V to QA and then press the S2 (RCLK/Latch pin) to see the led which is connected to QA shine. I'll keep doing this to see only QB shine.... only QC shine... until only QH and then return back to QA

    The problem is when I connected all of this stuff, all LEDs are bright and I can't control anything. Did I make any mistakes?

    Thanks
    BlackMelon

    PS: This is the datasheet of SN74HC595N
    http://www.es.co.th/Schemetic/PDF/SNX4HC595.PDF
     

    Attached Files:

  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    Your SER, RCLK and SRCLK signals all need pulldowns. The pushbuttons and switches are only able to pull them up to VCC; when the switch or pushbutton is released, they will float. That's why you need a resistor from each of those inputs to 0V. You have the right idea with -SRCLK, where the switch connects to 0V and you have a pullup resistor.

    Also -OE needs to be held low.

    But you also need debouncing on the SRCLK input, at least. When you switch or press S3, the contacts will not close cleanly - they will "bounce" several times. When this signal feeds a clock input, each transition within the bounce will cause a clock action in the device. Search for contact bounce, or debouncing, using Google or Wikipedia for examples of how to remove contact bounce from a switch.
     
  3. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    Thank you Kris. Right now, I want to modify the circuit to be shift-restore (rotate the data of Q4 back to Q1). Q1 to Q4 is connected to LED. The result that I want to see is pressing only 1 button and the bright LED will be shifted right until it meets the last LED then return back to the first one. My idea is to do the circuit as an attachment here. The problem is the data pin (which should be the "D" of the first flip flop).

    At the very beginning, the data pin should be high then I'll press the shift key to shift the high state from data pin to Q1. After I shifted the data from the data pin to Q1, the data pin should be low. My reason is from this point on, it will continuously shift more low states from data to Q1 (if I give a clock and latch signal) and the bright led will be shifted to the right

    Here is the problem:
    1) After the bright led is the Q4 and the data is low, will it be a dead short which will burn my stuff?

    2) If so, is there any efficient way to solve this except putting a relay to disconnect the data pin out when the bright LED is the 4th LED? (Because a relay is expensive :) )
     

    Attached Files:

  4. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
    It has to be done with a micro and PWM because the whole thing is an illusion.
     
  5. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    If you want a circuit that lights one out of four LEDs and advances with a clock pulse, that's not the easiest way to do it. The venerable CD4017 will do that, with any number of LEDs from 2 to 10. Alternatively you could use a two-bit counter driving a two-to-four demultiplexer, but a CD4017 is simplest. Just do a Google image search on that part number and you'll find lots of circuits.

    A CD4017 can be operated from any supply voltage from 3V to 15V but it's not capable of providing much output current to drive LEDs directly. Its output current is highest at higher power supply voltages. If you need more than about 10 mA per LED, you should use a buffer transistor such as an emitter follower for each LED. Let me know if you want details.
     
    Last edited: Nov 1, 2014
    BlackMelon likes this.
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,271
    2,718
    Jan 21, 2010
    So all the LEDs are on, but one is brighter?

    If so, this is actually pretty easy to solve. You arrange that a small current is always allowed to pass through each LED and the 595 then simply supplies more current to the LED thus making it brighter.

    However, it would be easier to use a 4017 for this. It would require no initialization because it implements the output pattern you seem to be after.
     
  7. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    I'm sorry for making confusion. I mean 1 LED is on and the rest is off.
    1st state: Q1=1 the rest are off
    2nd state: Q2=1 the rest are off
    .....
    Then rotate back to Q1


    I come up with a new idea too in the attachment, is it valid?

    (The number in sequence like 1,0,1 means that at the first state, this node is 1... the next state it will be 0 and the 3rd state it will be 1 again.... It doesn't mean that I use any external circuit to force that node to be that sequence)
     

    Attached Files:

  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,271
    2,718
    Jan 21, 2010
    That's fine except for a few minor details.

    1) You need to clear it and then prime it with a single "1".
    2) The resistors are not needed.

    Take a look at the 4017. Really!

    The 4017 uses a twisted ring counter and then decodes the various states to get the 10 decoded outputs.

    A twisted ring counter is really useful in this case because:

    1) it requires no initialization
    2) it can recover from invalid states
     
    BlackMelon and KrisBlueNZ like this.
  9. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    I found that the CD4017 is much cheaper than a shift register. :v :v :v
    Thank you everyone :)
     
    (*steve*) and KrisBlueNZ like this.
  10. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    The shift register CD4017 works magnificently!! The clock button is connected to a microcontroller. As the bright led shift from the very left LED to the right(4th led), the controller will count 1 to 4 and then count back to 1

    The only problem right now is the Vcc. When the 5V is supplied to both microcontroller and shift register, the shift register will work first. I mean if I give a clock, the shift register will shift a display LEDs for me but the microcontroller have to wait until 5 minute to start counting up. Is there any good way to solve this?





    PS: I was trying an RC time constant to delay 5V to CD4017 (I also add a buffer after the RC circuit otherwise the voltage might be decrease by resistor when the capacitor is full). The result does not satisfy me much. When I press the clock button 3 times, the LEDs are still off. I thought that the RC delayed for me already. After few seconds, the bright LED is the third one which means the CD4017 has shifted the 5V data even the supply voltage is lower than 5V.
     
  11. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,271
    2,718
    Jan 21, 2010
    I'm not exactly sure what you're saying. Are you saying that you want the display not to start stepping for 5 minutes after power on? Is there any reason you can't program the microcontroller to do that?
     
  12. BlackMelon

    BlackMelon

    187
    5
    Aug 7, 2012
    Yes but not that long. Might be 10seconds. My microcontroller ports are full right now so I can't lose any ports to do the job.
     
  13. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,271
    2,718
    Jan 21, 2010
    So that output is used for other things?

    10 seconds is relatively short. You could try an RC delay on the clock inhibit pin of the 4017.

    You place a pull down resistor non this pin, then a capacitor to Vcc. If you want 10 seconds, try something like 100kΩ and 220μF.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-