Need help on controlling lots of leds with shift resisters u

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
wakeupwolfgang
 
Posts: 16
Joined: Wed Sep 14, 2011 9:21 pm

Need help on controlling lots of leds with shift resisters u

Post by wakeupwolfgang »

I have always loved making clocks and modifying clocks. But all of my projects so far run direct off of the pins of the microcontroller. I want to save some money so I can an Attiny instead of an Atmega. I have an Attiny12 I want to run this on and three SN54HC595 shift registers. The display is handmade with some leds that I have. There is 3 7 segment displays that are common cathode (see attachment) . I have never designed anything with shift registers and I am at a lost at where to start.
Attachments
902898_10200403576125059_110062558_o.jpg
902898_10200403576125059_110062558_o.jpg (360.45 KiB) Viewed 733 times

waltr
 
Posts: 306
Joined: Wed Jun 12, 2013 5:01 pm

Re: Need help on controlling lots of leds with shift resiste

Post by waltr »

This can be done with SN54HC595s.
To start do some web searches to see how others have used these shift registers with ATmega type processors.
Also, read and study the SN54HC595 data sheet and compare to projects you find on the web to understand how this chip is being used.

If your LEDs can be driven from an Atmega pin the SN54HC595 should also drive the LEDs. However, it is best to compare the data sheet spec for how much current both the Atmega and SN54HC595 can sink or source.

wakeupwolfgang
 
Posts: 16
Joined: Wed Sep 14, 2011 9:21 pm

Re: Need help on controlling lots of leds with shift resiste

Post by wakeupwolfgang »

I don't want to use the Atmega I am trying to save money by using the Attiny.

waltr
 
Posts: 306
Joined: Wed Jun 12, 2013 5:01 pm

Re: Need help on controlling lots of leds with shift resiste

Post by waltr »

Both are Atmel processors and are very closely related (they will have close to the same specs for pin driving). Also much of the code on these two processors will be similar. You will probably need to bit bang the serial data to the SN54HC595s instead of using an SPI hardware module. However, there is info on the web on how to do this.
You stated you were using an Atmega to drive the LEDs and then referenced the Atmega's pin drive current to the SN54HC595.
If these specs are the same then the SN54HC595 will drive the LEDs just like when your Atmega was driving the LEDs. So the only issue is writing Attiny code to interface to the SN54HC595s.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need help on controlling lots of leds with shift resiste

Post by adafruit_support_mike »

The '595 is basically a collection of D-type flip flops, which are digital sample-and-hold circuits. Each one has an input, an output, and a clock, and when the clock goes HIGH, it copies whatever signal is currently at the input to the output. Thing is, the input can change all it wants between clock pulses. Only the signal on the input at the moment the clock goes HIGH gets copied to output.

If you wire up a bunch of D-flops so the output of one is the input of the next, then have them all share the same clock, you get a basic shift register: With every clock pulse, data moves one more flip-flop down the line. If you use a chain of 8 D-flops and connect all the outputs to pins on a chip, you get a 74*168 shift register.

The trouble with a '168 is that you can see the data move along the pins. Each incoming bit moves from out0 to out1, then out2, on down to out7. That can be inconvenient if you have something connected to the pins that should only change when the whole byte is loaded into the register.

The '595 solves that problem by adding another eight D-flops between the shift register and the output pins. Sending the clock for the buffer HIGH copies the current state of the shift register to the pins, and those signals will remain stable while you shift in the next set of bits.

So.. the '595 has three main control signals: the input to the first D-flop of the internal shift register (called DS), the clock for the internal shift register (called SHCP), and the clock for the output buffer or 'storage register' (called STCP).

There are a couple of housekeeping pins: the memory reset pin (MR|) forces a zero into every D-flop of the internal shift register when it's LOW. The output enable pin (OE|) tristates the storage register's outputs when it's HIGH, so it needs to go LOW for data to appear on the output pins.

Finally, there's the serial output pin (called Q7S). That's connected to the output of the last D-flop of the internal shift register. If you connect that to the DS pin of another '595, the connection between the chips is exactly the same as the connections between the D-flops in the internal shift register. That way you can daisy-chain '595s to make as long a shift-buffer as you want. A string of chained '595s use exactly the same signals as the first one.. you just have multiple chips listening to the SHCP, STCP, MR| and OE| signals.

The Arduino makes it easier to control a '595 by wrapping all the 'set DS then strobe SHCP' business into a function called `shiftOut()`.

wakeupwolfgang
 
Posts: 16
Joined: Wed Sep 14, 2011 9:21 pm

Re: Need help on controlling lots of leds with shift resiste

Post by wakeupwolfgang »

I was drawing it up in eagle so I know what I am doing before I start sont don't mess it up. I realised that I forgot about programming the time. Is there a way to use pins as both as an input and output or could I use a shift register to output and input data?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need help on controlling lots of leds with shift resiste

Post by adafruit_support_mike »

You can't use a single pin for input and output at the same instant, but you can swap between them. Just call `pinMode()` to set the behavior you want when you want it.

You need to be a bit careful with your circuits when you have a single pin doing several things. You want to make sure the one producing the input doesn't interfere with the one reading the output and vice versa. The exact techniques depend heavily on the kinds of circuits connected to the pin.

There's also a chip that works like the '595 in reverse: the 74*165. Where the '595 is a serial-in/parallel-out device, the '165 is a parallel-in/serial-out device. It copies the values it sees on its 8 input pins to an internal shift register, then clocks that data out on a serial pin.

joviedos
 
Posts: 1
Joined: Thu Feb 13, 2014 2:21 am

Re: Need help on controlling lots of leds with shift resiste

Post by joviedos »

165 165 etc in RTC 1307 , I solved, Simply solder the pins and use the correct library and appropriate connections .... My arduino joel oviedo

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”