# Designing driver circuit for RGB Power LED with dimming PWM control



## Joern (Apr 22, 2013)

Hi everyone,

I started an electronics project of my own recently. I intend to build a Wake-up / Mood Lamp with a high power RGB LED which is to be controlled via a web interface run on a RaspberryPi and accessed via smartphone. As an aspiring software engineer, the program interfaces shouldn't be much of an issue for me, sadly though, I'm pretty bad at electronics and circuit design. (This is my second electronics projects so far -- I built a light sensing mouse robot before, which was mildly successful). So I'm posting here in hope for advice and assistance before I am going to build non-working, inefficient or possibly hazardous circuits.

My plan:
I want to put a *3Watt RGB LED* (on a heatsink) into my lamp with following specs:
( ordered from DX.com: http://dx.com/p/4530 )


R 3.0 V, 350 mA
G 3.8 V, 350 mA
B 3.8 V, 350 mA
_Note:_ this LED has a common anode according to the review comments on DX.com.

*Power Supply* is to be an ordinary phone charger with *5V, 1A DC*.
_Question:_ Is 1A sufficient or should I get a power supply with more current (e.g 1.2A) considering all colour LEDs consume 1050A on max combined?

The past week, I've been reading up on Electronics theory, LEDs, transistors, PWM, circuit design, application examples, instructables, etcpp. (read and catalogued content with around 58 website bookmarks...). I managed to acquire a humble understanding of this matter, still I feel a little overwhelmed.

I finally drew up a simple schematic I would love to hear your advice about. 






You can see the RGB LEDs on top connected to the power source, each with a voltage limiting resistor, followed by an N-MOSFET, whose gates are connected to the respective PWM signal output from the RaspberryPi to control the brightness of the LEDs. The RaspberryPi and LED power supply have a common ground. The resistors between MOSFET and PWM output are supposed to protect the RaspberryPi I think? I'm not really sure from what though, now that I look at it.

To reduce the voltage for the LEDs I calculated their resistors to be:
Rr : (5V - 3V) / 0.35A = 5.7 ohm
Rg, Rb : (5V - 3.8V) / 0.35A = 3.4 ohm
with power dissipation of 0.35A² x 5V = 0.6 Watt each (_is this too much?_).

*So, first of all*: Can you tell me if this circuit works?
Would it be better if to make a voltage divider to drop the 5V to 3.8V first before connecting power supply to the LEDs? (or voltage dividers for each LED, regarding that the red LED needs lower voltage than green and blue?)
Is there a way to (easily) improve on this circuit to make it
(a) more efficient
(b) provide better dimming results
(c) safer for components and living creatures?

I haven't decided on any specific MOSFET yet either. Do you have any recommendations? I still have to analyze and understand MOSFET data sheets and the necessary specifications for my appliance.

I've also seen some schematics for LEDs including a MOSFET & (Pull-down) Transistor like so:
http://www.pcbheaven.com/userpages/LED_driving_and_controlling_methods/?topic=worklog&p=5
or so: http://www.instructables.com/id/Cir...tep6/The-new-stuff-Constant-Current-Source-1/

Would this make sense in my case?
Does the stuff I wrote here make any sense? 

I'd really appreciate your help and advice!
Thanks and Regards, Jörn


----------



## Steve K (Apr 22, 2013)

Joern said:


> *Power Supply* is to be an ordinary phone charger with *5V, 1A DC*.
> _Question:_ Is 1A sufficient or should I get a power supply with more current (e.g 1.2A) considering all colour LEDs consume 1050A on max combined?


I think you'll probably want to have a good sized capacitor from the 5v bus to ground in order to handle the current surges. Maybe 470uF? It's always a good idea to have a large capacitor to handle the changes in current demand like this. You may also consider increasing the size of the resistors that are in series with the LEDs, and dropping the LED current to 330mA.



Joern said:


> You can see the RGB LEDs on top connected to the power source, each with a voltage limiting resistor, followed by an N-MOSFET, whose gates are connected to the respective PWM signal output from the RaspberryPi to control the brightness of the LEDs. The RaspberryPi and LED power supply have a common ground. The resistors between MOSFET and PWM output are supposed to protect the RaspberryPi I think? I'm not really sure from what though, now that I look at it.



The resistors that are in series with the MOSFET gate aren't absolutely necessary, but are useful to slow the turn on and turn off of the mosfet a bit. A fast turn on and turn off of the MOSFET can cause electrical noise, and the fast turn off of the MOSFET can cause large voltages to be generated by the wiring in the MOSFET's drain circuit, which can actually cause problems in turning the MOSFET off. I think I'd start with 100 ohms or so, as a rough estimate.



Joern said:


> To reduce the voltage for the LEDs I calculated their resistors to be:
> Rr : (5V - 3V) / 0.35A = 5.7 ohm
> Rg, Rb : (5V - 3.8V) / 0.35A = 3.4 ohm
> with power dissipation of 0.35A² x 5V = 0.6 Watt each (_is this too much?_).



0.6W is less than what is being dissipated in the LEDs, so it's not so bad. It's not that much power... just make sure you use resistors with a suitable power rating. Just pick resistors rated for 1 watt, to be safe. 



Joern said:


> *So, first of all*: Can you tell me if this circuit works?
> Would it be better if to make a voltage divider to drop the 5V to 3.8V first before connecting power supply to the LEDs? (or voltage dividers for each LED, regarding that the red LED needs lower voltage than green and blue?)
> Is there a way to (easily) improve on this circuit to make it
> (a) more efficient
> ...



It should be fine. You will be dissipating 5 watts, so be sure that there is a way to get the heat out of the electronics.



Joern said:


> I haven't decided on any specific MOSFET yet either. Do you have any recommendations? I still have to analyze and understand MOSFET data sheets and the necessary specifications for my appliance.


Find an N MOSFET with a Vdss rating of 10v or so, an Rds suitably small (0.1 ohms is a good start), and a low enough Vgs to have low resistance at 330mA. Some MOSFETs are called "logic level", which means they are fully turned on with a Vgs of 5v, which is what you want.



Joern said:


> I've also seen some schematics for LEDs including a MOSFET & (Pull-down) Transistor like so:
> http://www.pcbheaven.com/userpages/LED_driving_and_controlling_methods/?topic=worklog&p=5
> or so: http://www.instructables.com/id/Cir...tep6/The-new-stuff-Constant-Current-Source-1/
> 
> Would this make sense in my case?



The resistor on the source circuit, along with the NPN transistor, form a current limit circuit. Not needed when you have a regulated voltage and are already dropping a fairly large amount of voltage across the resistors that you use to set the current. 



Joern said:


> Does the stuff I wrote here make any sense?
> 
> I'd really appreciate your help and advice!
> Thanks and Regards, Jörn



You're in pretty good shape. Just pick out a suitable MOSFET.. and pick out a package that can dissipate whatever heat is lost in the MOSFET. Shouldn't be much, though..


----------



## Joern (Apr 28, 2013)

Thanks Steve, that's really helpful!

I finally had the time to reflect on what you wrote and am looking for a suitable MOSFET right now.

I found the IRLR 8721 PbF ( Datasheet: http://www.produktinfo.conrad.com/d...1231-da-01-en-MOSFET_IRLU8721PBF_I_PAK_IR.pdf )
Is this a logic level MOSFET? It looks like one to me with quickly growing Id to Vgs ( 4A Id @ 3V Vgs)
Short spec overview:
Vds : 30V
Rdson: 8.4mOhm
Vgs: typically 1.9V, min 1.35V, max 2.35V

Would this be a good MOSFET to drive my LED?

Regards,
Jörn

edit: Ok, I think I just had a very revealing discovery. Apparently, the L in the MOSFET ID stands for Logic Level.


----------



## Steve K (Apr 28, 2013)

that looks like a good choice. If you want to, you could look for one that is a bit smaller. That mosfet is a bit oversize for 1 amp, so you might be able to find one that is smaller and cheaper that would work. Maybe something in a SOT-223 package?


----------



## Joern (Apr 28, 2013)

Those SOT-23 and SOT-223 components are really cheap! But I only have ordinary through-hole plates to mount my electronics on and I'm a really bad shot at soldering.


----------

