Driving LEDs - Do I need a resistor? - Page 1
Forum section: electronics / beginners

author: made2hack
author_rank: Frequent Contributor
timestamp: July 30, 2014, 05:03:19 pm
content: 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,

author: zapta
author_rank: Super Contributor
timestamp: July 30, 2014, 05:11:49 pm
content: The middle one is not good. To control the LED current you need to be predictable and stable transistor gain which is impractical.

author: jlmoon
author_rank: Unknown
timestamp: July 30, 2014, 05:17:48 pm
content: Pick C..

author: made2hack
author_rank: Frequent Contributor
timestamp: July 30, 2014, 05:24:11 pm
content: Care to elaborate?

author: retrolefty
author_rank: Super Contributor
timestamp: July 30, 2014, 05:31:12 pm
content: Quote from: trs80 on July 30, 2014, 05:24:11 pmIn 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.

author: ejeffrey
author_rank: Super Contributor
timestamp: July 30, 2014, 05:36:48 pm
content: 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.

author: Phaedrus
author_rank: Frequent Contributor
timestamp: July 30, 2014, 05:38:44 pm
content: Your constant current in B is determined by the resistorhFEandVBE. Unfortunately, these values are not well controlled in production. While a datasheet might list anhFEof 100 are "typical" it may vary from 50 to 250. Additionally, it varies significantly with temperature. You should never base any circuit parameter onhFEif 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.

author: made2hack
author_rank: Frequent Contributor
timestamp: July 30, 2014, 05:38:48 pm
content: Quote from: retrolefty on July 30, 2014, 05:31:12 pmOk, 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?

author: ejeffrey
author_rank: Super Contributor
timestamp: July 30, 2014, 05:52:41 pm
content: 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).

author: Phaedrus
author_rank: Frequent Contributor
timestamp: July 30, 2014, 05:53:00 pm
content: Quote from: trs80 on July 30, 2014, 05:38:48 pmWell 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.

author: mariush
author_rank: Super Contributor
timestamp: July 30, 2014, 06:12:22 pm
content: 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)/RB : 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)/RAn 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.

author: made2hack
author_rank: Frequent Contributor
timestamp: July 30, 2014, 06:32:50 pm
content: @mariush - Yeah, i've used the Mosfet / BJT combination before, I was just looking to simplify and use less parts.

author: Phaedrus
author_rank: Frequent Contributor
timestamp: July 30, 2014, 06:41:58 pm
content: 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.

author: Electronics-Repairman
author_rank: Contributor
timestamp: July 30, 2014, 07:14:27 pm
content: Best idea, go down to the pub , and think about it tomorrow

author: made2hack
author_rank: Frequent Contributor
timestamp: July 30, 2014, 07:18:52 pm
content: Quote from: Electronics-Repairman on July 30, 2014, 07:14:27 pmDid that once, never left!!!

author: jlmoon
author_rank: Unknown
timestamp: July 30, 2014, 07:43:42 pm
content: Quote from: Phaedrus on July 30, 2014, 06:41:58 pmI 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

author: retrolefty
author_rank: Super Contributor
timestamp: July 30, 2014, 07:50:38 pm
content: Quote from: trs80 on July 30, 2014, 05:38:48 pmIt 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.

author: Phaedrus
author_rank: Frequent Contributor
timestamp: July 30, 2014, 08:28:09 pm
content: Quote from: jlmoon on July 30, 2014, 07:43:42 pmVdss = 50VId = 220mAVgs = 0.8 - 1.5VWith 5V gate voltage you'll get about 5ohms RDSonIn my situation that's perfect for driving about 10mA through an LED

author: David Hess
author_rank: Super Contributor
timestamp: July 31, 2014, 02:38:53 pm
content: 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.