74HC595 High all Ports
PlayLikeFabian
Posts: 8
Hey all,
I recently bought a BS1 'cause I wanna build kind of an 'orientation system' for blind people. For this project I need more than 8 ports, so I ordered the 74HC595.
I'm not that into programming the BS1 and I already know, that I need to reset SHIFTIN and SHIFTOUT.
So I only need outputs, because I can easily connect the inputs to my usual ports. Imagine if I wanted to high every single port by the shift register. I already did some research but I'm not really sure, how to do it properly.
I would be fine, if you only showed me, how to set the shift-ports high, that I want to have high.
Here's my code so far:
So tbh, even yet it's not working. I just wanted to turn the ports of my shift register on and off again. Any help or at least tried help would be appreciated so much.
Thanks,
PlayLikeFabian
I recently bought a BS1 'cause I wanna build kind of an 'orientation system' for blind people. For this project I need more than 8 ports, so I ordered the 74HC595.
I'm not that into programming the BS1 and I already know, that I need to reset SHIFTIN and SHIFTOUT.
So I only need outputs, because I can easily connect the inputs to my usual ports. Imagine if I wanted to high every single port by the shift register. I already did some research but I'm not really sure, how to do it properly.
I would be fine, if you only showed me, how to set the shift-ports high, that I want to have high.
Here's my code so far:
' {$STAMP BS1} OUTPUT 1 OUTPUT 2 OUTPUT 3 start: B0=%00000000 GOSUB ShiftOut PAUSE 500 'OnOff: B0=%11111111 DEBUG CLS, "on" GOSUB ShiftOut PAUSE 1000 B0=%00000000 DEBUG CLS, "off" GOSUB ShiftOut PAUSE 1000 'GOTO OnOff END ShiftOut: FOR B11=1 TO 8 PIN0=BIT7 PULSOUT 1, 1 B0=B0*2 NEXT PULSOUT 2, 1 RETURN
So tbh, even yet it's not working. I just wanted to turn the ports of my shift register on and off again. Any help or at least tried help would be appreciated so much.
Thanks,
PlayLikeFabian
Comments
Page 130 if page 140 of the pdf.
Do you have '595 pin 13 OE grounded?
Do you have '595 pin 10 SRCLR pulled high?
Your code looks good to me. What happens when you run it?
Edit: The above list is incorrect. It should be
Looks like he wrote a subroutine called "shiftout"
Now I'm wondering if I was having a seniors moment or the code was edited between looking at it and composing a reply.
Yes I edited it from "spoiler" to "code" so it would be more readable.
Welcome to the forum!
We will try and find a solution.
@Duane Degn
Setup looks quite fine to me. Should be the code I'm struggling with.
My LEDs just turn on and stay on forever. I only wanted it to stay turned on for 1 second.
I don't quite get the things about PIN13 OE and the other line to be honest. Sorry about me being that dumb, but I'm new to all of this.
By LEDs, I am thinking you have LEDs with series resistors to ground on each Q.
You enable pins 1, 2, and 3 at the beginning and then use pins 0, 1, 2 in your shift routine.
In the beginning,
or better still
I promise we can help you to make this work.
Also, I'm not sure what you mean when you are confused how to get that loop included in my program. Copy and paste?
And it didn't really work, so maybe I have to swap them too.
Maybe my understanding of a shift register isn't what it should be. I now don't really get the function.
The '595 (data sheet is here) is a little more than a simple shift register; it also contains a storage register. That way the parallel outputs don't change more or less randomly while the shifter is being loaded. The FOR/NEXT loop loads eight bits, one at a time, into the shift register. The PULSOUT 2,1 provides a positive edge that loads the storage register and thence the outputs.
I programmed a simple counter only so I could observe the outputs (connected to LEDs) and thus convince myself that the setup was working.
You could call shiftout a "driver". My little program that incremented B2 could be called a test program or demo.
A1Y: If so, what is your real question? Do you want help in connecting the sensors and speakers?
A1N (Q2): If not, did you make the changes to P0 and P2 I pointed out?
A2Y: If so, show me. Post a photo of your board that clearly and unambiguously shows the connections along with the code.
A2N: If not, why not.
Q3: If you are using Ping sensors, they need one I/O each. That is three, plus three for the speakers for a total of six. A BS-1 has eight I/Os. Are you sure you need an expander in the first place?