Shop OBEX P1 Docs P2 Docs Learn Events
Daisy Chain the 74HC595 — Parallax Forums

Daisy Chain the 74HC595

ArchiverArchiver Posts: 46,084
edited 2002-06-30 20:03 in General Discussion
I want to use 4 of these shift registers (74HC595) using the same
stamp pins - daisy chain. The example in the "App Notes" in the BS2
manual doesn't get into that details. I understand that the OE line
on the first 74HC595 is connected to the Data pin of the second and
both of them share the clk and latch lines.

My confusion is how to address a particular 74HC595 in the chain.
What should be put in the code that will make the command to go to,
let's say the 3rd 74HC595 but ignored by all other three chips. I
am just not sure how to do that?

Many thanks in advance...

Al

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-06-30 16:28
    For Al

    Daisy chaining the 595 is simple.

    First, change your shiftout msbfirst to lsbfirst. That was if you write

    1000 0000 the the "1" is the first 595 output, or Qa. Makes it much easier
    to program.

    Second, to send to multiple 595s you would write

    Shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern]
    shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern1]
    shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern2]
    pulsout latch, 10

    Pattern goes to the last 595 in the string, pattern1 goes to the second 595,
    and pattern2 goes to the first 595. This gets confusing when you are trying
    to control things, so I always send the pattern I want in the last chip
    first, then the pattern I want in the second chip and finally the pattern I
    want in the first chip.
    If you want to send, for example,

    00001000, which = 8 decimal, you could send

    shiftout pin, clk, lstfirst, [noparse][[/noparse]8]
    pulsout latch, 10

    In other words, decimal numbers work just as well as binary codes.

    Connect pin 9 if the first chip to pin 14 of the second chip, pin 9 of the
    second chip to pin 14 of the third chip, and so on. You can daisy chain up
    to at least 10, giving you 80 outputs with one I/O line.

    Hope I expressed this clearly.

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-30 17:37
    When you daisy-chain 74HC595s, you need to connect the serial output pin of
    one device to the serial input of the next. The clock and latch lines for
    all devices are connected together.

    Since the data is sent down the stream serially, it's not possible to address
    one without impacting the others. Imagine this chain:

    [noparse][[/noparse] Stamp ]--[noparse][[/noparse] A ]--[noparse][[/noparse] B ]--[noparse][[/noparse] C ]--[noparse][[/noparse] D ]

    To get information into device "C" it must pass through "A" and "B" first.
    Device "D" is also affected due to the information moving through the chain
    (if you just do three SHIFTOUTs to get information into C, what was in A will
    now be in D). What you need to do, then, is create a subroutine that sends
    the current data for all four devices -- in reverse order (D, C, B, A). Like
    this:

    Update_595_Outputs:
    SHIFTOUT Dpin, Cpin, MSBFirst, [noparse][[/noparse]DevD, DevC, DevB, DevA]
    RETURN

    Whenever there is a change in any of your device storage variables, call this
    routine. For any device that had no change in its variable, there will be no
    change at the outputs.

    I hope this helps.

    -- Jon Williams
    -- Applications Engineer, Parallax

    In a message dated 6/30/02 8:58:59 AM Central Daylight Time,
    brownstamp@y... writes:


    > I want to use 4 of these shift registers (74HC595) using the same
    > stamp pins - daisy chain. The example in the "App Notes" in the BS2
    > manual doesn't get into that details. I understand that the OE line
    > on the first 74HC595 is connected to the Data pin of the second and
    > both of them share the clk and latch lines.
    >
    > My confusion is how to address a particular 74HC595 in the chain.
    > What should be put in the code that will make the command to go to,
    > let's say the 3rd 74HC595 but ignored by all other three chips. I
    > am just not sure how to do that?
    >
    > Many thanks in advance...
    >
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-06-30 20:03
    Thanks to both Jon and Sid. You are a god sent! You help me me so
    much over the BS2learning process through this group and N&V
    articles. Many thanks.


    Al




    --- In basicstamps@y..., Newzed@a... wrote:
    > For Al
    >
    > Daisy chaining the 595 is simple.
    >
    > First, change your shiftout msbfirst to lsbfirst. That was if you
    write
    >
    > 1000 0000 the the "1" is the first 595 output, or Qa. Makes it
    much easier
    > to program.
    >
    > Second, to send to multiple 595s you would write
    >
    > Shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern]
    > shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern1]
    > shiftout pin, clk, lsbfirst, [noparse][[/noparse]pattern2]
    > pulsout latch, 10
    >
    > Pattern goes to the last 595 in the string, pattern1 goes to the
    second 595,
    > and pattern2 goes to the first 595. This gets confusing when you
    are trying
    > to control things, so I always send the pattern I want in the last
    chip
    > first, then the pattern I want in the second chip and finally the
    pattern I
    > want in the first chip.
    > If you want to send, for example,
    >
    > 00001000, which = 8 decimal, you could send
    >
    > shiftout pin, clk, lstfirst, [noparse][[/noparse]8]
    > pulsout latch, 10
    >
    > In other words, decimal numbers work just as well as binary codes.
    >
    > Connect pin 9 if the first chip to pin 14 of the second chip, pin
    9 of the
    > second chip to pin 14 of the third chip, and so on. You can daisy
    chain up
    > to at least 10, giving you 80 outputs with one I/O line.
    >
    > Hope I expressed this clearly.
    >
    > Sid
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.