Difficulty with the 74HC595
Agent Cobalt
Posts: 88
I'm currently working on a project and found myself needing more outputs than the propeller could provide. I had a few 74HC595's hanging around my parts bins and decided to use them. I've never actually used the 74HC595 before and so I decided to see if there was an object I could use on the OBEX. I came across Dennis Ferron's object pack and am using the 74HC595_Regular object. My project has 2 74HC595's cascaded in the following manner:
The problem I'm experiencing is that in using the call to set the outputs, the outputs of both 74HC595's are the exact same.
Here's a snippet of code in which I'm setting the outputs:
Now, according to Dennis's object, you send out the 8 bits as the first parameter and the second parameter is which chip in the cascade.
Determined to try and find a working method, I tried my hand at using the SPI object that is in the Propeller library. This one yielded a more entertaining effect as the outputs from the chips are not even matching the bit pattern I would send out with the object regardless of whether I sent it out using MSB first or LSB first.
I've tried different things to try to get the chips working in cascade, but other changes ended up not working or working partially, but the outputs on one chip would be 'ghosted' on the other in that the LEDs (used to see the output states) would be slightly light on the ghost pins. Any pointers or ideas with what I'm doing wrong would be helpful as I've never used this chip nor have I used any chips that use the SPI protocol so I don't know much about it either.
┌──────┐ QB ┫1• 16┣ Vcc QC ┫2 15┣ QA QD ┫3 14┣─────────────────────────────── ← A (Data in from Propeller) QE ┫4 13┣─────────────────────• Output Enable (Tied to ground) QF ┫5 12┣───────────────┐ QG ┫6 11┣─────────────┐ │ QH ┫7 10┣──────────────────┐ gnd ┫7 9┣───────┐ QH' │ │ │ └──────┘ │ │ │ │ │ │ │ │ ┌──────┐ │ │ │ │ QB ┫1• 16┣ Vcc │ │ │ │ QC ┫2 15┣ QA │ │ │ │ QD ┫3 14┣───────┘ A │ │ │ QE ┫4 13┣─────────────│─│──│───• Output Enable (Tied to ground) QF ┫5 12┣─────────────│─┻──│───• Latch Clock (to LatchPin from Propeller) QG ┫6 11┣─────────────┻────│───• Shift Clock (to ClockPin from Propeller) QH ┫7 10┣──────────────────┻───• RESET (to Propeller's Reset pin) gnd ┫7 9┣ Qh' └──────┘
The problem I'm experiencing is that in using the call to set the outputs, the outputs of both 74HC595's are the exact same.
Here's a snippet of code in which I'm setting the outputs:
HC595.Out(Main, 0) 'Output main signals to chip 0. HC595.Out(Cross, 1) 'Output aux signals to chip 1.
Now, according to Dennis's object, you send out the 8 bits as the first parameter and the second parameter is which chip in the cascade.
Determined to try and find a working method, I tried my hand at using the SPI object that is in the Propeller library. This one yielded a more entertaining effect as the outputs from the chips are not even matching the bit pattern I would send out with the object regardless of whether I sent it out using MSB first or LSB first.
SPI.SHIFTOUT(Dat_595_1, Clk_595_1, SPI#MSBFIRST , 16, %0001000100000001) ToggleLatch(Ltc_595_1)
I've tried different things to try to get the chips working in cascade, but other changes ended up not working or working partially, but the outputs on one chip would be 'ghosted' on the other in that the LEDs (used to see the output states) would be slightly light on the ghost pins. Any pointers or ideas with what I'm doing wrong would be helpful as I've never used this chip nor have I used any chips that use the SPI protocol so I don't know much about it either.
Comments
Also, everything is wired correctly according to the diagram above.
When using this driver with two 595s in a chain you would send the value to the outer device first without latching, then the inner with the latch:
After the first leds.out() the value for the outer device is in the inner device's holding register but not latched to the outputs. On the second leds.out() call the outer bits are pushed out of the inner device -- now you can use the latch to transfer the holding registers of both devices to their respective outputs.
Post Edited (JonnyMac) : 7/4/2009 3:02:27 PM GMT
If the output is duplicated, I suspect that you tried it at least twice. If you shift by the wrong number of outbuts (in your case 8), the output gets duplicated. I didn't have a look at your object.
Oh, the diagram in the 1# posting is quite clobbered. Seems I have a different font than you.
HTH,
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
the 595 clock and latch trigger on a certain TRANSITION low-high or high-low (I don't remember)
did you carefully check this ?
how about using a debugging program that does the following
shift in 1 bit toggle latch %1
shift in 2 bits toggle latch %10
...
shift in 8 bits toggle latch %10000000
shift in 9 bits toggle latch %100000000
....
to see what is happening in detail step by step
best regards
Stefan
Rising edge.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
A problem I've run into is, if I'm using 5V on the HC595 chips, then you can't drive them directly from propeller pins. The Vih minimum high-level input volatage for the HC595 is around 3.2V. If you drive it from the prop, you'll get intermittent signals.
I solved this by running the signals through a 74HCT365 buffer with a 5V VCC.
This probably isn't your problem, but I thought I'd mention it, just in case.
Jim
Why to use 5V with the HC595 plus a 74HCT365 ???, you could simple use 3.3Vcc to power HC595 with any problems.
@Agent Cobalt.
I ever used the suggested circuit for cascade two HC595 in the Basic Stamp Manual... it works perfect. (It is the experiment #23b) Be carrefully, you'll need a 10k resistor to GND in the latch pins of the HC's.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Good point about using a lower VCC. The only reason I used 5V was that I needed 5V output from the HC595.
I could also have used 74HCT595 chips, but the HC595's are MUCH cheaper, I believe $0.11, and my board has 17 of them. I only need 2 HCT365's.
Besides, it was a good learning experience. [noparse]:)[/noparse] Figuring out why it didn't work the first time.
Thanks for asking.
Jim
I don't believe you need a pull-down resistor on the latch pin of the HC595, as long as you're driving it explicitly, both high and low, with the propeller pin.
I don't use a pull-down on my board and it works fine.
Jim