Intro: Using Shift Register 74HC595 With ULN2803, UDN2981 and BC327
Hello, all !!
In many situations in your projects with microcontrollers you can use a shift register like 74HC595 directly with LEDs and displays, but if you check the datasheet you will see that need to take care with the maximum current on each output and also with the total current to not damage the device.
These are important information that we normally do not care in our home projects (including me in many times) and I would like to explain you this issue in order you go further with more reliable and robust solutions !
This overview will help you to understand the differences and the design alternatives using as examples the devices 74HC595, ULN2803, UDN2981 and also the BC327 transistor, but you can extrapolate all information to another devices configurations.
I hope you enjoy it and that be useful.
Step 1: 74HC595 - Shift Register
This is a formal description of 74HC595 you can find on datasheet:
"The 74HC595 devices contain an 8-bit, serial-in, parallel-out that feeds an 8-bit D-type storage register."
It is very popular for applications on LED displays but my intention here is only discuss its limit of current consumption and not all its funcionality.
Let's see the specifications shown at datasheet related to Maximum Ratings:
- Io (Continuous Output Current) = 35 mA
- Io (Continuous Current through Vcc or GND) = 70 mA
- Output Drive at 5V = 6 mA
What this means:
- If you have 2 output with 35 mA of charge, forget to use the remaining 6 outputs because you are already using the limit of 70 mA of device.
- The maximum for each port is 8.75 mA and the recomendation at 5V is 6 mA.
Within these conditions if you apply one LED for each output port, probably you will go beyond these limits.
In this case, a standard red LED has a consumption of 10 mA what means 80 mA at total when 8 of them are used simultaneouslly in your project.
Sure you can put a resistor to limit in 6 mA but certaily you will not like the result of brightness of each LED.
Ok, now you are thinking already had seen dozen of projects (including books) that just use the shift register to drive directely some component.
I confess I did this too in another situations just to keep a more compact design, with less components and with lower costs. Maybe they survive due low duty cicle.
But with an equipment you must keep working during all day long for a long time, I am not sure whether it will be robust and reliable enough in terms of its time life.
For these conditions you need to use some interface device that can work with larger currents as we will see in next steps.
Step 2: ULN2803 - High Current Drain
The ULN2803 is a Darlington transistor arrays that can be charge 500 mA on a single outputwith voltage up to 50 V.
There are many applications for it such as solenoids, relays, LED display drivers, lamps, inductive load like small motors.
Note that in the images of simplified schematic and in pin configuration you only find the GND but none Vs pin.
In first view it is strange because we expect to see both pins !
In fact you do not need any specific Vs pin because the ULN2803 is used as a drain for the current.
When you apply a signal on a input port, the corresponding output port will be able to drain the current from a positive source.
You can see an example of that in the schematic shown in attached image.
Look that LEDs are connected in common anode configuration and the ULN2803 is used to drain the current in its output ports according with the input signals driven by 74HC595.
In this case you can drain up to 500 mA in each output port and keeping the 74HC595 in safe working conditions.
Step 3: UDN2981 - High Current Source Drivers
The UDN2981 is a 8-channel source drivers.
It is similar to ULN2803 but with an opposite functionand you can use it as a interface between 74HC595 and a device that needs a supply of a higher current to work.
Typical loads include relays, solenoids, lamps, stepper motors, servo motors, LEDs.
UDN2981 can also work with 500 mA (Output Source Current Capabilty) ut to 80 V.
Note that in this case you have the Vs and GND pins because you must be connected to the power supply.
Now when you apply a signal on a input port, the corresponding output port will be able to supply a higher current to next device.
You can see an example in the schematic shown in attached image.
Look that LEDs are connected in common cathode configuration and the UDN2981 is used to supply the current in its output ports according with the input signals driven by 74HC595.
Again in this case you can drain a higher current in output ports and keeping the 74HC595 in safe working conditions.
In the datasheet you can also find an interesting information about the duty cicle versus the output current.
The attached graphic shows the number of outputs conducting simultaneoulsy and if you consider a duty cycle of 50% with 8 outputs, the recommended maximum output current is around 220 mA. In same configuration if you increase the duty cycle to 100% the recomended output current will be 120 mA.
And of course, the current can be higher if you decrease the number of output ports that are being used.
This show us how important is to consider the number of outputs conducting simultaneouly, the duty cycle you are using in your application (p.e., frequency of refreshment of LEDs) and the maximum current supported by the devices.
Step 4: BC327 - PNP Transistor Applied As Switch for Higher Currents
The amplifier PNP silicon bipolar transistor BC327 can work with collector currents up to 800 mA (Maximum Ratings) and up to 45V.
In some applications this transistor can be used as switch for higher currents, p.e., sourcing LEDs, in place of UDN2981.
But there are Pros and Cons:
- Low cost
- Availability (very easy to find anywhere)
- Need more space to be assembled on the board.
- More additional components (resistors must be connected to Base of transistor)
To work properly as a switch, the transistor BC327 must be on saturation and you can calculate the resistor in the base as following:
- hFE = Ic / Ib = 100 (minimum value according with datasheet of BC327)
- Vbe = 1.2 Volts
- Rb = (Vin - Vbe) / Ib
For example, if you need to drive a current of 160 mA in collector and the gain of transistor is 100, it means the necessary current in the base is only 1.6 mA.
Rb = (5 - 1.2) / 0.0016 = 2.4 K (Ohms)
Step 5: Conclusion
This presentation show you some ways to improve the robustness and reliability of some devices avoiding they work beyond their limits of design.
Personally, my preferred design is with common anode using ULN2803 because is very simple, easy to find it in different markets and also have a lower cost comparison with UDN2981.
Feb. 8th, 2016.