In some situations using Arduino and microcontrollers, it is necessary to use a shift register such as the 74HC595 to directly trigger LEDs, LED arrays or displays, but if you check the datasheet, you will see that you need to be careful with the maximum current in each output and also with the total current so as not to damage any device.
This information is important for designing more reliable and robust solutions and this post will help you better apply some components such as the 74HC595, ULN2803, UDN2981 and transistors PNP.
1) 74HC595 - Shift Register (serial-in to parallel-out)
According to the datasheet of 74HC595, this component contain an 8-bit, serial-in, parallel-out that feeds an 8-bit D-type storage register.
This device is very popular for applications on LED arrays, for example, but my intention here is to just discuss your power consumption limit and not all of its functionality.
Its Maximum Ratings are:
- 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 there are 2 outputs consuming 35 mA in use, the device's maximum limit of 70 mA has been reached and no other port can be used at the same time.
- The maximum current allowed per port is 6mA at 5V.
Due to these technical limitations it is necessary to apply other interface components to have a more robust and reliable design, protecting the components.2) ULN2803 - High Current Drain
The ULN2803 is an array of Darlington transistors that can be charged 500 mA in a single output with voltage up to 50V. There are many applications for it, such as solenoids, relays, LED display drivers, and light bulbs, as well as inductive loads such as small motors.
Note that in the pin configuration you only find the GND but no Vs pin. At first glance, it is strange because we hope 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 to an input port, the corresponding output port will be able to drain the current from a positive source.
You can see an example of this in the schematic shown in the attached image. Note that the LEDs are connected in a common anode configuration and the ULN2803 is used to drain the current at its output ports according to the input signals driven by the 74HC595.
In this case, you can drain up to 500 mA at each output port and keep the 74HC595 in safe working condition.3) UDN2981 - High Current Source Drivers
The UDN2981 is an 8-channel source drivers.
It is similar to the ULN2803 but with an opposite function and you can use it as an interface between 74HC595 and a device that needs a higher current supply for the job. Typical applications include: relays, solenoids, lamps, step motors, servos and LEDs.
UDN2981 can also work with 500 mA (Output Source Current Capacity) up to 80V. 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 to an input port, the corresponding output port will be able to provide a higher current to the next device.
You can see an example in the schematic shown in the attached image. Note that the LEDs are connected in the common cathode configuration and the UDN2981 is used to supply the current at its output ports according to the input signals driven by the 74HC595. Again, in this case, you can drain a larger current at the output ports and keep the 74HC595 in safe working condition.
In the datasheet, you can also find interesting information about the duty cycle versus the output current.
The attached chart shows the number of outputs simultaneously, and if you consider a 50% duty cycle with 8 outputs, the maximum recommended output current is about 220 mA.
In the same configuration, if the duty cycle is increased to 100%, the recommended output current will be 120 mA and, of course, the current can be higher if you decrease the number of outgoing ports that are being used.
This shows us how important it is to consider the number of outputs you run simultaneously; the duty cycle you are using in your application (e.g., the LED refresh rate) and the maximum current supported by the devices.4) PNP transistor used as a switch for higher currents
As example, 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, e.g., LED actuation, in place of UDN2981.
Note: BC327 is shown here as an example, but of course there are many other equivalent transistors for this type of application.
- Low cost
- Availability (very easy to be found anywhere)
- It requires more space to be mounted and uses additional components (resistors).
To work properly as a switch, the PNP transistor must be in the saturation region and you can calculate the resistor of its base as follows:
- hFE = Ic / Ib = 100 (minimum gain value according to datasheet of BC327)
- Vbe = 1.2 Volts
- Rb = (Vin - Vbe) / Ib = (Vin - Vbe) / (Ic / 100)
For example, if you need to direct a current of 160 mA to the collector and the gain of the transistor is 100, this means that the current required at the base is only 1.6 mA.
Rb = (5 - 1.2) / 0.0016 = 2.4 K (Ohms)
Note: The hFE gain of the transistors produced can vary within a specified range according to the datasheet and due this you should test some resistors with values close to the calculated one.5) Conclusion
This presentation shows some ways to improve the robustness and reliability of some devices by preventing them from working beyond design limits.
In the next photos you can see a project of mine where I applied all these concepts.