Author Topic: Driving LEDs - Do I need a resistor?  (Read 4579 times)

0 Members and 1 Guest are viewing this topic.

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Driving LEDs - Do I need a resistor?
« on: July 30, 2014, 05:03:19 pm »
OK,

Let's look at the following examples:


In Example A, we can drive a led (albeit a cheap, low power) by simply attaching a resistor to it and getting a constant current.

Moving up, to more powerful LEDs, we drive them via Constant Current using a transistor, same idea, but we use the Transistor to set the current with the resistor R2. Example B is the one that I want to use.

However, I've seen some schematics where people are adding a second resistor (in this case R4) to the LED even though there is a Transistor that runs the Constant Current. Why? Is it necessary to have another resistor at the cathode? Even though I am already creating a Constant Current via the Transistor? Isn't R4 redundant?

Thanks,

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6193
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #1 on: July 30, 2014, 05:11:49 pm »
The middle one is not good. To control the LED current you need to be predictable and stable transistor gain which is impractical.
 

Offline jlmoon

  • Supporter
  • ****
  • Posts: 609
  • Country: us
  • If you fail the first time, keep trying!
Re: Driving LEDs - Do I need a resistor?
« Reply #2 on: July 30, 2014, 05:17:48 pm »
Pick C..  :-DD
Recharged Volt-Nut
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: Driving LEDs - Do I need a resistor?
« Reply #3 on: July 30, 2014, 05:24:11 pm »
Care to elaborate?

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Driving LEDs - Do I need a resistor?
« Reply #4 on: July 30, 2014, 05:31:12 pm »
Care to elaborate?

In C the transistor is biased as to be completely turned off or turned on to full saturation, so the transistor doesn't set the maximum led current the series resistor in the collector lead is calculated to limit the current flow to the desired amount.

 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3733
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #5 on: July 30, 2014, 05:36:48 pm »
In 'B' you are dependent on the transistor beta, which varies quite a bit with temperature, collector voltage, and from device to device.  You can probably make it work: if the supply and base voltages are fixed, and the temperature doesn't vary too much, the transistor will be a nice high impedance current sink, but without additional compensation circuitry it won't be reproducible or stable.  You would have to re-trim it for every transistor, and more than a few degrees temperature shift will probably change the LED current too much.
 

Offline Phaedrus

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #6 on: July 30, 2014, 05:38:44 pm »
Your constant current in B is determined by the resistor hFE and VBE. Unfortunately, these values are not well controlled in production. While a datasheet might list an hFE of 100 are "typical" it may vary from 50 to 250. Additionally, it varies significantly with temperature. You should never base any circuit parameter on hFE if you have an alternative.

Instead you drive the transistor to saturation, and set your current with a ballast resistor. If you need a higher power/current than is practical with a resistor, you can use a transistor current source like ones below, or if it's *really* beefy you can use a buck regulator.

"More quotes have been misattributed to Albert Einstein than to any other famous person."
- Albert Einstein
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: Driving LEDs - Do I need a resistor?
« Reply #7 on: July 30, 2014, 05:38:48 pm »
In C the transistor is biased as to be completely turned off or turned on to full saturation, so the transistor doesn't set the maximum led current the series resistor in the collector lead is calculated to limit the current flow to the desired amount.

Ok, so if I understand correctly, I first choose the R3 resistor to get my forward gain. I then select the R4 resistor based on the Vf of the LED(s)? Irrespective of the collector?

But then what have I achieved? If the resistor R4 is still the one limiting the current, why the transistor?

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3733
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #8 on: July 30, 2014, 05:52:41 pm »
The transistor is only needed if you want to switch the LED...  If you just want it lit you only need a resistor (circuit A).
 

Offline Phaedrus

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #9 on: July 30, 2014, 05:53:00 pm »
In C the transistor is biased as to be completely turned off or turned on to full saturation, so the transistor doesn't set the maximum led current the series resistor in the collector lead is calculated to limit the current flow to the desired amount.

Ok, so if I understand correctly, I first choose the R3 resistor to get my forward gain. I then select the R4 resistor based on the Vf of the LED(s)? Irrespective of the collector?

But then what have I achieved? If the resistor R4 is still the one limiting the current, why the transistor?

Well you can now turn the LED on and off from a micro or other digital signal source. If I just need a constant-on LED like a power indicator I just use diagram A.
"More quotes have been misattributed to Albert Einstein than to any other famous person."
- Albert Einstein
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5044
  • Country: ro
  • .
Re: Driving LEDs - Do I need a resistor?
« Reply #10 on: July 30, 2014, 06:12:22 pm »
A : when you want to power a small LED without ability of controlling it (for example power on led).  The current going through the LED will be  (Vpsu - Vled)/R

B : you're relying on the transistor to limit the current. You can use the hFe of the transistor and pick a resistor to "open up" the transistor just enough current flow through, therefore limiting the led as well. 
hFe varies with transistor, it's usually within a wide range, and it also varies with temperature, so it's hard to pick one resistor that will work with any transistor out of - let's say - a batch of 100 transistors. You also have to be careful about how much power is wasted inside the transistor, and keep in mind that as the transistor heats up, the hFe will also change, so the current limit as a consequence will change.
It's worse than A because you're also wasting power in the resistor connected to the base (well, base-emitter), but it's a cheap solution and useful to turn on and off stuff for short periods of time.
For example, a microcontroller can output in general 20-25 mA though any pin, so if you have a LCD backlight (without its own current limiting system) that's supposed to use 50mA, you can use this method to power the LCD backlight from power supply, and the mcu pin will only use 0.1-0.5mA, enough to partially open up the transistor. 

C: the transistor is opened fully, it's not limiting the current. The resistor is there to just set a high limit for the current going through transistor from base to emitter (without resistor on base, you kill the transistor).  There is some voltage drop on the transistor from Collector to Emitter but it's generally small (0.2-0.7v)  so your new led current limit is (Vpsu - Vled - Vnpn)/R

An alternative to this C method would be to use a mosfet, which will waste less energy as there's no current from base to emitter as is the case with transistors. You would still need a resistor from gate to ground to turn off the mosfet when you want to kill the connection but it can be a large resistor (10 kohm or more). There's some capacitance otherwise which will keep the mosfet working even when your microcontroller stops sending voltage to gate.

There's also some resistance between Drain and Source, but it's usually small enough to not matter in formulas (a cheap BS270 for example has 1.5-2 ohm resistance) so you still have to use a current limit resistor with the led, and keep in mind the mosfets power dissipation.
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: Driving LEDs - Do I need a resistor?
« Reply #11 on: July 30, 2014, 06:32:50 pm »
@mariush - Yeah, i've used the Mosfet / BJT combination before, I was just looking to simplify and use less parts.

Offline Phaedrus

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #12 on: July 30, 2014, 06:41:58 pm »
The mosfet solution is the best overall, I feel. That's what I used in my recent project. In my case I left out the pull-down resistor, as it effectively gives the LEDs a smidgen of hysteresis, so I don't have to worry about flicker if the logic is at a boundary condition.
"More quotes have been misattributed to Albert Einstein than to any other famous person."
- Albert Einstein
 

Offline Electronics-Repairman

  • Contributor
  • Posts: 42
  • Country: 00
  • More people talk about Electronics than do it
Re: Driving LEDs - Do I need a resistor?
« Reply #13 on: July 30, 2014, 07:14:27 pm »
Best idea,  go down to the pub , and think about it tomorrow :-+
If it's highly recommended, then  I'm not interested.
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: Driving LEDs - Do I need a resistor?
« Reply #14 on: July 30, 2014, 07:18:52 pm »
Best idea,  go down to the pub , and think about it tomorrow :-+

 ;) Did that once, never left!!!

Offline jlmoon

  • Supporter
  • ****
  • Posts: 609
  • Country: us
  • If you fail the first time, keep trying!
Re: Driving LEDs - Do I need a resistor?
« Reply #15 on: July 30, 2014, 07:43:42 pm »
The mosfet solution is the best overall, I feel. That's what I used in my recent project. In my case I left out the pull-down resistor, as it effectively gives the LEDs a smidgen of hysteresis, so I don't have to worry about flicker if the logic is at a boundary condition.

I have not looked up the data on that particular part, what is the Vgs voltage for that MosFet?  Is this one of those digital gate style fets?
just curious
Recharged Volt-Nut
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Driving LEDs - Do I need a resistor?
« Reply #16 on: July 30, 2014, 07:50:38 pm »
In C the transistor is biased as to be completely turned off or turned on to full saturation, so the transistor doesn't set the maximum led current the series resistor in the collector lead is calculated to limit the current flow to the desired amount.

Ok, so if I understand correctly, I first choose the R3 resistor to get my forward gain. I then select the R4 resistor based on the Vf of the LED(s)? Irrespective of the collector?

But then what have I achieved? If the resistor R4 is still the one limiting the current, why the transistor?

It depends on the led pin current desired. If for a standard 20 mA led, then your case "A" is the best as it uses the fewest components and works within the arduino output pin current capacity. If however you wanted to drive a led at higher current limits then the transistor switch acts as a simple current amplifier switch.

 

Offline Phaedrus

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: us
Re: Driving LEDs - Do I need a resistor?
« Reply #17 on: July 30, 2014, 08:28:09 pm »
The mosfet solution is the best overall, I feel. That's what I used in my recent project. In my case I left out the pull-down resistor, as it effectively gives the LEDs a smidgen of hysteresis, so I don't have to worry about flicker if the logic is at a boundary condition.

I have not looked up the data on that particular part, what is the Vgs voltage for that MosFet?  Is this one of those digital gate style fets?
just curious

Vdss = 50V
Id = 220mA
Vgs = 0.8 - 1.5V

With 5V gate voltage you'll get about 5ohms RDSon

In my situation that's perfect for driving about 10mA through an LED
« Last Edit: July 30, 2014, 08:43:11 pm by Phaedrus »
"More quotes have been misattributed to Albert Einstein than to any other famous person."
- Albert Einstein
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16641
  • Country: us
  • DavidH
Re: Driving LEDs - Do I need a resistor?
« Reply #18 on: July 31, 2014, 02:38:53 pm »
Adding emitter degeneration to circuit B which only requires a resistor will allow the output current to be controlled despite variations in the transistor.  Then the output current depends on the voltage at the base.  Emitter degeneration may also be used to make a reasonable current mirror with unmatched discrete transistors.

The other variation that I like is to drive the transistor through an emitter resistor in common base mode with the base tied to the positive logic supply but that is more appropriate for high voltage indicators like vacuum fluorescent displays and neon lamps.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf