Shop OBEX P1 Docs P2 Docs Learn Events
74HC595 serial parallel. — Parallax Forums

74HC595 serial parallel.

adelatoaadelatoa Posts: 11
edited 2010-11-08 15:47 in BASIC Stamp
Hi. I'm trying to learn to use the 74hc595 with the shif out commands. Are there any tutorials out there on understanding the basics, learning to wire it using a bs2, and programing it? Thanks in advance.

Comments

  • hover1hover1 Posts: 1,929
    edited 2010-10-22 03:39
    Experment #23 in the StampWorks book, is a great place to start.

    http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf

    Jim

    adelatoa wrote: »
    Hi. I'm trying to learn to use the 74hc595 with the shif out commands. Are there any tutorials out there on understanding the basics, learning to wire it using a bs2, and programing it? Thanks in advance.
  • youngbillyoungbill Posts: 54
    edited 2010-10-23 00:18
    Hover,that was great reading,A very good explaination of the common code instructions.
    The stamp manual on page 439 has a program for a 595 shift register also,,I was going to build tomorrow actually.
  • $WMc%$WMc% Posts: 1,884
    edited 2010-10-23 13:36
    hover1 wrote: »
    Experment #23 in the StampWorks book, is a great place to start.

    http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf

    Jim
    '
    StampWorks is My favorite!
    '
    Some of Jonny Mac's Best!
  • adelatoaadelatoa Posts: 11
    edited 2010-10-23 16:55
    youngbill wrote: »
    Hover,that was great reading,A very good explaination of the common code instructions.
    The stamp manual on page 439 has a program for a 595 shift register also,,I was going to build tomorrow actually.

    Would you be kind to snap some pictures on how you wire it? I am having trouble understanding which wires go where. My confusion is wiring between stamp and the 74hc595 chip. I am basically going yo install this 74hc595n to a eight relays triggering each a valve. In the end they will be fired in sequence creating a chase in my fountain.

    Does anyone have this 74hc595N? This was shipped from parallax and the spec sheet on the website is for the 74hc595 and not for the 74hc595N chip they shipped me.
  • hover1hover1 Posts: 1,929
    edited 2010-10-23 17:40
    The schematic in the StampWorks manual clearly shows the connection to the BS2. P0 (Basic Stamp Pin 5) connected to 74HC595 Pin 11 and so on.

    Page 3 of the Datasheet shows a 74HC595N as being a 16 Pin plastic DIP which is what Parallax sells. The "N" is just a package and temp range suffix.

    Hope that helps.

    Jim

    adelatoa wrote: »
    Would you be kind to snap some pictures on how you wire it? I am having trouble understanding which wires go where. My confusion is wiring between stamp and the 74hc595 chip. I am basically going yo install this 74hc595n to a eight relays triggering each a valve. In the end they will be fired in sequence creating a chase in my fountain.

    Does anyone have this 74hc595N? This was shipped from parallax and the spec sheet on the website is for the 74hc595 and not for the 74hc595N chip they shipped me.
    794 x 520 - 36K
    129 x 299 - 9K
  • adelatoaadelatoa Posts: 11
    edited 2010-10-23 20:24
    This is my Issue.. I get confused because the 74hc595N has has pins called out differently than the 74hc595.

    Data Spec sheet on 74HC595N (this chip was mailed to me from Parallax, did they send me the wrong chip perhaps??):

    http://www.datasheetcatalog.org/datasheet/philips/74HC_HCT595_CNV_3.pdf
    666 x 948 - 121K
  • LeonLeon Posts: 7,620
    edited 2010-10-24 04:35
    Different manufacturers used different names for the signals. Go by the pin numbers.
  • youngbillyoungbill Posts: 54
    edited 2010-10-27 14:39
    I built and tested the 595 circuit, It basicly is a counter,,any ideas how to make it into a lamp chaser,,but with the leds going on in a row,,and staying on
  • sumdawgysumdawgy Posts: 167
    edited 2010-10-29 05:42
    (After posting...and reviewing I noticed that this "might" have need a new thread. It's still on topic though..... Sigh. Forum ettique can be so confusing & demanding.)

    Making a lamp chaser....once you "understand" the 595...it will be simple.
    Bearing in mind the 595 IS NOT a counter but rather a storage device.

    You've played with the project and read the material..
    http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf (pg 130)
    Obviously, it doesn't eplain the 595 very well....

    It has 2 "memory banks" actually.
    Bank1--(Shift mem)--is used to serially "load" your 8 bits into the 595.
    Bank2--(Out mem)--drives the output pins and mirrors bank1's state when, you "Latch"

    So, you can shift data into the 595 all day long and NOT affect the outputs.....
    I used Lookup to load my registers to control my dishwasher project...
    http://forums.parallax.com/showthread.php?t=123064&highlight=sumdawgy

    i just tracked the "step" of the program and shifted in the next number....
    (I also used a BS1 so I had to "write" a shift routine..not hard ..just uses space.)

    I.E. step1 00000001, step2 00000011, etc (or any combination)

    note: step1=1 and step 2=3....
    you can use binary or decimal in your program you'll just have to notate the binary with "%"

    There's a project in stampworks that controls a stoplight setup using "drum" programing... much like this... Ill find it later and post it....

    Hope this gets you further down the track??

    OH! you may want to look at using a darlington to drive the relays? (Page 11 & 12 of my notes have the schematics you'll want to consider....)

    -dawgy
  • youngbillyoungbill Posts: 54
    edited 2010-10-29 11:54
    Great document,,,very well commented,,,Sumdawgy. Here is my problem,question,,,I attached my code,,it uses lookup,,to do a light chaser,,with a bs-2,,,and a 595.
    But I want two 595 units. I tried 16 bit constant,,,but that does not make sense,,( ie if you had 3 -595's then what)..the example code in stamp works seems to have both 595,,outputting at the same time.
    What I want is for the first 8 leds to shift on,,in a row,and stay on,,and then the next 8 leds ( the next 595)to chase on,,and stay on. shift command shifts a zero in,,,so the pattern is only one led on,,,I want all leds off,,,and the lit led shifts over,,followed by another lit led.
    Any help...I think another lookup table is the answer,,,but,,its not working.
    Is there a way to shift a one IN?

    Ahh this second code does work,,,The problem was a missing 10k resistor on data pin 12 to stop noise
  • adelatoaadelatoa Posts: 11
    edited 2010-11-03 21:55
    The latest is that I have have my PDB running with a BS2P40 stamp controlling 28 solenoid valves and a fog machine. In addition to the 28 solenoid valves I have a 74HC595 serial parallel chip controlling an additional 8 solenoid valves which I want to control in the same fashion as the first 28. I basically want to control each one:

    High 1
    Pause 1000
    Low 1

    ....and on to the next nozzle using the same above commands.

    Does anyone know how to do this in that same way with out using the fancy codes?

    Please help desperate eager to program as the wedding is in 10 days.
  • ercoerco Posts: 20,256
    edited 2010-11-04 13:49
    Two offbeat methods you may consider:

    74LS138 decoder: Just 3 Stamp pins give you binary control over 8 outputs, only one on at a time. Have a look at http://www.electronics-tutorials.ws/combination/comb_5.html .

    LM3914 analog bargraph chip: Analog voltage in drives 10 outputs, you select one on (dot mode) or all on (bargraph mode) mode http://www.national.com/ds/LM/LM3914.pdf
  • adelatoaadelatoa Posts: 11
    edited 2010-11-05 00:57
    Houston we have a problem:

    Managed to get the 74HC595 installed on my BS2P40 PDB. There is an issue when I reset the stamp. When I go to touch the resistor it looks to be get started and stall. Check out the video:

    http://www.adelatoa.phanfare.com/4653707#imageID=114472366

    Can this issue be triggered by the Solid State Relays?

    Can this issue be triggered by the 10K resistor?
  • sumdawgysumdawgy Posts: 167
    edited 2010-11-05 12:05
    adelatoa wrote: »
    Houston we have a problem:

    Sorry... I was expecting to get a E-mail notifier about posts to the thread.....since the forum change it seems I have to lookup that option again.....

    I was/am busy with a few things in REAL LIFE (there's more than the internet?? :))

    I saw the vid w/the breadboard circuit...saw the scematic leading to the valves...but NOT the one for the actual breadboard circuit... i have to follow the other 2 links you listed ....But I won't be able to for another 3-4 hours..;.I understand the 10...uh 9 day issue so...I'll make certain to return..

    Uh... the 10k resistor for noise.....where's that going and why is it so criticle again?? I should find out form the notes..IF you poseted the breadboarded circuit schematic...if you didn't would you..and explain that resistor a bit more...seems to critically affecting you project.....solid state relays should be helping...and I assume your power supply is filtered....you did set up an isolated (diode cap minimum) supply that feeds the stamp & 595(s) right?
  • sumdawgysumdawgy Posts: 167
    edited 2010-11-05 21:03
    youngbill wrote: »
    But I want two 595 units. I tried 16 bit constant,,,but that does not make sense,,( ie if you had 3 -595's then what)..

    595's have serialout pin.....tie that to the serial in pin of the next 595....and...you tie both clocks & latches of the 2 595s together... then they will shift data thru the first 595 to the second, allowing you 16bits (or more if u add more chips) So yes, you COULD have 3 or more....not sure if "shiftout" handles more...you may have to write yer own shift out.

    altho this might be a bit late to help you.
  • sumdawgysumdawgy Posts: 167
    edited 2010-11-05 21:04
    adelatoa wrote: »
    Houston we have a problem:

    Can this issue be triggered by the 10K resistor?


    video suggests that but.....you didn't include your 595 schematic in posts.....
  • adelatoaadelatoa Posts: 11
    edited 2010-11-07 10:42
    Update:

    I was using the schematic on the experiment #23 (link to schematic):

    Image-4936703-114643383-2-Web_0_c4db50c20e7342d7e48aa62ba6df738d_1

    Solution to the 74HC595 video issue was the re-configuring of my pins. Originally I had main valves on MainIO pins 0-13 and aux valves on AuxIO pins 0-13 of the PDB using the BS2P40 stamp. I then used Main pin #14(for Clock), Aux pin 14(for Data), and Aux pin #15 (for the Latch) of the 74HC595.

    I re-configured using Main pins #0(clock), #1(data), and #2(latch) for the 74HC595. I then used MainIO pins 3-15, and AuxIO #14 for the main Valves, while using AuxIO's 0-13 for the Aux valves.

    New development issues:
    I have a programing mind of an architect so please bear with me.:smilewinkgrin:

    Issue #1 "GOSUB"
    I want to have several different subroutines of what I call "chases" which are long and would like to use many times through out the "show".

    Is it possible to program several different routines and call them out? Can they each be called out numerous times?

    Issue #2 "GOTO"

    May I call different sub routines using this GOTO command and still be able to maintain my original place in the program? For example:

    Main: 'show

    command 1
    command 2
    GOTO Routine A
    command 3
    command 4
    GOTO Routine B
    command 5
    command 6
    GOTO Routine C
    command 7

    END

    Routine A:
    list of commands

    Routine B:
    list of commands

    Routine C:
    list of commands

    My question is how do I go between GOTO's and continue my "show"?


    Issue #3 Shorting commands

    I have 14 valves using MainIO pins 0-13. I am entering each one of them seperately for example:

    Chase:
    High 0
    Pause 500
    Low 0

    High 1
    Pause 500
    Low 1

    High 2
    Pause 500
    Low 2

    ...and so on until valve #13.

    Question is how do I shorten my command? I would like to shorten and read:

    Set off Main valves 0-13 with a pause of 500.

    Thanks in advance...tired and sleep less groom in Burbank. I am not so nervous of wedding as I am nervous of not getting a show going for the day of.
  • hover1hover1 Posts: 1,929
    edited 2010-11-07 11:24
    adelatoa wrote: »
    Update:

    I was using the schematic on the experiment #23 (link to schematic):

    Image-4936703-114643383-2-Web_0_c4db50c20e7342d7e48aa62ba6df738d_1

    Is this the schematic you want to used? It is a 74165 Parallel-In/Serial-Out. That is from Experiment #24. You want experiment #23.

    Jim
  • hover1hover1 Posts: 1,929
    edited 2010-11-07 11:26
    [QUOTE=a
    May I call different sub routines using this GOTO command and still be able to maintain my original place in the program? For example:

    Main: 'show

    command 1
    command 2
    GOTO Routine A
    command 3
    command 4
    GOTO Routine B
    command 5
    command 6
    GOTO Routine C
    command 7

    END

    Routine A:
    list of commands

    Routine B:
    list of commands

    Routine C:
    list of commands

    [/QUOTE]

    Use GOSUB instead of GOTO and a RETURN at the end of the GOSUB.
  • hover1hover1 Posts: 1,929
    edited 2010-11-07 11:32
    adelatoa wrote: »
    Update:


    Issue #3 Shorting commands

    I have 14 valves using MainIO pins 0-13. I am entering each one of them seperately for example:

    Chase:
    High 0
    Pause 500
    Low 0

    High 1
    Pause 500
    Low 1

    High 2
    Pause 500
    Low 2

    ...and so on until valve #13.

    Question is how do I shorten my command? I would like to shorten and read:

    Set off Main valves 0-13 with a pause of 500.

    Thanks in advance...tired and sleep less groom in Burbank. I am not so nervous of wedding as I am nervous of not getting a show going for the day of.

    Maybe something like this:

    Chase:

    FOR x = 0 TO 13 'number of relays
    High x
    Pause 500
    Low x

    NEXT ' loop until x > 13
  • adelatoaadelatoa Posts: 11
    edited 2010-11-07 16:05
    hover1 wrote: »
    Use GOSUB instead of GOTO and a RETURN at the end of the GOSUB.

    GOSUBS are working great thanks.... the High, Pause, and Low not so well. Its asking for info on the X
  • hover1hover1 Posts: 1,929
    edited 2010-11-07 16:43
    adelatoa wrote: »
    GOSUBS are working great thanks.... the High, Pause, and Low not so well. Its asking for info on the X

    You need to define x in your Variables section
    x     VAR    BYTE
    
    

    Jim
  • adelatoaadelatoa Posts: 11
    edited 2010-11-08 15:09
    Latest development:

    I have tried all the subroutines on individual files and they all worked fine. The latest issue is that the fountain is getting stuck on SubRoutine "L2R_CHASE" as its not going onto the next command. FYI the "L2R_CHASE"(highlighted in Red where it is getting stuck) is programmed using the SHIFTOUT command. The show ends there at the command and does not go onto the next command. Can someone help me out in writing that subroutine "L2R_CHASE"(highlighted in green at the bottom of the page) so that it gets out of that LOOP? Do I even need a Loop? The following is my code:

    WEDDING FOUNTAIN CODE

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    'THIS IS THE WEDDING'S MAIN SHOW FOR NOV 13,2010

    '
    [ I/O definitions ]

    clock PIN 0 'PIN NUMBER 11 ON 74HC595.11
    serData PIN 1 'PIN NUMBER 14 ON 74HC595.14
    Latch PIN 2 'PIN NUMBER 12 ON 74HC595.12

    '
    [ constants ]

    DelayTime CON 200


    '
    [ variable ]

    pattern VAR Byte

    '
    [intialization]

    Reset:
    LOW latch
    pattern= %00000001


    '
    SHOW SHOW SHOW SHOW

    ELSHOW:

    DO
    MAINIO
    HIGH 6
    HIGH 7
    PAUSE 500
    LOW 6
    LOW 7
    PAUSE 1500
    HIGH 13
    HIGH 14
    PAUSE 1500
    LOW 13
    LOW 14

    GOSUB MN_CCCOUNTERCW
    MAINIO
    GOSUB L2R_CHASE '<<<Stuck here and does not go to "MN_CCOUNTERCW"
    MAINIO
    GOSUB MN_CCCOUNTERCW
    LOOP


    '
    [ SUBROUTINES ]

    MN_CCCOUNTERCW: '>>>>>>>>>>>MAIN CIRCLE CHASE COUNTER-CLOCKWISE<<<<<<<<<<<<
    MAINIO 'switching to Main I/O's

    HIGH 3
    PAUSE 50
    LOW 3

    HIGH 4
    PAUSE 50
    LOW 4

    HIGH 5
    PAUSE 50
    LOW 5

    HIGH 6
    PAUSE 50
    LOW 6

    HIGH 7
    PAUSE 50
    LOW 7

    HIGH 8
    PAUSE 50
    LOW 8

    HIGH 9
    PAUSE 50
    LOW 9

    HIGH 10
    PAUSE 50
    LOW 10

    HIGH 11
    PAUSE 50
    LOW 11

    HIGH 12
    PAUSE 50
    LOW 12

    HIGH 13
    PAUSE 50
    LOW 13

    HIGH 14
    PAUSE 50
    LOW 14

    HIGH 15
    PAUSE 50
    LOW 15

    AUXIO 'Switching to AUX I/O's
    HIGH 15
    PAUSE 50
    LOW 15
    RETURN

    MN2_CCCLOCKW: '>>>>>>>>>MAIN CIRCLE CHASE CLOCKWISE<<<<<<<<<<<<<
    AUXIO 'Switching to Aux I/Os

    HIGH 15
    PAUSE 50
    LOW 15

    MAINIO 'Switching to Main I/O's

    HIGH 15
    PAUSE 50
    LOW 15

    HIGH 14
    PAUSE 50
    LOW 14

    HIGH 13
    PAUSE 50
    LOW 13

    HIGH 12
    PAUSE 50
    LOW 12

    HIGH 11
    PAUSE 50
    LOW 11

    HIGH 10
    PAUSE 50
    LOW 10

    HIGH 9
    PAUSE 50
    LOW 9

    HIGH 8
    PAUSE 50
    LOW 8

    HIGH 7
    PAUSE 50
    LOW 7

    HIGH 6
    PAUSE 50
    LOW 6

    HIGH 5
    PAUSE 50
    LOW 5

    HIGH 4
    PAUSE 50
    LOW 4

    HIGH 3
    PAUSE 50
    LOW 3
    RETURN


    AX_CCCOUNTERCW: '>>>>>>>>>>>>>>>>AUXILIRARY CIRCLE -COUNTERCLOCKWISE<<<<<<<<<<<<<<<<<

    AUXIO
    HIGH 0
    PAUSE 50
    LOW 0

    HIGH 1
    PAUSE 50
    LOW 1

    HIGH 2
    PAUSE 50
    LOW 2

    HIGH 3
    PAUSE 50
    LOW 3

    HIGH 4
    PAUSE 50
    LOW 4

    HIGH 5
    PAUSE 50
    LOW 5

    HIGH 6
    PAUSE 50
    LOW 6

    HIGH 8
    PAUSE 50
    LOW 8

    HIGH 9
    PAUSE 50
    LOW 9

    HIGH 10
    PAUSE 50
    LOW 10

    HIGH 11
    PAUSE 50
    LOW 11

    HIGH 12
    PAUSE 50
    LOW 12

    HIGH 13
    PAUSE 50
    LOW 13
    RETURN

    AX2_CCCLOCKW: '>>>>>>>>>>>>>>>AUXILIARY CIRCLE CHASE CLOCKWISE<<<<<<<<<<<<<<<<<
    AUXIO
    HIGH 13
    PAUSE 50
    LOW 13

    HIGH 12
    PAUSE 50
    LOW 12

    HIGH 11
    PAUSE 50
    LOW 11

    HIGH 10
    PAUSE 50
    LOW 10

    HIGH 9
    PAUSE 50
    LOW 9

    HIGH 8
    PAUSE 50
    LOW 8

    HIGH 7
    PAUSE 50
    LOW 7

    HIGH 6
    PAUSE 50
    LOW 6

    HIGH 5
    PAUSE 50
    LOW 5

    HIGH 4
    PAUSE 50
    LOW 4

    HIGH 3
    PAUSE 50
    LOW 3

    HIGH 2
    PAUSE 50
    LOW 2

    HIGH 1
    PAUSE 50
    LOW 1

    HIGH 0
    PAUSE 50
    LOW 0
    RETURN

    L2R_CHASE: 'LEFT TO RIGHT
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern]
    PULSOUT Latch, 5
    PAUSE delaytime
    pattern = pattern << 1
    LOOP UNTIL (pattern = %10000001)
    RETURN


    R2L_CHASE: 'RIGHT TO LEFT
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern REV 8]
    PULSOUT Latch, 5
    PAUSE Delaytime
    pattern = pattern << 1
    LOOP UNTIL (pattern = 00000001)
    RETURN

    LL_ZIGZAG: 'Chase starts at Left returning to end on Left side
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern]
    PULSOUT Latch, 5

    PAUSE delaytime
    pattern = pattern << 1
    LOOP UNTIL (pattern = %10000000)
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern]
    PULSOUT Latch, 5

    PAUSE Delaytime
    pattern = pattern >> 1
    LOOP UNTIL (pattern = %00000011)
    RETURN

    RR_ZIGZAG: 'Chase start on Right side returning to end on right side
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern REV 8]
    PULSOUT Latch, 5

    PAUSE delaytime
    pattern = pattern << 1
    LOOP UNTIL (pattern = %10000000)
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern REV 8]
    PULSOUT Latch, 5

    PAUSE Delaytime
    pattern = pattern >> 1
    LOOP UNTIL (pattern = %00000011)
    RETURN
  • hover1hover1 Posts: 1,929
    edited 2010-11-08 15:47
    adelatoa wrote: »
    Latest development:



    L2R_CHASE: 'LEFT TO RIGHT
    DO
    SHIFTOUT Serdata, Clock, MSBFIRST, [pattern]
    PULSOUT Latch, 5
    PAUSE delaytime
    pattern = pattern << 1
    LOOP UNTIL (pattern = %10000001)
    RETURN


    A very quick, and I mean quick look see , shows your pattern to start out at pattern= %00000001. If you SHIFT LEFT, you would never reach a pattern of %10000001, so the best you could do is stop when pattern = %10000000.

    Jim

    Jim
Sign In or Register to comment.