Shift-registers or latches?

Grogster

Senior Member
Hi all.
:)

Wanting to expand the number of outputs on a chip using the likes of a shift-register or latch.

What I need, is the ability to load all the bits into the register or latch, with all the output pins on the register/latch high(probably using external pull-ups unless the default for the pins is high), and then when commanded, the whole port goes active - similar to the pins=%10000100 command, where the whole port can be read or written at once.

Lets say that I loaded a high into bits 2 and 8 of an 8-bit latch such as a 74HC595, then pulsed the LATCH pin - would this make all pins on the latch switch to whatever was loaded into them from the PICAXE?

Shifting the binary through the cells is not suitable, as I want to control a voice-recorder chip, and the 8 inputs on that chip are held high, and you pull low one of the 8 pins to play a message. Shifting the 0's and 1's through an "Active all the time" shift register port will make the voice recorder play messages I don't want played. :p

Hopefully you can see what I mean...

So, will a latch allow me to do this, or do I have the wrong end of the stick?
 

westaust55

Moderator
Yes the 74HC595 will do as you seek in terms of a shift register latch mechanism.

You can shift the data serially into the 74HC595’s and when the data is in place within the internal shift registers, pulse the output latch control line to shift the data from the internal shift registers to the output latches. In that way the outputs do not change as the data ripples through.
Note that the 74HC595 outputs ARE open collector or tri state. When the OE line ishigh, the outputs are neither driven high or driven low. So pull-up resistors could be used.

If you can live with the time to shift in 8 bits and transfer to the outputs to make the outputs all high between your control actions (ie you are effectively holding a control into the voice recorder in the active state until you shift the new clearing byte into the 74HC595) then all is well.
Otherwise you may need to consider an octal buffer with tri-state outputs.

Hope the above is clear enough for you


Let us know if the short delay is an issue. If so we can help locate a more suitable chip.
 
Last edited:

moxhamj

New Member
A 595 would be perfect. As westy says, the data only ripples through internally. Externally, you can have one pin going high and low with complete control. A 595 is both a shift register and a latch.

There are 3 control lines - data, clock and latch. You clock the 8 bits in using the data and clock lines, lets say 00100000. Then you send that out to the real world with a latch pulse, and that one line goes high and the rest are low. Then to turn that one line off, send out 00000000 via the clock and data lines, and then latch it again.

an HC595 expands 3 lines to 8 lines. You can daisy chain HC595s as long as you like - it just makes things slower.

Or, if you want speed, you can have (say) an 8 bit bus, 3 control lines, one line for latch, and expand the 3 address lines to 8 with a HC138. Then use eight HC373 chips. That expands 13 lines to 64 and is 8x faster than the HC595 solution.

The HC595 and the 08M go together well. Code and schematic for a 3 line to 16 line expander is here http://www.picaxeforum.co.uk/showthread.php?t=9116&highlight=hc595
 
Last edited:

Grogster

Senior Member
Thanks guys - exactly what I wanted to know - I will set about breadboarding the idea now.
:)

Time delay while shifting the bits in the latch is no problem, provided the voice-recorder can be tripped within a second or so of being asked to.

What is the AVERAGE shifting time for a latch such as the 595, assuming that you have to load all 8 bits before latching the device?

If it is only a second or two on average, that is no problem.
 

moxhamj

New Member
Picaxe is about 1000 instructions per second, so with one 595 chip and code overheads etc, well under 1/10th of a second.
 

westaust55

Moderator
using 74HC595

From some past checks I did with a 40X1 using the SHIFTOUT commands
Post 14 here: http://www.picaxeforum.co.uk/showthread.php?&p=81360

Sending 4 bytes out to a chain of 74HC595’s, the time was 7.45ms at 4MHz clock speed.
So, in round figures 2 ms per byte.
Allowing for the need to bit-bash the data out on no X1/X2 parts, maybe 3 or 4 ms

So well inside your 1 second timer period.
 

stocky6409

Senior Member
What voice ship you using Grogster?
I'm working with the HK828 at the moment with a picaxe 28x1 - i ended up dedicating the portb outputs to drive it and used a 74HC540 octal inverter so that i could just use simple "pulsout" code to drive the chip inputs.

My circuit monitors a number of inputs (used porta as cheats digital inputs) plus combined inputs and outputs on portc plus serial comms via the programming pins.

I toyed with latches and port expanders before settling on the 74HC540 - you could use a 74HC240 as well - the 540 was more suited to the compact PCB layout

Stocky
 

Grogster

Senior Member
What voice ship you using Grogster?
I'm working with the HK828 at the moment with a picaxe 28x1 - i ended up dedicating the portb outputs to drive it and used a 74HC540 octal inverter so that i could just use simple "pulsout" code to drive the chip inputs.

My circuit monitors a number of inputs (used porta as cheats digital inputs) plus combined inputs and outputs on portc plus serial comms via the programming pins.

I toyed with latches and port expanders before settling on the 74HC540 - you could use a 74HC240 as well - the 540 was more suited to the compact PCB layout

Stocky
Not using a voice ship - never heard of that kind of vessel... ;)

Yes, using either the Holtek HK828 or Aplus APR9600 - both appear to be exactly the same die, as both datasheets technical data is too similar in too many areas of the sheet NOT to be... :D (besides the fact they are pin-for-pin compatible)

Looks like we have similar methods.
Currently, I use the voice-recorder chip controlled by portc on a 40X PICAXE for simplicity more then anything else, with the other ports acting as inputs and other control functions. I am looking at using a cheaper method using the latch idea, but this is still in breadboarding stage...

I also use a "Standard" output pin on the 40X, to control the 828/9600's /CE(enable) line, so that you can stop any message - even if it is half-way through playing it, and then reset the chip for a new message.

I use 22k pull-ups on all message control pins, even though the datasheet does not show them or say they are required. I found by experimentation, that you need the pull-ups for reliable operation. Without them, sometimes the 828/9600 refuses to see the change in input state, and subsequently, refuses to play the desired message. Not always - just sometimes, but if the 22k's are there, the messages always play, so I would encourage you to put them on your project...

The little 828/9600 is a versatile little chip, really, for relatively basic and low-fi voice or sound applications. :)
 
Last edited:
Top