42

I'm trying to work out what value resistor to use in a LED circuit. The equation I'd use to do this is:

$$ R = \frac{V_{cc} - V_f}{I_f} $$

Seems logical, and makes complete sense. The answers to the question How do I calculate the resistor value for a simple LED circuit? confirm this too.

I have the following LEDs:

  • \$ V_f = 3.3V \$
  • \$ I_{f_{typ}} = 20mA \$

Using a 5V power supply:

  • \$ V_{cc} = 5V \$

Plugging these into the above equation gives:

$$ \begin{eqnarray} R & = & \frac{V_{cc} - V_f}{I_f} \\ & = & \frac{5V - 3.3V}{20mA} \\ & = & 85\Omega \end{eqnarray} $$

All good so far.

However, if I use the calculator at http://led.linear1.org/1led.wiz, that gives me 100Ω. If I use the ElectroDroid app on my phone, that gives me 85Ω.

So, I assume that the linear1 calculator is using a different method of calculating this resistor value; is there some better way of doing this?

Jeremy Kerr
  • 1,092
  • 1
  • 8
  • 15

2 Answers2

43

Your calculation is correct. linear1 rounds up to the next E12 value, which happens to be 100\$\Omega\$. The nearest E12 value would have been 82\$\Omega\$, and that would still be safe, because, even if the current will be higher, the difference will be small, within the 10% tolerance of the E12 series.

edit
Purists may say I'm cutting corners here. Russell has a long answer about iterating the solution, and others whine (hey, no offense!) about rounding up being more safe. My answer is meant to be pragmatic; no professional design engineer can afford to spend 15 minutes to calculate the resistor for a classical color LED. If you stay well below the maximum allowed current you'll have enough headroom to allow some rounding, and the rounded value won't be noticeable in brightness. For most LEDs perceived brightness doesn't increase much above a value of typically 20mA, anyway.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
  • Ah! makes sense, thank you. Yes, 82Ω seems close enough, at 20.7mA. – Jeremy Kerr Jul 21 '11 at 08:19
  • You can check the rounding up. If you choose 21mA the resistor should be 81\$\Omega\$, and linear1 shows 82\$\Omega\$, again the next E12 value. – stevenvh Jul 21 '11 at 08:20
  • Just a quick (probably obvious) addendum: it's better to round up your resistors when working with LEDs as that will under-power rather than over-power them, hopefully making them last longer. Though 0.7mA shouldn't make any difference, and variation in Vf will probably fudge the current by about the same... – Al Bennett Jul 21 '11 at 08:53
  • @Al - that's most certainly the reason why they rounded it up. But if you don't calculate it at the maximum current (which you should never do anyway), there's absolutely no harm in having 21mA instead of 20mA. – stevenvh Jul 21 '11 at 09:01
  • 3
    Pragmatism ... sigh ... I miss working with pragmatic people. Intellectual engineering types tend to go OCD on things that are utterly pointless at the expense of the *really* important things, like schedules (and lunch breaks, and weekends with family/friends)... – Adam Lawrence Jul 21 '11 at 13:39
  • 1
    @Madmanguruman - ...having a drink with friends on a terrace downtown on a sunny evening. Indeed, you absolutely have to balance [your priorities](http://www.lifemastering.com/en/syltetoy_og_bayer.html)! – stevenvh Jul 21 '11 at 13:48
  • @stevenvh Luckily, I'm not called on as much as I once was for extraordinary efforts (perhaps I'm just immune to the guilt trips and threats at this point in my career!) – Adam Lawrence Jul 21 '11 at 13:54
  • Ifmax is 100mA, so I'm not too concerned about that extra mA. – Jeremy Kerr Jul 22 '11 at 08:36
  • 1
    @Jeremy - 100mA is quite high, it's probably Absolute Maximum Ratings (AMR). You should *never* operate continuously under AMR. Like it says it's *Absolute Maximum*, which means almost guaranteed damage if you exceed that. But like I said, most LEDs don't have much gain in brightness above 20mA, anyway. – stevenvh Jul 22 '11 at 08:44
20

Your formula is correct BUT to do it properly you need to iterate the result (or use a simple graphical load-line method - see at end).
This is because LED forward voltage drop is non linear with current (or current is non linear with forward voltage drop. In many cases this effect is not significant, but in some cases it can lead to results which are 2:1 or more in error.

Where there is plenty of "headroom" voltage for the series resistor - the difference between Vcc and Vf - the original result is liable to be close enough to correct so as to not matter. But if headroom voltage is small with respect to Vf, changes in LED Vf with current will change headroom which will change current which will change Vf which will ... . This really does happen in real world situations.

For white LEDs Vf is typically in the 2.9V to 4V range with more typical values 3.3 - 3.8V until quite recently and say 3.0 - 3.3V in more modern higher efficiency LEDs. In serious production applications Vf will be available in "bins" so can be guaranteed within about +/- 0.1V at a given current. In retail sales you may get samples from every bin going and Vf may be eg 3.3V for one LED and 3.6V for another nominally identical one.

If operating from 5V the headroom will be 1.7V and 1.4V respectively for a current variation of about (1.7-1.4)/1.7 =~18%. Add to that slight shifts in Vf with current as above and 20% variations in If may result between "identical" LEDs. In most cases this is not going to make the slightest practical difference. Light output is approximately proportional to current - 20% variation in light output is not detectable by eye by all but the most skilled or experienced of viewers.

If this was a say 5 Watt power LED the difference in LED dissipation may be 1 Watt and this MAY make a difference in operating temperatures and lifetime.

All of which leads to the advice that in "serious" applications LEDs should be driven from a constant current source if you care about the true operating current. In "indicator" roles or low level illumination applications this may not matter. In high power applications or where LED lifetime matters then constant current drive is essential.


SH correctly commented:

The classical non-iterative method would be to take the LED's characteristic curve and draw a loadline across it so that it intersects the curve at the operation point the user desires. The slope tells you the resistance. People did this all the time in the vacuum tube era when there were no pocket calculators.

This is a quick and easy method which produces the same final result. Wikipedia

enter image description here

Simple & useful load line tutorial here

Mostly-related images, each links to a webpage here

Russell McMahon
  • 147,325
  • 18
  • 210
  • 386
  • 5
    While theoretically absolutely right, I don't know *any* engineer who wastes his time on iterating for a classical LED (BTW, the graphical method is faster). The differences in appearance are simply too small. (And provided that you don't operate the LED at its maximum current, which you never should do anyway) – stevenvh Jul 21 '11 at 08:57
  • @Russel - What is this "Ref: TMBJ" thing at the end of your last answers? The [acronym dictionary](http://acronyms.thefreedictionary.com/TMBJ) says it's either They Might Be Jedi or Thermoplastic Minerva Body Jacket. If it's a sig, it belongs in your profile. You can edit your username, too, if you want it displayed in all your answers. – Kevin Vermeer Jul 21 '11 at 13:24
  • @Kevin - My guess is "This Might Be (J)useful" :-). In a comment to [this answer](http://electronics.stackexchange.com/questions/17174/why-use-lnas-in-a-noise-generator/17178#17178) I explained why it would be deleted, as Kortuk apparently did. – stevenvh Jul 21 '11 at 13:43
  • Juseful? I suppose it's an easy typo... – Kevin Vermeer Jul 21 '11 at 13:48
  • 9
    You now know one engineer who iterates LED currents when it's a good idea to do so. If you NEED to iterate you have too little headroom for safety - but if you have too little headroom for safety you need to iterate. There is no reason not to operate an LED at its maximum RATED current if it serves a need and if you design correctly. I have around 2 million LEDs "out there" which are designed correctly :-) (and constant current driven). – Russell McMahon Jul 21 '11 at 14:18
  • 3
    Ah - the phantom downvoting moron has struck almost a year after the event. – Russell McMahon May 31 '12 at 20:39
  • I'm going to use 220 ohm resistor arrays for my LED project. 220 ohms was a compromise between brightness and limiting the current to the LED. 5 Volt application. So....am I right? (I'm not an engineer) – Tim Spriggs Nov 14 '16 at 22:23
  • @TimSpriggs What colour LEDs? What Vf target, what current target. White and blue operate with Vf around 3 - 3.5V, red 2V ish, others intermediate. 5V at Vf = say 3.2V and 220 R -> I = (5-3.2)/220 =~ 8 mA. Lower than max usually. But red 2V = (5-2)/220 =~ 14 mA. Still lower than typical allowed 20 mA max BUT max varies with type. And if you have many (100+ say) you may care about max current but if only a few you usually don't. As a guide: Rmin = (Vsupply max - Vfmin)/I_LED_max so if these are 5.2, 1.8, 20 mA Rmin_safe = (5.2-1.8)/0.02 = 170 Ohms. This give 20 mA max under above ... – Russell McMahon Nov 15 '16 at 01:39
  • @TimSpriggs ... stated worst case conditions. If instead was Vcc_abs_max = 5.2, VF_abs_min = 2.9V, I_LED_max_allowed = 20 mA then Rmin = (5.2-2.9)/.020 = 115 Ohms. Add a margin for resistor t olerance if you REALLY do not want to exceed Imax_LED. – Russell McMahon Nov 15 '16 at 01:41
  • The classical non-iterative method would be to take the LED's characteristic curve and draw a loadline across it so that it intersects the curve at the operation point the user desires. The slope tells you the resistance. People did this all the time in the vacuum tube era when there were no pocket calculators. – sh- Apr 20 '19 at 11:10
  • @sh- [8 years on ! :-) ] . Yes. I used to live in that world :-). I'm olde-ish. Ideally, of course, constant current drive is used and deals with temperature, production spread, ... . – Russell McMahon Apr 20 '19 at 12:54
  • @sh- Another 20 months on I've added a comment on load-line method at the end :-). Thanks. – Russell McMahon Dec 15 '20 at 20:02
  • 1
    @RussellMcMahon Though 20mA through an LED in 2002 seems like it should come with a warning about not looking directly at the light source. – Spehro Pefhany Dec 15 '20 at 20:42
  • @spehro The 2002 had me scratching my head for a while :-). – Russell McMahon Dec 15 '20 at 23:40
  • @RussellMcMahon A typo, obviously(?). ' – Spehro Pefhany Dec 15 '20 at 23:41
  • @SpehroPefhany Indeed. After a while - but it was not obvious to my brain for some seconds :-). I thought back to the state of LEDs in 2002. Hmm - not at all bright. Nichia safety tested some of their LEDs for me in about 2008 - the blue end of the spectrum was classified as mildly hazardous. (Classification escapes me). I asked them about eye hazard issues and was pleasantly be surprised that they had assigned the task to the lab queue and that they would notify me in due course. We may have used approaching a million of them - small by their standards. The still impressive NSPWR70CSS-K1 – Russell McMahon Dec 16 '20 at 09:34