74HC595 serial parallel.
adelatoa
Posts: 11
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
http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf
Jim
The stamp manual on page 439 has a program for a 595 shift register also,,I was going to build tomorrow actually.
StampWorks is My favorite!
'
Some of Jonny Mac's Best!
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.
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
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
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
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
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.
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
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?
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?
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.
video suggests that but.....you didn't include your 595 schematic in posts.....
I was using the schematic on the experiment #23 (link to schematic):
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.
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
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.
Maybe something like this:
Chase:
FOR x = 0 TO 13 'number of relays
High x
Pause 500
Low x
NEXT ' loop until x > 13
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
Jim
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
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