Shop OBEX P1 Docs P2 Docs Learn Events
How to interface the 74HC595,and SN74HC165N chips with my BS2? — Parallax Forums

How to interface the 74HC595,and SN74HC165N chips with my BS2?

koehn29koehn29 Posts: 6
edited 2005-04-28 11:25 in BASIC Stamp
74HC595,and SN74HC165N

I need information on how to use the integrated circuts listed in the subject line.
I want to use them to add pins to my basic stamp.
Someone suggested that this was possible. Is there a pin map for these chips somewhere?
Better yet would be a detailed description on ow to set it up.

P.S. Maybe someone has already asked this question in the forum?
(How do I find it?)

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-03-31 13:12
    FORUM ADMIN:

    Here is another example of a message appearing on the forum WITH a perfectly good subject line, but when it appears in the email output, the subject line is COMPLETELY BLANK.
    This is an ongoing problem, and in this case the reader of the email message is held clueless since the message itself makes DIRECT REFERENCE to the (missing) SUBJECT LINE!

    Thanks for investigating this anomaly. If knew how to "bookmark" this message I would have reported it more appropriately in the support forum, but I've not figured out how to do that yet <sigh>.

    Regards,

    Bruce Bates (no smile, no wink, no grin!)<argh>
  • RickBRickB Posts: 395
    edited 2005-03-31 14:55
    koehn29 said... P.S. Maybe someone has already asked this question in the forum?

    (How do I find it?)



    This is why SEARCH needs to be fixed.

    Rick
  • koehn29koehn29 Posts: 6
    edited 2005-04-06 14:30
    Following is the program code for interfacing two 74HC595's two the basic stamp.
    I rechecked my wiring against the schematic.
    using this code i still do not get any high (+5V) signal on any output pin of either '595.
    What's wrong?
    Thanks, Ken



    ' ==============================================================================
    '
    ' File...... Ex23b - 74HC595 x 2.BS2
    ' Purpose... Expanded outputs with 74HC595
    ' Author.... Parallax
    ' E-mail.... stamptech@parallaxinc.com
    ' Started...
    ' Updated... 01 MAY 2002
    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    ' ==============================================================================
    '
    ' Program Description
    '
    ' This program demostrates a simple method of turning three Stamp lines into
    ' 16 outputs with two 74HC595 shift registers. The data lines into the second
    ' 74HC595 is fed by the SQh output (pin 9) of the first. The clock and latch
    ' pins of the second 74HC595 are connected to the same pins on the first.
    '
    ' I/O Definitions
    '
    ·DataOut CON 0 ' serial data out (74HC595.14)
    ·Clock CON 1 ' shift clock (74HC595.11)
    ·Latch CON 2 ' output latch (74HC595.12)
    '
    ' Constants
    '
    ·DelayTime CON 100
    '
    ' Variables
    '
    ·pattern VAR Byte ' output pattern
    ·counter VAR Byte
    · '
    ' Initialization
    '
    ·Initialize:
    ·LOW Latch ' make output and keep low
    ·pattern = %00000001
    '
    ' Program Code
    '
    ·Go_Forward:
    ·counter = counter + 1 ' update counter
    ·GOSUB Out_595
    ·PAUSE DelayTime ' put pattern on 74x595
    ·pattern = pattern << 1 ' shift pattern to the left
    ·IF (pattern = %10000000) THEN Go_Reverse ' test for final position
    ·GOTO Go_Forward ' continue in this direction
    ·Go_Reverse:
    ·counter = counter + 1
    ·GOSUB Out_595
    ·PAUSE DelayTime
    ·pattern = pattern >> 1
    ·IF (pattern = %00000001) THEN Go_Forward
    ·GOTO Go_Reverse
    '
    ' Subroutines
    '
    ·Out_595:
    ·SHIFTOUT DataOut, Clock, MSBFIRST, [noparse][[/noparse]counter] ' send counter to 2nd 74HC595
    ·SHIFTOUT DataOut, Clock, MSBFIRST, [noparse][[/noparse]pattern] ' send pattern to 1st 74HC595
    ·PULSOUT Latch, 5 ' latch outputs
    RETURN
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-06 14:47
    This looks like a StampWorks project (written by yours truly) and yours truly is human -- there is a schematic error. Notice how the schematic and the notes in the code don't agree on the connections? The data input on the 74x595 is pin 14 (not 11 as shown), and the clock input pin is 11 (not 14 as shown).

    The easiest fix is to update your constants:

    DataOut··· CON··· 1········ ' serial data out (74HC595.14)
    Clock····· CON··· 0········ ' shift clock (74HC595.11)
    Latch····· CON··· 2········ ' output latch (74HC595.12)

    An important lesson here is to double-check the manufacturer's data sheet for any part that you are trying to connect to.· StampWorks is due for a big update so we'll get that schematic sorted out -- sorry for the trouble my error caused you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • StarManStarMan Posts: 306
    edited 2005-04-07 16:19
    Could someone expand on how the "counter" works.· I have read the Stampworks articles 23a and 23b and I understand how the single 595 works but I still don't get how to address multiple 595's.··

    I've read the data sheet for Philips 74HC595 a couple of times and I must admit that like most data sheets it is somewhat indigestable for my level of understanding.·

    Every time I read a data sheet I wish I had one of you really smart guys available to answer my numerous basic questions.

    Chris Isaacson
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-07 16:21
    You wire the multiple '595 chips in a daisy-chain, then send enough bits down the chain to get to them all.

    So with one '595 you send 8-bits. With two '595 you send 16-bits, with three '595 you send 24 bits.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-07 16:39
    Chris,

    When you daisy-chain 595s the data in one can be pushed to the next by new data.· Let's say you have this setup:

    · Stamp --> [noparse][[/noparse]595 #1]
    [noparse][[/noparse]595 #2]

    When the Stamp sends data to #1 what is currently sitting in #1 gets pushed out to #2.· What's important to understand is that the internal registers aren't transferred to the 595 pins until the latch signal is received.· This works to our advantage; if we want to refresh both devices, first we send the data for #2 (it lands in #1, but this is temporary).· Now we send the data for #1.· What was in #1 (which belongs in #2) gets moved to #2 and #1 has its own data. NOW we chan blip the latch lines and the outputs are refreshed.

    I recently wrote in my column (Nuts & Volts) about the value of experimenting.· I promise that none of the explanations that you read here will match the value of an hour's worth of experimenting.· Connect LEDs to the outputs and start shifting values.· Use the DEBUG terminal to tell you what what's happening.·




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • StarManStarMan Posts: 306
    edited 2005-04-08 03:02
    Jon, Allan thank you for the replies.

    I have ordered some 595s to experiment with.· I'm pretty sure I understand what you're saying but·I guess I'm not sure of the output you're trying to achieve.· This is how I see it happening each time Out_595 is called:

    ···· [noparse][[/noparse]595 #1]········· [noparse][[/noparse]595 #2]

    ·· 00000000········· 00000001······ (first time)

    ·· 00000001········· 00000010······ (second time)

    ·· 00000010········· 00000011······ (third time)

    ·· 00000100········· 00000100······ (fourth time)

    ...and so on.· Is this correct?

    Chris Isaacson
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-08 05:50
    StarMan,

    ·· It might be better to look at it 8 bits (1 byte) at a time...When you power up your system the 595's will be empty:

    [noparse][[/noparse]595#1]·· [noparse][[/noparse]595#2]
    00000000 00000000

    ·· Once you've shifted the first byte out, it resides in 595#1, for example, if you shiftout a value of 74, it will now be in 595#1, 595#2 will still contain zero:

    [noparse][[/noparse]595#1]·· [noparse][[/noparse]595#2]
    01001010 00000000

    ·· On the next byte shifted out, say a value of 156, it will shift into 595#1, and what was in 595#1 will shift into 595#2:

    [noparse][[/noparse]595#1]·· [noparse][[/noparse]595#2]
    10011100 01001010

    ·· Now when you shiftout your next value, say 213, it will look like this:

    [noparse][[/noparse]595#1]·· [noparse][[/noparse]595#2]
    11010101 10011100

    ·· Of course, you're probably going to want to shiftout 2 bytes at a time each time so that you are re-loading both shift registers.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • StarManStarMan Posts: 306
    edited 2005-04-09 18:19
    Thanks Chris.

    I am clear on your explanation.· I will be having fun when I receive my 595s.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-09 21:28
    ·· I have a project coming up using them as well.· I will have 3 of them in a chain.· The 595's will make up about 1/4 of the project.· You will see it posted in the projects forum as soon as I have the information available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • koehn29koehn29 Posts: 6
    edited 2005-04-28 07:57
    I am finally back to the '595's in my project.
    I changed my constants like you suggested, Jon, but alas... still nothing
    my Chips are numbered 74HC595N. On the data sheet it says that the "N" variant (MM74HC595N) is a (PDIP) not an (SOIC).
    Would this make a difference?
    Ssshh... (I got these from parralax) If I have the right hardware, And I have it connected properly it would be working!
    I am reasonably sure (beyond the shadow of a doubt!) that I have it connected exactly according to the schematic.
    I have double checked my code, and all is in place. I bought 2 chips and both do absolutely nothing!
    So help me Anyone!!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-28 11:25
    Alas, you're still doing something wrong. Sorry to be blunt, but the x595 is really easy to work with an we use it all the time. Start with the circuit in the Helf file under SHIFTOUT. Get one device working first. Then add a second (the data-in on the second is fed from the data-out of the first). StampWorks shows how to chain them together. Double-check your connections and be patient; you'll get there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.