Let's Make Robots!

How to make LEDs glow not blow!

A tutorial for calculating series resistance and reading LED data sheets
AttachmentSize
tsal5100.pdf111.64 KB
DSE200405_catalogue_data.pdf1.02 MB

I've noticed that some people are uncertain how to calculate series resistance for a LED or when using a group of LEDs are uncertain about wiring them in series or parallel. This walkthrough will try and explain how and why.

LEDs come in a wide range of colour, brightness and power ratings. Some of the latest highpower LEDs even require heatsinking. No matter what LED you want to use, they all have some basic properties in common that you need to know before using them in a circuit.

First of all, LEDs are a polarised electronic component. This means that power must be connected the right way or else damage will occur. For this reason there is always some indication on the caseing as to which lead is positive and which is negative.

This is a photo of a typical LED with it's parts labeled from Wikipedia. Please go to this Wikipedia link for detailed information on LEDs and how they work. Click on the image for a larger picture.

Notice the cathode (negative) has a flat on it's side. The anode usually has a longer lead. If the LED does not have a flat side and the leads are the same length or have been trimmed then notice in this photo that the cathode has the reflector attached.

If you have an unusual LED and cannot determine the + and - leads then check it's datasheet.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notice on this 1W LED that positive and negative are etched on the connections. LEDs like this are mounted on large bases because they need a heat sink. With Aluminium torches, the body acts as a heatsink. Seperate Lens can be bought for these type of LEDs to change the output to a narrow beam if required.

 

 

 

 

 

 

 

 

 

Once you've determined the right way to connect the LED you need to consider current limiting. This is usually done with a resistor in series with the LED. As demonstrated beatifully by Rik, a LED without sufficent series resistance will have a extremly bright but short existance before going up in a puff of magic blue smoke :)

To calculate the correct resistor value you need to know a few things about your LED.

1. what is it's forward voltage drop?

2. what is it's maximum continuous forward voltage.

This information should be supplied with you LEDs or can be found in the data sheet. I've attached the data sheet for a high intensity IR LED as an example of what to expect. It is worth becoming familiar with data sheets. You don't need to understand everything in them but you should be able to find basic information such as absolute maximum ratings and electrical characteristics. The second attachment covers a wide range of components but in the section on LEDs it gives you details on various LEDs such as forward voltage and max continuous current. It demonstrates that both values can vary widely depending on the LED.

Once you know the forward voltage drop and maximum current you can work out your circuit design and resistor values.

This is a basic power indication LED circuit. The formula for calculating the series resistor is:

R ohms = (Vsupply - VLED) / I where "I" is current in amps. For the circuit on the right, assume the supply voltage is 7.2V, the forward voltage of the diode is 2.1V and it's maximum forward current is 15mA.

R ohms = (7.2V - 2.1V) / 0.015A

R ohms = 5.1V / 0.015A

R ohms = 340 ohms

Since you can't get a 340 ohm resistor I would use a 390 ohm. The current would be less giving you a safety margin.

If you are driving a LED from a processor output as an indicator light then the same formula works except that your supply voltage is that of the processor (usually 5V) and your processor is limited on it maximum current output. Pic processors have a maximum limit of 25mA which is enough for most LEDs. Note that the forward voltage of the LED must be less than the supply voltage or else it wont light up.

 

Multiple LEDs series or parallel?

If you want to turn on more than one LED at once then you need to look at the best way to wire them up. Since most robots run on batteries, efficency is a consideration. A series resistor does waste some power so the fewer resistors the better. Having your LEDs wired in series means one resistor can limmit the current for many LEDs but there are limits.

In the sample circuit on the right I'm using an IR spotlight consisting of 8 IR LEDs. These LEDs have a forward voltage drop of 1.2V and a maximum continuous current of 50mA. When you connect LEDs in series then their forward voltage drops must be added together. If I wired all eight LEDs in series then the combined forward voltage drop would be 8 x 1.2V = 9.6V. Since the supply is only 6.6V (a 7.2V battery pack minus 0.6V of a polarity protection diode) the LEDs will not light up. In this case I've created two equal strings of 4 LEDs with each string having a voltage drop of 4 x 1.2V = 4.8V. The resistor value is then (6.6V-4.8V)/0.05A = 36 ohms. By rights the circuit should show 39 ohm resistors as the 33 ohm resistors will allow 54mA to flow. The reason I can get away with this is because these LEDs are only turned on for a few milliseconds at a time in this application and the 50mA limit was a continuous rating. If your design requires the LEDs being on for an extended period of time then you should use a higher resistor value rather than a lower one. By wiring the LEDs in series strings like this, the power wasted by the resistors is the voltage across the resistor multiplied by the current. The voltage across the resistor is the supply voltage minus the forward voltage drop of the LEDs.

P = (6.6V - 4.8V) x 0.05A

P = 1.8V x 0.05A =  0.09W so with the two resistors in this circuit the total wasted power is only 0.18W. Since each string of LEDs draws 50mA the total current drawn is 100mA. Since this is more than the processor can drive directly I've shown a N channel FET driven by the processor. A NPN trasistor could also be used as long as it can handle the 100mA load. There will be a small voltage drop (usually about 0.4V) across the collector - emitter junction of a bipolar transistor. This may need to be taken into acount if your LED forward voltage is close to the supply voltage.

If we had wired the LEDs in parallel with each LED having a series resistor then the power wasted across one resistor would be (6.6V - 1.2V) x 0.05A = 0.27W. Multiply that by eight resistors and that is 2.16W of wasted power. Since they are wired in parallel and each LED wants 50mA, a total current of 400mA will be drawn.

 

 

 

 

 

 

 

 

 

 

 

By connecting them in parallel with a single resistor the math changes a bit. The forward voltage drop across each LED is the same so it is still 1.2V no matter how many LEDs you wire in parallel but now the current required is 8 x 50mA. So now your resistor is:

R = (6.6V - 1.2V) / 0.4A

R = 5.4V / 0.4A

R = 13.5 ohms

And the power wasted is:

5.4V x 0.4A =2.16W, which is exactly the same as before except your single resistor will need to be rated at more than 2.16W.

So as long as the overall forward voltage drop does not exceed the supply voltage then where ever possible it is more energy efficent to connect your LEDs in series.

Reading a LED data sheet:

Below is an extract from the TSAL5100 data sheet with forward voltage drop and continuous current highlighted in blue. Click on the images for a larger picture.

This is the most important information to look for when using any LED. The information in red is usually only supplied for special purpose LEDs such as the TSAL5100. Because this LED is used in IR remote controls where range is important it can be pulsed at higher currents than normal under certain conditions.

Remember that the continuous current for this LED is 100mA. More than this and it will overheat. In fact there is a graph showing how high temperatures can affect the over all power dissipation and continuous current. The 100mA rating does not apply over 25 degrees celcius.

Another good reason to use a slightly higher value series resistor if you live in a hot climate. You don't want your robot to die because the airconditioner stopped working :) According to this graph I should limit the current to about 80mA as it can reach 40 degrees celcius here and I don't have airconditioning.

Pulsing a LED at full power:

Now for some fun, if your circuit or program is not right then your LED could have a very short life expectancy. The data I've marked in red is for pulsing power. It shows a pulse time tp of 100uS. That's 1/10,000th of a second. depending on your ambiant temperature you can have a single surge of up to 1.5A or with a 50% duty cycle you can pulse continuously at 200mA. The 50% duty cycle comes from tp/T=0.5 this means that the pulse time/total time is 1/2. Considering the pulse current is twice the normal forward current this makes sense as the over all power (heat) generated is the same.

What all that boils down to is simply, you can pump twice the normal amount of power through it for 100uS but then you have to turn it off for at least 100uS to let it cool a bit. If you have it on for 100uS and off for 100uS then you get a frequency of 5KHz. So as long as you use a frequency of 5KHz or higher and have a dutycycle of no more than 50% then allowing for ambiant temperature you can pulse that LED all day at twice it's normal current.

You can also send a surge of up to 1.5A through it for 100uS only once and then it must cool down completely before you can do that again. It will depend on the ambient temperature as to how long it will take to cool so they don't specify it in the data sheet.

So how do we use this information?

There is a great tutorial on IR remotes here: http://www.sbprojects.com/knowledge/ir/index.php.

Picaxe has IR transmit and recieve commands like irout and infraout pulse your LED at 38KHz (much higher than the 5KHz minimum) with data modulated into that carrier wave. 

Ken Shirriff has written a great Arduino library for IR remote control here: http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html. If you are using a Micro Magician robot controller then it comes with a library that includes an IR decoder for Sony IR Control (SIRC).

I have now written a SIRC decoder here: http://letsmakerobots.com/node/39384. It is not a library, just a simple function that you can cut and paste into your code. It uses an external interrupt pin rather than a timer interrupt which is useful for preventing timer conflicts.

There is a great tutorial here: http://www.sbprojects.com/knowledge/ir/index.php.

If you need or want to make your own protocol then the only thing you need to do is ensure that the LED can't accidently be left on for more than 100uS. Beware of interrupts and other subroutines that may affect your timing. The FET circuit above is an excellent way of allowing your processor to switch the high currents used for this LED. Because the on resistance of a FET is so low (usually much less than 0.1 ohms) it will not affect your series resistance calculations. If you replace the FET with an NPN transistor you will have to allow for a small voltage drop across your transistor.

You can find more information in GranTotem's tip: http://letsmakerobots.com/node/24218

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

How, specifically would I find the voltage drop of a loose LED with no known datasheet, such as the ones I might get from desoldering a light up toy? Could I just find the resistance and the voltage I will use, and then use Ohm's law to calculate the voltage drop? Or is there more to it?

P.S. I have learned the majority of what I know regarding the mathmatics of electronics from the Science Olympiad competition Shock Value, it does leave some gaps, considering it is designed for middle schoolers, though it does teach us quite a bit, so please don't make things too complex.

Just take a 9v battery with a 1k resistor from + to the LED anode, take LED cathode to ground. Then measure voltage drop across the led.

I like this tutorial OddBot. One thing I wonder about the examples provided though... I thought that when driving LED's in parallel, because of the small differences in the LED's themselves (even from the same batch), that you had to use a single resistor for each LED. Otherwise one diode will conduct slightly before the others, hogging all the current and possibly blowing that LED. If it does then the next time you power the circuit another turns on first... etc...

I used to think that too but in practice that is only necessary if you are using LEDs with different forward voltage drops such as green and red LEDs.

With LEDs of the same type, I think any difference is so small that they can self compensate. So if one LED is drawing more current it will get hotter and the small amount of resistance in the LED will increase.

 

But when the LED heats up it's forward voltage drop lowers, thus increasing the current thru the die, not decreasing it. So instead of self limiting, you have thermal runaway. I do agree that in pratice you can probably get away with this, but not every time. There is a good chance that you will lower the life of the LED's unless the individual LED's are rated to take full current set by the single resistor.

Good point. Please note that in the tutorial the LEDs are only shown this way for the purpose of explaining the math and why series is more efficient than parallel.

As I mention, for the parallel method the resistor would get quite hot and need to be a high wattage type. In practice you would have a resistor in series with each LED because then you could use low power resistors.

the dreaded double post... doh

thank you very much!

I saw this a few days ago and thought while the tutorial was getting updated I'd add it.
http://hackaday.com/2013/12/03/advice-about-over-driving-leds/

Very well done.