User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Shift register help!

Tue Aug 06, 2013 9:29 am

Hello all,

I am trying to get my Pi working with a shift register, and after that several shift registers. I understand the concept of shift registers but I am having a little trouble with the naming of the Pins and how to get the thing up and going. My shift register is a SN74HC595 which appears to be different from everyone elses and thus I am struggling to find a good tutorial! Attached is a pinout...

Could someone please help me?! With Python code as well? Or is that easy? The only thing I have connected is +5v and GND!

Thanks

- Bigcat123
Attachments
PIC.jpg
PIC.jpg (10.81 KiB) Viewed 6671 times
Just a beginner sharing his experiences on his way to geek nirvana...

User avatar
Burngate
Posts: 6227
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Shift register help!

Tue Aug 06, 2013 11:26 am

Can't help with the Python, but maybe some help with pin names.

Pin 14 - SER is the serial input.
Pin 9 - QH' is the serial out for daisy-chaining

Pin 11 - SRCLK is the shift-clock, clocking the data through on its rising edge
Pin 12 - RCLK is the storage register clock. On its rising edge, whatever is in the shift register is transfered to the parallel outputs
Pin 13 - OE when low, enables the parallel outputs. When high, the parallel outputs are tri-state - high impedance

Pin 10 - SRCLR when low clears the shift register to all zeros - but not the storage register

Pins 15 & 1-7 are the parallel outputs

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Shift register help!

Tue Aug 06, 2013 12:20 pm

So which one is data, latch etc?

Thanks

-Bigcat123
Just a beginner sharing his experiences on his way to geek nirvana...

MrEngman
Posts: 3961
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Shift register help!

Tue Aug 06, 2013 12:53 pm

Doesn't sound like you've looked at the data sheet. It might help. Try this http://www.ti.com/lit/ds/symlink/sn74hc595.pdf


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Shift register help!

Tue Aug 06, 2013 1:09 pm

I'm sorry but I don't really understand that data sheet... I thought that shift registers were easy? I have never used them before and all of that stuff about there being 2 clock lines only confuses me! Can someone please help?

- Bigcat123
Just a beginner sharing his experiences on his way to geek nirvana...

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Shift register help!

Tue Aug 06, 2013 1:36 pm

Are there 2 clock lines?

- Bigcat123
Just a beginner sharing his experiences on his way to geek nirvana...

MrEngman
Posts: 3961
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Shift register help!

Tue Aug 06, 2013 1:57 pm

OK. The device you have is a shift register with a seperate latch on the outputs.

There are two clocks, one for the shift register and another for the latch. SRCLK is the shift register clock and RCLK the latch (register) clock. The shift register data is clock in from the shift register data input SER using SRCLK. The data will appear on the output of the shift register latches when SRCLK goes from low to high.

The output latch effectively operates independently and data on the output of the shift register latches will get clocked into the output register latches on the low to high edge of RCLK and can then appear on the output pins Qa-Qh if OE is low. If OE is high the outputs go to a high impedance state (tri-state) and the voltage will be at an unknown level between 0 and Vcc, the supply to the SN74HC595.

So to get data on to the output pins you need to clock it into the shift register with SRCLK and then clock it on to the outputs of the storage register using RCLK.

You may find something like the CD74HC164 may be more what you're looking for. An 8 bit shift register with no extra output latch to get in the way.

Hope this helps a little. Sorry can't help with code.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

PiGraham
Posts: 3785
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Shift register help!

Tue Aug 06, 2013 2:11 pm

What do you want to do with this chip?
It may not work with the 3.3V logic of the Pi if you power it from 5V. VIH min seems to be about 0.7Vcc which would be 3.5V for Vcc = 5V. The Pi will not be able to drive the inputs high.

It should be OK if you power it from 3.3V
You can connect the two clocks together if you don't mind the shifting pattern of data appearing on the outputs. If you were driving LEDs with this you would probably want to shift 8 bits of data in then clock the pattern to the outputs with RCLK so that the pattern changes all at once.

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Shift register help!

Tue Aug 06, 2013 2:25 pm

Ah, so my shift registers are different to the normal ones? Drat...

Basically what I would like is to be able to control around 20 LEDs. I would like separate LED control as well... What do you suggest?

Thanks
Just a beginner sharing his experiences on his way to geek nirvana...

Raspberry wino
Posts: 49
Joined: Mon Mar 05, 2012 11:48 am

Re: Shift register help!

Sat Aug 17, 2013 11:18 am

I'm doing the same, with the same chip. But an HC type chip, if running on 5V is no good as it won't read data input reliably from 3.3V logic such as the Pi. So I used an HCT type (74HCT245) as a crude level shifter. If I'd known I'd have got an 74HCT595 for simplicity but I'd never worked with 3.3V logic before.

It's important to tie the reset line 'high'. Not doing so held me up at first. On my datasheet calls it /MR but it's pin 10. Also tie /OE low to enable the outputs.

Mine worked well sending data in at SER, clocking it through the shift register with pulses on SRCLK. Then to see the register contents on pins 1-7 and 15, I pulse RCLK.

Python? No idea, sorry. I used C.
Last edited by Raspberry wino on Sat Aug 17, 2013 4:48 pm, edited 1 time in total.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12670
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Shift register help!

Sat Aug 17, 2013 12:29 pm

Ah, so my shift registers are different to the normal ones? Drat...
No drat.... needed!
This shift register with output latches is actually better than one without output latches! Without the latches the LED's will display all the random patters that "flow by", while you clock data in.

Its an 8-bit device, so if you need 20 outputs you need 3 of them.

shift and latch clocks can be tied in parallel, and clear input SRCLR can be tied inactive, (high) and output enable OE can be tied permanently low.
QH' outputs from one shift register, should be connected to the SER input of the next shift register to "chain" the three chips together.

First start with setting SET low as well as RCLK.

now you can begin:
Place data on the first chips SET input then clock SRCLK high then low again

Now you have pushed one bit, (for the last LED in the chain) into the shift register.
Do the same for the next 19 bits.
Now drive RCLK high and low again to latch the data in the shift register into the latches. The right bits will appear on the outputs (you can simply ignore the last 4 outputs).

now "rinse and repeat".

If you want to manipulate individual bits, use an array of bits, holding 20 bits. Manipulate the bit(s) you want to change in that array, then write the whole array to the latches.

Don't forget to put resistors in series with each LED, something like 220 Ohm should work.

Dutch_Master
Posts: 362
Joined: Sat Jul 27, 2013 11:36 am

Re: Shift register help!

Tue Aug 20, 2013 11:09 am

There are logic families able to cope with the 3V3 signals from the RPi. Here's one: http://www.nxp.com/products/logic/family/LV/#products The LV595 is pin-compatible with yours.

PiGraham
Posts: 3785
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Shift register help!

Tue Aug 20, 2013 11:28 am

Has anyone used the 74HC595 with Vcc = 3.3V? It looks like that should work OK with Pi GPIO. The problem with threshold levels is at Vcc = 5V.

I don't think you should need level shifters, but you may need a beefier 3.3V supply than the Pi provides (you have to run the LEDs from the same supply or they won't turn off).

mignev
Posts: 20
Joined: Mon Dec 03, 2012 1:24 pm

Re: Shift register help!

Wed Dec 18, 2013 8:32 am

Hi,
see if this library can help you: https://github.com/mignev/shiftpi

I hope I helped :)

Return to “Interfacing (DSI, CSI, I2C, etc.)”