12
\$\begingroup\$

I have 60 leds that came in a led strip. One meter length of the led strip requires the following:

  • 400 milliamps
  • 12 volts

I want to control these LEDs with micro controller. I'm thinking of using a TIP120 and a raspberryPi.

A raspberryPi GPIO pin can output 50 milliamps continuously. (Update: This is not true, see below)


I am a beginner, and I'm not sure I'm doing this correctly. All my calculations are based off of things I read on this blog.


Math

Base current:

The TIP120 has a collector current of lc = 250 * lb so I'll need a base current of 1.6 mA.

( 1.6mA * 250 = 400 )

The raspberryPi should have no problems with the Base current

Base resistor:

I'll need a resistor low enough to ensure that the TIP120 base remains saturated but stays less than 50 mA as to not overload the raspberryPi.

According to the blog I mentioned, I find the base resistance by looking up the Vbe(sat). See figure 2.

where Vbe(sat) is 400 on the x axis, the collector current is about 1.3 on the y axis.

enter image description here

If the raspberryPi outputs 3.3 volts, then there is a voltage drop of 2 volts
(3.3 - 1.3)

So according to my calculation, I need a resistor between 4 and 40 Ohms R = V/I
2 / (0.05 A) = 40 Ohms
2 / (0.50 A) = 4 Ohms
(Update: Incorrect, see bottom of question)

I still consider myself an amateur and I am in a bit over my head.

  • Do these calculations look correct?
  • Will TIP120 work? (any other suggestions welcome)
  • Are there any other considerations I should take into account for my schematic?

enter image description here

Update

As pointed out in the answers, I typoed the milliamp ratings by a factor of 10. I should have said:
2 / (0.005 A) = 400 Ohms
2 / (0.050 A) = 40 Ohms

Update 2

It appears that there is some fogginess about the maximum current a pin on a Raspberry Pi can provide. To be safe, I'm going to assume it is 8 mA.

https://raspberrypi.stackexchange.com/questions/9298/what-is-the-maximum-current-the-gpio-pins-can-output

https://raspberrypi.stackexchange.com/questions/1130/what-is-the-nominal-gpio-pin-output-current

Update 3

Ada fruit wrote a great blog article on how to control an LED strip with a micro controller. She recommends a STP16NF06 or a TIP120

https://learn.adafruit.com/rgb-led-strips/usage

\$\endgroup\$
6
  • 2
    \$\begingroup\$ I don't think the GPIO pins can source 50 mA. I think the +3.3V power rail pin can source 50 mA. I think each GPIO can source just a few milli-amps. I would use a logic-level MOSFET instead of a BJT. No need worrying about continuous current then. IRLB8721 is a fine choice for many uses; I think this use would qualify. \$\endgroup\$
    – Jon Watte
    Aug 28, 2013 at 4:21
  • \$\begingroup\$ @JonWatte Thanks for pointing that out, I'm going to double check the maximum current before I go any further. \$\endgroup\$
    – spuder
    Aug 28, 2013 at 4:38
  • \$\begingroup\$ @JonWatte Power calculations in design of the RPi figured all GPIO on at the same time, 3mA each, 50mA total. You can have less on at any given time and increase the current. On top of that, they figured an extra 50mA directly from the 3.3v rail, when all peripherals are in use (like hdmi, ethernet, and sd card, all which draw from 3.3v rail). So the 3.3v PINS, directly connected to the 3.3v rail, and the 3.3v GPIO from the BCM SOC are different. \$\endgroup\$
    – Passerby
    Aug 28, 2013 at 5:47
  • \$\begingroup\$ +1 for beginner doing their own research and getting almost all the way there before asking a question. \$\endgroup\$
    – pjc50
    Aug 28, 2013 at 14:04
  • \$\begingroup\$ @Passerby I think you will burn the driver stage of the GPIO pin if you try to source 50 mA from one of them and keep the rest idle. \$\endgroup\$
    – Jon Watte
    Aug 28, 2013 at 16:25

2 Answers 2

6
\$\begingroup\$

You're nearly there, a couple of things though:

The base resistor calculation ins't correct - remember you only need 1.6mA according to your calculations (the collector current is separate).
Looking at the datasheet, the minimum gain is 1000, and maximum base-emitter voltage is 2.5V, which means we need to adjust the calculations, 1.6mA will do for the base current (always good to have extra for a switch as the gain drops at saturation) but we need to use 2.5V rather than 1.3V for worst case (it's better to use worst case/maximum values to design with, though looking at the graph it seems the extra Vbe is unlikely at this current, so somewhere between the two figures below should be okay):

So:

(3.3V - 2.5V) / 1.4mA = 570Ω

or

(3.3V - 1.5V) / 1.4mA = ~1.2kΩ

This should work okay, but is not the most efficient way to do things - the transistor dissipation will be at least 0.4A * Vce(sat) which is about 0.4A * 0.75V = 0.3W, plus your R-pi needs at least a couple of mA or so to drive it.
A modern logic level MOSFET can be much smaller, be driven with (almost) no current) and have almost no dissipation. Here is an example part, the FDC637BNZ , chosen at random from thousands at Farnell:

enter image description here

\$\endgroup\$
3
\$\begingroup\$

0.5A is 500 Milliamps... You will blow your Pi. 0.05 is 50 Milliamps. That's the high limit. No need to go for that. You only need 1.6mA as you said. So buff it up a bit, say a nice even 5mA. 3.3 - 1.3 = 2v the resistor needs to drop. 2v / 0.005A (5mA) = 400Ω. Round up to next biggest size 470Ω, you get ~ 4mA at the base.

That math error aside, the TIP120 works fine for this, even though its really overkill for the 400mA that the led strip will take. It is a darlington pair, for high current multiplication. A common single BJT transistor like the PN2222 (1 Amp in a standard To-92 package) would be more than enough. Or you could split the strip in two or three and use a few 2n3904 (100~200mA) and flash the different sections differently (Of course you will need an equal number gpio, unless you want to drive them all from a single GPIO which would work too. Parallel Transistors each with their own base resistors driving smaller sections of the LED strip would be a good way of dealing with smaller transistors if you cant get bigger ones.)

And your schematic is good enough for a mockup. A single color led strip is not a very complex circuit to work with, so there is no way to improve it aside from using the right parts instead of generic placeholders.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for catching that. I typoed the calculations. I've updated the question with the correct information. \$\endgroup\$
    – spuder
    Aug 28, 2013 at 3:56
  • 1
    \$\begingroup\$ Disadvantage of a Darlington pair is the relatively high V(CE,sat), which just dissipates power in the transistor. A regular BJT will perform much better with that aspect. As @Passerby states, you don't need a beast like TIP120 that is rated for almost 20x what you need. \$\endgroup\$
    – jippie
    Aug 28, 2013 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.