Shop OBEX P1 Docs P2 Docs Learn Events
74hc595 problems daisychaining — Parallax Forums

74hc595 problems daisychaining

remmi870remmi870 Posts: 79
edited 2009-02-05 02:34 in BASIC Stamp
i am having problems with two hc595's running them in tandem, the clock and latch are paralled between the two and i run the output from the first chip to the second. the first chip wil work standing alone, i can get the chip to count up, but if i add the second chip and connect the latch pin to the first chip i get a erractic output and eventual all the pins go high, is the second chip damaged or is there something im missing?

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2009-02-04 05:09
    remmi870,

    Can you provide a schematic?

    What are the RESET lines doing? ... as well as the OUTPUT Enable lines?

    "... i run the output from the first chip to the second... " - Just to confirm, this should be from pin 9 of the first stage to pin 14 of the second stage.

    Do you have a decoupling cap of .1uF to .01uF across pins 8 and 16 of each chip?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • remmi870remmi870 Posts: 79
    edited 2009-02-04 11:21
    actualy, i figured out the problem, but have a new one, the problem i had was apparently the packaging that my chips came in had two types of chips ( i will be making a phone call) so i put the wrong chip in. now that i put in a hc595 in tandem( yes pin 9 is connected to pin 14 on the second 595) i am getting a "parallel" output not a cascading output, to help, the exact chip im using is a MC74HC595B1.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-04 12:03
    If you are getting parallel output and not a cascaded output, chances are you are only pushing through 8 bits and not 16 bits of data. Make sure that you latch only once after you shift the data out also.


    See the attached drawing (disregaurd the SX adaptation note) and the BS2 counter code. This is set up for 3 cascaded 74HC595 chips but you can take out the 3rd set if you only want 2.



    Post Edited (T&E Engineer) : 2/4/2009 2:06:36 PM GMT
  • remmi870remmi870 Posts: 79
    edited 2009-02-04 13:59
    thanks, i forgot about the 16 bit output, got it working now, everything was wired right, however i dont see how to cascade past 2 595's if you can only do 16 bits out, is there a way to output more than 16 bits?
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-04 14:03
    Yes. The drawing and code I attached before show you how to connect (3) of the 74HC595 chips to your Basic Stamp 2 (BS2). You can send out 8 "bits" (1 byte) in a pattern or something for each 74HC595 cascaded as shown in my BS2 code.


    Explain a little more of what you want to do, and I will see if I can help (or other forum user too).
  • remmi870remmi870 Posts: 79
    edited 2009-02-04 14:39
    i guess im kinda confused as to how your program pushes out 24 bits, it seems like it would push out the first 8 bits to the first 595, then run the second sequence again, how would it keep "pushing" out to get to the third register?
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-04 15:04
    My particular program does nothing more than turn on 1 LED from a bit being pushed or shifted out to the first 74HC595 and then to the next and finally to the last 74HC595.

    Let's break it down and start with the FORWARD subroutine to start:

    Step 1 - pattern1=%00000001
    Step 2 - Shift that bit into the first 74HC595's output pin 15
    Step 3 - Wait and delay so you can see the LED on at pin 15
    Step 4 - Shift that bit to the left now so pattern1=%00000010
    Step 5 - Loop though the remaining 7 bits from pattern1 into the 74HC595.

    What you see at this point is a single LED turning on and off across the 8 output pins of the first 74HC595.

    Step 6 - Take the overflow from pin 9 of the 1st 74HC595 and input that into the Data in (pin 14)·on the 2nd 74HC595
    Step 7 - This process continues as the data now gets shifted as the next 8 bits get pushed through the first 74HC595 into the 2nd 74HC595

    What you see at this point is a single LED turning on and off across the 8 output pins of the second 74HC595. At the end of this, the 2 sets of 8 bits have been shifted through (2) 74HC595s. Remember the shifting caused previsous bits to have 0's in them (meaning the LEDs are off - except for the final LED in the chain staying on).

    Step 6 - Take the overflow from pin 9 of the·2nd 74HC595 and input that into the Data in (pin 14) on the·3rd 74HC595
    Step 7 - This process continues as the data now gets shifted as the next 8 bits get pushed through the·2nd 74HC595 into the·3rd 74HC595

    What you see at this point is a single LED turning on and off across the 8 output pins of the·third 74HC595. At the end of this, the·3 sets of 8 bits have been shifted through (3) 74HC595s. Remember the shifting caused previsous bits to have 0's in them (meaning the LEDs are off - except for the final LED in the chain staying on).

    For the BACKWARD routine, the pattern1 (e.g. %10000000) gets shifted to the right this time to make the single LED to turn on in the reverse direction.

    The MAIN: program repeats itself with the FORWARD and BACKWARD routines running over and over which gives the LED display a moving display of a LED going from left to right and back to left again to be repeated over and over.

    Does this make more sense now?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-04 16:16
    Remmi,

    You’re not limited to only pushing out 16 bits. That limitation is for a single variable and allows for variable bits to be sent out as individual groups. To send out 24 bits to your 3 shift registers you would use something like the following. Note that each variable is an 8-bit byte and three are being shifted out prior to latching the '595.· I hope this helps. Take care.
    Out_595:
      SHIFTOUT DataIO, Clock, MSBFIRST, [noparse][[/noparse]secs, mins, hrs]
      PULSOUT HC595, 5                      ' Latch Outputs
      RETURN
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • remmi870remmi870 Posts: 79
    edited 2009-02-04 18:04
    ok, i understand, so assuming you push in 16 bit groups, what is the maximum amount of groups that can be pushed, in other words, now that i figured how to do numerous groups, like for instance

    SHIFTOUT Data, clock, MSBFIRST, [noparse][[/noparse] 22045\16, 22045\16, etc.......]

    this should give me every other pin two 595's at a time but what is the maximum amount of pairs i can shift at a time?
  • remmi870remmi870 Posts: 79
    edited 2009-02-04 19:56
    i guess if you keep adding a new shiftout line before the latch, you could make almost a infinite amount of outputs, however if one were to assign a task to each individual output, for instance 125 different outputs for lights or relays or even 200-500 outputs, you would need to write the code for each output wich would be alot of code, so unless you use a sx or px chip with alot of space for code, you may run out of memory for your program before you run out of outputs.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-02-04 20:02
    Yes. You are correct about the new SHIFTOUT commands before the latch. I'm not following what you are saying about "assign a task to each individual output" ?

    JonnyMac on the SX forum helped me write some 74HC595 cascaded code for the SX28. With this, I should not run out of memory until I reach about 800 LEDs. If I used an SX48, since it has twice the RAM as the SX28, I should be able to have 1600 LEDs in theory at least. However, in my application I only need to use about 128 LEDs.
  • remmi870remmi870 Posts: 79
    edited 2009-02-05 02:34
    well, hypotheticaly you could make a code so if you wanted chip 3, bit 5 out, instead of output 5 or HIGH 5 on chip 3, you would have to set series 2, 16 out which is binary 5 out, if you just keep adding or subtracting, but if you have to have code to alow a action or condition to set each of your "800" some odd outputs, thats allot of code. however if one were to use 128 outputs for something usefull or to make some type of display, you could write a code that would just strobe outputs in sets, less code for more outputs.
Sign In or Register to comment.