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

74hc595

MctmarkMctmark Posts: 5
edited 2007-11-02 18:42 in BASIC Stamp
Could someone please tell me the Digikey part number of the proper 74HC595 I would use in this example· http://www.parallax.com/dl/docs/books/sw/exp/sw23b.pdf·and I am also unclear from this programing example of how I would address a individual LED output via the 74HC595.

For example, lets say I have two 74HC595 and I want to turn on a particular LED out of the 16 to choose from. How do I program the BS2 to turn on or off a particular LED in this example http://www.parallax.com/dl/docs/books/sw/exp/sw23b.pdf.

Thanks

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-06-23 04:33
    You can't change just one at a time, exactly.· You have to update all of the others, too (even if they don't change.)· So, you have to send out the whole byte (or word) with each update.

    UPDATE: Good ol' Parallax stocks the '595 -- http://www.parallax.com/detail.asp?product_id=602-00009

    Post Edited (PJ Allen) : 6/23/2007 4:39:06 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-23 20:40
    Hello,

    If you have 16 LEDs connected to the two 74HC595 shift registers you must have a word variable that you’re shifting out to them. You change the bits in the word variable and shift it out to change individual LEDs. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-06-24 11:33
    Just go to Mouser and search on 74hc595.

    Make sure you get the package you want (dip or pdip if you don't want surface mount). Should be around $0.50 and no minimum order.

    Buy some other stuff while you're there because shipping is going to be about $7 no matter what.

    (they sell Parallax stuff also)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • jeffjohnvoljeffjohnvol Posts: 197
    edited 2007-06-25 12:33
    Does anyone know if there is an equivalent chip that could be used to expand the inputs into the stamp through serial communication as well?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-25 12:43
    What is it that you would like to do?

    The MAX3100 from Maxim is a serial communications port (UART) that only needs an external crystal to be complete. It attaches to a microprocessor (like a Stamp) via an SPI interface which requires 4 I/O pins and is controlled with SHIFTIN and SHIFTOUT statements. You can use more than one MAX3100 in which case 3 of the 4 I/O pins can be shared.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-06-25 12:57
    Jeffjohnvol,

    To expand the INPUTS (unlike the 74HC595 which allows for more OUTPUTS for LEDs, etc. serially), you can use the 74HC165 to allow up to 8 inputs (or you can cascade more 74HC165's for more inputs) into the BS2.
  • Larry~Larry~ Posts: 242
    edited 2007-06-25 17:12
    If you can find an 8243 it has 4 ports, with 4 bits for each port, giving you 16 bits input or output. It
    has one port to talk to the stamp. Its an old chip but works well.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-06-25 17:24
    Then again - speaking of old chips there is also the 8255 PIA chip which allows for up to 24 inputs or outputs or combinations of Inputs/outputs. I have already written code for interfacing this to a BS2 as well as an SX 28. I beleive there is even a Propeller object out there too by Dennis Ferron. Do a search on this forum if you like.

    http://forums.parallax.com/showthread.php?p=561893
  • MctmarkMctmark Posts: 5
    edited 2007-08-08 04:06
    Could you give me an actual sample program using on one 74HC595 with a BS2. I don't quite understand how to do this.



    Thanks





    Hello,

    If you have 16 LEDs connected to the two 74HC595 shift registers you must have a word variable that you’re shifting out to them. You change the bits in the word variable and shift it out to change individual LEDs. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-08-08 10:43
    Here is some example code and schematic using 74HC595 chips with a BS2.

    The StampWorks 2 file is more than 2.43 MB which exceeds the 2 MB·file limit·size·of the forum. However, if you have less than 3 74HC595s used, then simply use my schematic and don't connect the other 74HC595s.
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-08-08 10:56
    Here's an example -turns on 1 LED at a time- requires 2 chips daisy chained Sh ans St must be wired parallel - Q7' output from first chip should be wired to Ds input on other:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' 74HC595 example wit 2 chip daisy chain

    Ds· CON 2····················· 'Display Data Pin
    St· CON 1····················· 'Display Latch Pin
    Sh· CON 0····················· 'Clock Pin

    x······ VAR Nib
    result· VAR Word

    DO

    FOR x = 0 TO 15
    result=DCD x····························· 'set bit
    SHIFTOUT Ds,Sh,MSBFIRST,[noparse][[/noparse]result\16]······ 'output to 2 daisy chained· 74HC595
    PULSOUT St,5····························· 'latch display
    PAUSE 1000······························· 'pasue fo 1sec

    next

    loop

    Reposted I had forgot the ' after Q7'

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 8/8/2007 11:58:45 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-08-08 14:29
    Hello,

    The Stamp Works Manual contains examples of not only controlling one 74HC595 but of daisy chaining them as well. The circuit schematics are included and there are source code downloads on the bottom of the page, as well as a PDF of the book. Take care.

    http://www.parallax.com/detail.asp?product_id=27297

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • gchrtgchrt Posts: 33
    edited 2007-09-17 08:18
    Hi,

    I am interested in daisy chaining 4 74hc595's to turn on a bank of LEDs.
    This is what I have so far:
    TurnOnLights:
      DEBUG CRSRXY, 2, 5, "Turning on lights"
      pattern = %11111111
      SHIFTOUT DataOut, Clock, MSBFIRST, [noparse][[/noparse]pattern]  ' send pattern to 74x595
      PULSOUT Latch, 5                              ' latch outputs
      RETURN
    


    This turns on all the LEDs except for the one on the 595's PIN15.
    Trying to turn the lights off again, using %00000000 with MSBFIRST or LSBFIRST doesn't work.
    This of course is for one 595.
    I just am not understanding the arguments needed in the SHIFTOUT to make this work.

    thanks for any help.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-09-17 08:27
    gchrt -

    Knowing how DataOut, Clock, Latch and pattern are defined will probably be helpful in troubleshooting your problem. Also, how is the 74x595 wired up?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • pwillardpwillard Posts: 321
    edited 2007-09-17 13:57
    You could use the PCF8574 and I2C.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    There's nothing like a new idea and a warm soldering iron.
  • gchrtgchrt Posts: 33
    edited 2007-09-17 16:16
    Hi,

    Bruce, here are my program definitions:
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------  
    '          ---(74hc595)---
    Clock           CON     0                       ' shift clock (74HC595.11)
    DataOut         CON     1                       ' serial data out (74HC595.14)
    Latch           CON     2                       ' output latch (74HC595.12)
    ' --------[noparse][[/noparse] variables ]---------------------------------------------------- 
    '          ---(74hc595)---
    pattern               VAR  Byte               ' output pattern
    
    



    attached is the schematic I used to hook up the 595.

    pwillard, thanks for the tip on the 8574. I'd like to understand the 595 setup first, but I can see the 8574 maybe simpler in execution.
    Cats are getting skinned.

    glenn
    309 x 215 - 26K
  • MctmarkMctmark Posts: 5
    edited 2007-11-01 17:11
    I have a 64 relays attached to to 8 - 74HC595. If I try and turn each one on and off in sequence sometimes it works and sometimes it turns on or off the wrong light. Does something have to be held "High" or is it the software?



    '
    [noparse][[/noparse] I/O Definitions ]
    Clock·········· PIN···· 0······················ ' shift clock (74HC595.11)
    SerData········ PIN···· 1······················ ' serial data (74HC595.14)
    Latch·········· PIN···· 2······················ ' output latch (74HC595.12)

    '
    [noparse][[/noparse] Constants ]
    DelayTime······ CON···· 200
    DelayTime1······ CON··· 200
    '
    [noparse][[/noparse] Variables ]
    pattern········ VAR···· Word··················· ' zig-zag pattern

    '
    [noparse][[/noparse] Initialization ]
    Reset:
    · LOW Latch···································· ' make output and low

    '
    [noparse][[/noparse] Program Code ]
    Main:
    ·· GOSUB Out_595······························ ' put pattern on 74x595·· 1
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00000000
    ···· GOSUB Out_595······························· ' put pattern on 74x595··· 2
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00000010
    ·· GOSUB Out_595······························· ' put pattern on 74x595··· 2
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00000100
    ·· GOSUB Out_595······························· ' put pattern on 74x595··· 3
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00001000
    ··· GOSUB Out_595······························ ' put pattern on 74x595··· 4
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00010000

    ··· GOSUB Out_595······························ ' put pattern on 74x595··· 5
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %00100000
    ···· GOSUB Out_595····························· ' put pattern on 74x595···· 6
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %01000000
    ··· GOSUB Out_595······························ ' put pattern on 74x595·· 7
    ··· PAUSE DelayTime···························· ' hold
    ···· pattern = %10000000

    · GOTO Main

    '
    [noparse][[/noparse] Subroutines ]
    Out_595:
    · SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern]· ' send pattern to '595
    · PULSOUT Latch, 5····························· ' latch outputs
    · RETURN
  • pwillardpwillard Posts: 321
    edited 2007-11-01 17:22
    Relays may be creating spikes on the power source causing some parts of the serial stream being sent to read incorrectly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    There's nothing like a new idea and a warm soldering iron.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-11-02 04:57
    Do you have a reverse biased diode on each relay?

    Also, placing a 0.1uF cap across Power and Ground (as close as possible to the pins) on the 74HC595's wouldn't hurt either.

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

    IC Layout Engineer
    Parallax, Inc.
  • MctmarkMctmark Posts: 5
    edited 2007-11-02 16:17
    I hook up some LEDs right off the 74HC595 and it is doing the same thing so I think it is my software. I want to control each of the 64 lights seperately for a christmas display but what is happening is each 8 segment of lights is turning on at the same time doing the same sequence. I want to be able to have the lights chase each other, smash in to each other, that sort of thing. Also in the subroutine what does the "5" stand for after latch
    Out_595:
    SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern] ' send pattern to '595
    PULSOUT Latch, 5 ' latch outputs
    RETURN

    Here is an example of part of a program:


    '
    [noparse][[/noparse] I/O Definitions ]
    Clock PIN 0 ' shift clock (74HC595.11)
    SerData PIN 1 ' serial data (74HC595.14)
    Latch PIN 2 ' output latch (74HC595.12)

    '
    [noparse][[/noparse] Constants ]
    DelayTime CON 200

    '
    [noparse][[/noparse] Variables ]
    pattern VAR Word ' zig-zag pattern

    '
    [noparse][[/noparse] Initialization ]
    Reset:
    LOW Latch ' make output and low

    '
    [noparse][[/noparse] Program Code ]
    Main:
    GOSUB Out_595 ' put pattern on 74x595 1
    PAUSE DelayTime ' hold
    pattern = %00000000
    GOSUB Out_595 ' put pattern on 74x595 2
    PAUSE DelayTime ' hold
    pattern = %00000010
    GOSUB Out_595 ' put pattern on 74x595 2
    PAUSE DelayTime ' hold
    pattern = %00000100
    GOSUB Out_595 ' put pattern on 74x595 3
    PAUSE DelayTime ' hold
    pattern = %00001000
    GOSUB Out_595 ' put pattern on 74x595 4
    PAUSE DelayTime ' hold
    pattern = %00010000

    GOSUB Out_595 ' put pattern on 74x595 5
    PAUSE DelayTime ' hold
    pattern = %00100000
    GOSUB Out_595 ' put pattern on 74x595 6
    PAUSE DelayTime ' hold
    pattern = %01000000
    GOSUB Out_595 ' put pattern on 74x595 7
    PAUSE DelayTime ' hold
    pattern = %10000000

    GOTO Main

    '
    [noparse][[/noparse] Subroutines ]
    Out_595:
    SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern] ' send pattern to '595
    PULSOUT Latch, 5 ' latch outputs
    RETURN
  • BeanBean Posts: 8,129
    edited 2007-11-02 17:14
    You must send the data for ALL of the '595s before toggling the latch pin.

    Make an array to hold the data for each '595:

    pattern VAR BYTE (8)
    


    Then change your Out_595 routine to:

    Out_595: 
      SHIFTOUT SerData, Clock MSBFIRST, [noparse][[/noparse]pattern(0), pattern(1), pattern(2), pattern(3), pattern(4), pattern(5), pattern(6), pattern(7)] 
      PULSOUT Latch, 5 
    RETURN
    

    Now in the main program just update the pattern array to change the pin states, then call Out_595 again.

    Let us know if this works for ya.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • MctmarkMctmark Posts: 5
    edited 2007-11-02 18:42
    Sorry Bean I have very little knowledge of how to program. Could you give me a short program so I can understand it and then I could extapolate on it.

    Thanks very much
Sign In or Register to comment.