Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Resistor Value for RGB LED


Best Answer CW2, 02 February 2013 - 06:55 PM

It is considered good practice to use separate resistor for each LED. The formula is R = (VCC - VF)/IF, where VCC is the supply voltage, VF is LED forward voltage and IF is the desired LED current. So in your particular case RR = (12 - 2)/0.02 = 500 ?, RG = RB = (12 - 3.2)/0.02 = 440 ?. The values can be a little bit lower (~10%) if you account for voltage drop of the transistors (about 0.7V at 20 mA).  
 
The resistors will be dissipating ~9V*0.02A = 0.18W, so use ones with appropriate power rating (at least 0.25W).

Go to the full post


  • Please log in to reply
9 replies to this topic

#1 Andre Trollip

Andre Trollip

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationGauteng, South Africa

Posted 02 February 2013 - 06:23 PM

Hi Guys,

 

I am controlling an RGB LED from my Netduino. I want to know how to calculate the resistor value R1 in my circuit. What throws me off is that the LED's are not the same forward voltage. The RGB LED has a common anode.

 

It works fine but the resistors get very very hot. I am using 2 x 100ohm resistors in series for R1.

 

And in general, is my circuit technically correct and efficient? Can lower the R1? Here is the diagram.

 

Attached File  RGB LED.jpg   29.55KB   47 downloads

 

Thanks in advance.



#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 02 February 2013 - 06:55 PM   Best Answer

It is considered good practice to use separate resistor for each LED. The formula is R = (VCC - VF)/IF, where VCC is the supply voltage, VF is LED forward voltage and IF is the desired LED current. So in your particular case RR = (12 - 2)/0.02 = 500 ?, RG = RB = (12 - 3.2)/0.02 = 440 ?. The values can be a little bit lower (~10%) if you account for voltage drop of the transistors (about 0.7V at 20 mA).  
 
The resistors will be dissipating ~9V*0.02A = 0.18W, so use ones with appropriate power rating (at least 0.25W).



#3 Andre Trollip

Andre Trollip

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationGauteng, South Africa

Posted 02 February 2013 - 07:26 PM

Thanks CW2. That makes sense. I have one resistor because there is a common annode, but just realised I can put the resistors after LED's (connected to the cathodes). Thanks again.

#4 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 02 February 2013 - 07:58 PM

Hi Galibore,

 

Have you had any problems turning off the LEDs?

You are using pnp transistors; to turn them on, you need to pull the base down to about 0.7V below the voltage at the emitter - easy. But to turn them off you need to push the base up close to that emitter voltage - since the Netduino can only output 3.3V, and your external supply is12V,  this may be hard to acheive.

I suspect that when you try to turn each LED off, you will find there is still some current flowing.

 

Basically, when you use an npn transistor, your drive voltage on the base is relative to the ground. When you use a pnp transistor it is rellative to the positive supply.

 

You may find you don't have a problem (or don't care), but it may be worth measuring the current with an ammeter if you have one available.

 

Remember its supposed to be fun! - Paul



#5 Andre Trollip

Andre Trollip

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationGauteng, South Africa

Posted 02 February 2013 - 08:09 PM

Hi Paul, thanks for this. Coincidentilly, I found out earlier tonight that my ammeter is broken (probably the fuse). I don't have a problem turning it off, but I probably won't know for sure until I measure.

#6 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 02 February 2013 - 08:42 PM

You are using pnp transistors


I think there is wrong symbol used in the schematic, 2N2222 is NPN.



#7 Andre Trollip

Andre Trollip

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationGauteng, South Africa

Posted 02 February 2013 - 09:20 PM

I think there is wrong symbol used in the schematic, 2N2222 is NPN.

Yeah sorry my ignorance shining through again.

#8 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 02 February 2013 - 09:45 PM

Yeah sorry my ignorance shining through again.

I've had 30 years practice at making stupid mistakes :blink:  you've got some catching up to do!

Paul



#9 Andre Trollip

Andre Trollip

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationGauteng, South Africa

Posted 03 February 2013 - 06:55 AM

On your heels buddy :) Just a question for interest sake; if the RGB LED was a common cathode, how would I wire that?

#10 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 03 February 2013 - 11:55 AM

Use one of each! A pnp and an npn.

 

The npn and pnp transistors need current to flow to turn them on.

 

That means that for an npn we need 0.7V plus the common cathode LED forward voltage (3.2V worse case), so we need to drive the base with 3.2V + 0.7V = 3.9V to get the current to flow into the base and turn the transistor on. That's too high for the Netduino outputs to reach.

 

For a pnp, we just need to provide a voltage 0.7V below the emitter, so with a 12V supply that easy for a Netduino output, unfortunately its too easy. The 3.3V high voltage level for the Netduino is also going to give a path for the current to flow out of the base to ground, so we can't shut off the transistor.

 

Solution 1, is to use the tri-state output mode of the Netduino. When the GPIO pin is set to tristate, no current can flow in or out of the pin, so this could be used with a pnp transistor. When the transistor needs to be on, set the output low, when it needs to be off, set it to tri-state.

There are two reasons this is not going to be useful to you:

1 - I don't think you can set a PWM to operate in tri-state mode.

2 - With the 12V supply, when the pin is set to tri-state, the voltage at the GPIO will be pulled up to near 12V via the transistor's base. The Netduino will not like this.

 

Solution 2, is to use an npn transistor to turn on a pnp transistor.

Here the npn transistor is wired up normally. The collector goes to the base of a pnp transistor via a resistor. Now when the npn is turned on, current will flow from the pnp's base to ground turning on the pnp. When the npn is off, no current can flow, so the pnp will be off.

 

Paul

 

 

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.