Shift registers - only good for LEDs?

Newbie here!
I have read many, many, many articles and watched tons of youtube tutorials on shift registers, but almost every single one only mentions driving LEDs with them. By my understanding, if you can generate PWM outputs to drive RGB LEDs, you should be able to do the same for motors or servos with, say a ULN2003, to provide the uumph!

What I can't understand is why just absolutely no-one ever takes the project further than LEDs, which leaves me with a nagging doubt that I am missing something!

Any suggestions on sources for research welcome and Thanks!

So use a unl2003 to ramp up the current then?....

For motors, you typically need a lot more than 100-150mA of current, so discrete transistors are used.

You only describe shift-out registers. Shift-in registers are also used, for reading in banks of switches for example.

There are other cases where shift-out registers are used to set up other logic functions.

Useless for motors.

AND almost useless for LEDs. Most of those "youtube tutorials" are severely stressing the chip.

Serial-to-parallel shift registers like the 74HC164 or 74HC595 are good for driving a lot of outputs with a few microcontroller pins. Any time you have that situation, consider a 74HC164 or 74HC595 shift register. LEDs are obvious, but if you really wanted to write, for example, a parallel memory's address pins or the digital input of a parallel DAC, you could use a 74HC164 or 74HC595 shift register to be able to send signals to them without eating all your pins.

Parallel-to-serial shift registers like the 74HC165 are good for reading a lot of inputs with a few microcontroller pins. Any time you have that situation, consider a 74HC165 shift register. A large set of switches are obvious, but if you really wanted to read, for example, a parallel memory's data pins or the output of a parallel ADC, you could use a 74HC165 shift register to be able to retrieve signals from them without eating all your pins.

In both cases, you trade pins for speed. With the Arduino and its very slow default port access speeds, you might lower the number of times you can touch an external device to a few thousands of times per second if you are using a shift register to control a large number of inputs or outputs. Still, this is usually fast enough for most applications.

This document says the 74HC164 can source 25mA per pin or sink 20mA per pin and dissipate 750mW per package. I would say it is perfectly fine to drive normal LEDs on such an IC. Limit current to 20mA with resistors.

http://easyelectronics.ru/datasheet/74HC164.pdf

JoeN:
This document says the 74HC164 can source 25mA per pin or sink 20mA per pin and dissipate 750mW per package. I would say it is perfectly fine to drive normal LEDs on such an IC. Limit current to 20mA with resistors.

http://easyelectronics.ru/datasheet/74HC164.pdf

That datasheet also says: Icc - DC Supply Current, VCC and GND Pins - 50mA

ie. You can't source 20mA on more than 2 pins at the same time.

cd74ac164 - better current drive than HC.
TPIC6B595 better still, sink current from cathodes.

fungus:
That datasheet also says: ICC - DC Supply Current, VCC and GND Pins - 50mA

Which clearly makes no sense at all against the 750 mW dissipation rating! :astonished:

Thanks everyone for your replies. Unfortunately, it still doesn't answer my question !
I understand the limited current capacity on the outputs of the shift register, which is why I asked whether a transistor, or Darlington pair, could be used to pump up the current.
It seems to be perfectly capable of passing on PWM to RGB LEDs, and I have seen projects driving high powered LEDs through 595s.
I guess maybe therein lies the answer.

PWM through a shift reg is possible, pretty inefficient but if you are really short of pins ok.

I have seen projects driving high powered LEDs through 595s.

Not without further amplification, or not for very long.

Unfortunately, it still doesn't answer my question !

I thought everyone had, what was the question again then?


Rob

xmasdreams:
Thanks everyone for your replies. Unfortunately, it still doesn’t answer my question !
I understand the limited current capacity on the outputs of the shift register, which is why I asked whether a transistor, or Darlington pair, could be used to pump up the current.

Yes, of course. A BJT transistor only needs a few milliamps to saturate.

Darlingtons are pretty obsolete these days. Normal transistors have high enough gains.

Paul__B:

fungus:
That datasheet also says: ICC - DC Supply Current, VCC and GND Pins - 50mA

Which clearly makes no sense at all against the 750 mW dissipation rating! :astonished:

7.0V supply with 50mA going through Vcc and 50mA going through GND is 700mW.

An arduino output PIN can supply only a few mA but with right interfac it could control hundreds of kW.
The same with the shiftregister 74HC595, output are only a few mA but with right interface i could control hundreds of kW.

I’m using lots of 74HC595 and interfacing with an MOSFET I can control 25 Amps

Pelle

I've built a small robotic vehicle that uses 4 small stepper motors. To control the 4 stepper drivers (ULN2003) I used 2 74HC595 shift registers. http://www.bajdi.com/arduino-28byj-48-stepperbot/
So yes you can use shift registers to do other things then blinking leds :slight_smile:

Thanks all for your replies. I will proceed to experiment - Badji, I am a great fan of those cheap steppers because my applications don’t need much speed or power - I have followed your work on youtube and love your work. I have also used some of your codes before, so it is most appreciated! Cheers,

xmasdreams:
I have read many, many, many articles and watched tons of youtube tutorials on shift registers, but almost every single one only mentions driving LEDs with them.

Same as all the basic/beginner tutorials at arduino.cc. For example, when you learn a new programming language, after it's installed the first thing you do is write a tiny test program that prints 'Hello World' on the screen. Or creates some other easily detectable output. A resistor and an LED is the easiest to construct, cheapest, and fastest way to detect output on an IC pin.

With that you know your basic install of the programming language (and in this case the Arduino GUI) works, and the USB cable and such and you move on from there. In the shift register case the LEDs tells you that everything in the software-hardware chain works.

I have an Arduino motor shield, and other manufacturer motor boards. For test and troubleshooting purposes each output pin has an LED that tells me what that output pin is doing. I operate the board first with no motor attached, and watch the LEDs to give me a better confidence that the motor will work when attached. If the motor doesn't work, but the LEDs 'imply' that it should, then that's a clue.

By my understanding, if you can generate PWM outputs to drive RGB LEDs, you should be able to do the same for motors or servos with, say a ULN2003, to provide the uumph!

2003 has 7 inputs and 7 outputs. That fills up a Uno pretty quickly. One of the easiest ways to create a vast amount of outputs is through only a few pins and a shift register. Cascade them and make more-more outputs.

What I can't understand is why just absolutely no-one ever takes the project further than LEDs, which leaves me with a nagging doubt that I am missing something!

Because that exercise is left to the student. Whatever reason you -need- a mux, these tutorials demonstrate the basic Hello World, and you may proceed from there at will. PWM/stepper/multicolorLED/whatever, whether the data can be processed inside the Arduino bits shifted out fast enough to control 'x' number of motors is a different topic and beyond the scope of any typical Hello World tutorial. All the tutorial does is get you off the ground - you need to decide how hard you need to flap your wings to fly as high as you need/prefer. :slight_smile:

xmasdreams:
Thanks everyone for your replies. Unfortunately, it still doesn't answer my question !
I understand the limited current capacity on the outputs of the shift register, which is why I asked whether a transistor, or Darlington pair, could be used to pump up the current.
It seems to be perfectly capable of passing on PWM to RGB LEDs, and I have seen projects driving high powered LEDs through 595s.
I guess maybe therein lies the answer.

I'm reading your posts, are you are asking about using PWM through a '595 or similar? My first inclination is that the amount of shifting required to have a reasonable base frequency wouldn't leave much else for the Arduino to do. Then I found this thread suggesting using a TLC5940 instead of software, [this thread](http://this thread) discussing driving PWM through a normal s2p (serial to parallel) shift register with software, and finally [this library](http://this library) for software PWM using interrupts through a normal s2p shift register for up to a 75Hz PWM on each shift register output.

LEDs are just used as examples. Lets say you have a large, complex pluming project for a fountain display. In your fountain display you have 30 valves that you need to control and want to use an Arduino UNO to run your show program. Daisy-chain four s2p shift registers and only use 3 pins on the Arduino to control up to 32 divices (valves, lights, curtains, audience zappers, etc.). You will need to have driver circuitry for each of the devices to provide the voltages and currents required to actuate them, but the actual control signal comes from the s2p shift registers. Just the first example that came to mind.

Drat... Now I have a desktop fountain display VU meter concept trying to take root in my mind. Control the height of each fountain jet based on amplitude of a frequency range. Water is (and mechanical valves are) fairly slow to respond so PWM may not be needed, just fast switching. Each fountain jet is normally illuminated with a green LED except at peak when it gets illuminated with red... Anyone else is welcome to take this idea and make an instructable out of it... :wink:

While do-able, I think a lot of why people don't is due to complexity, especially at a real-time level. LEDs don't need real time, since people can't observe certain speeds. However, for a stepper-motor, you need to worry about real-time signals, especially when controlling multiple. You really need to be sure that both motors are doing exactly what they are supposed to so your movement is correct and won't damage something. Adding a shift register adds in latency, so the timing becomes more critical.

I have used a shift register to control a character LCD with only three Arduino pins:

So, definitely good for more than LEDs...

StanD:
I have used a shift register to control a character LCD with only three Arduino pins:
Arduino controlled LCD using a shift register and the SPI library – 42 Bots

So, definitely good for more than LEDs...

Specialized ones have additional applications, though I think the thread is mostly talking about the general purpose and cheapo shift registers. For example, most VFD drivers are simply high voltage shift registers. Here are two I have used with no problems:

MAX6921 (20 output, 76 volts)
PT6306 (64 outputs, 70 volts)

The second one is both a lot cheaper than the Maxim part and also has three times the outputs. It works great for displays with a large number of grids and segments.

Don't lick the project board when running it at 70 volts. :grin: