Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RGB LED Room lighting project

Status
Not open for further replies.

solis365

New Member
I have a plan to add variable accent/mood lighting to rooms using high powered LEDs, such as the 1W or 3W Luxeon stars

I want to have a way to select any color (probably 128 colors or something like that), and then adjust brightness once the color is selected. I plan on doing this via a PWMing program on an ATMega microcontroller, because that's what I have.

I can use the program to change the PWM for whatever features I want to add.

I'm not worried about the input methods and software so much as I am the interface with the LEDs.

I want to have a series string of a few LEDs of each color, with 3 PWM channels, each controlling one color.

Obviously, the uC cant source enough current to power these LEDs (350mA-1A per channel), so I need to interface. I think the IRL540N (datasheet pdf) would work, as its threshold voltage is only 2V, and seems to be used fairly often for logic level interfacing. I wish to PWM at around 100Hz. The uC should be able to source about 25mA, and I was wondering if this would be enough to drive the FET at that frequency.

The datasheet says the total gate charge is listed as 74 nC, and the input capacitance is listed as 1800 pF (I assume this means if the input is the Gate). Not sure which of these I would go about using to calculate the charge time for the gate when sourced by 25mA of current. Can someone explain this?




In addition to my drive problems, are Red LEDs inherently brighter or dimmer than blue or green LEDs? i.e. if I have 3 LEDs of each color, will one color be brighter at the same current level? I can either compensate by having different numbers of LEDs for each color or by adjusting the amount of pulse width that each channel gets. if anyone has experience with brightness levels that would help. it seems that blue LEDs "look" brighter than red ones...


Also, red, blue, and green LEDs all have different forward drops. I could just use a resistor to deal with this, but that seems inefficient, as I will need some fairly hefty resistors (at least 1W.) Does anyone know of a more efficient way to run the LEDs (perhaps an LM317 current regulator?)


A basic schematic is attached, with current limiting resistors just as place holders. (I had to use a really basic online editor for this one; the circles are LEDs. It counts the fwd voltage on all the LEDs as the same, but thats how I plan to use the MOSFETs; the square wave sources stand for the PWM outputs of the uC.
 

Attachments

  • schematic.JPG
    schematic.JPG
    18.6 KB · Views: 554
You must look at the Luminous Intensity spec for the LEDs on their datasheets to see the difference in brightness of the colours. I can't remember what is the ratio of the brightnesses of the colours to produce white.

Look at their max forward voltage rating and you will see that you cannot connect two 3.5V green or blue LEDs in series and have them driven from a 5V supply.

Look at the max allowed current spec for the output of your micro-controller. They do not limit the current. The max allowed output from a PIC is 25mA and it will overheat and fail if it is loaded more since it will try to force 60mA.

The Mosfets should have a series resistor at the gate to stop very high frequency oscillation and it can limit the gate capacitance charging current to 25mA.

An LM317 current regulator needs to have 3.25V of headroom which you do not have. It will heat exactly as much as a resistor.
 
I should have been more detailed on the schematic, it was just to get across the idea. But then you wouldnt know which parts I had actually forgotten and which parts I left out, so thanks.

I think I will have separate voltage rails for each color depending on what the forward voltage drop ends up being, and perhaps I'll just use a 555 PWM circuit for tests (well, 3 actually), and rig up a pot on each one and mix until I get the right balance. Then measure the resistance on the pot and back calculate approximately what the duty cycle is. In addition to reading datasheets for the actual LEDs that I end up purchasing.

How does one go about deciding what value of resistor to place at the gate? It seems as if you would have to know the voltage at the gate, and to find the resistance then it would just be

(5V - Vg)/25mA = R (assuming the uC puts out 5V)

But what is Vg? Or is there another way to calculate this value?

(Thanks for your input by the way)





and @ gayan, thanks for the link, that's a pretty nice setup he's got there. Kind of a long term goal that I have as well, but I'm just going to start small with a lamp for now. That is a really cool link though, and it brought me to another project very similar to mine. Thanks!
 
Look at the max allowed current spec for the output of your micro-controller. They do not limit the current. The max allowed output from a PIC is 25mA and it will overheat and fail if it is loaded more since it will try to force 60mA.

Hi,

He said he plans to use an Atmel AVR microcontroller. The AVR can source or sink 40mA from any I/O pin, but this is the absolute max rating. To be safe, you should probably keep the current through any I/O pin under 30mA. Also, the AVR has a maximum current rating *per port* and for the Vcc and Gnd pins, which is 200mA. So just be careful to not exceed those "global" current limits.

Regarding the series gate resistor for the MOSFETs, it is not there to regulate gate voltage, but to limit gate current. You'll probably want to use the lowest value gate resistor you can since this will allow the MOSFET to switch on and off faster (since the gate acts like a capacitor). Faster switching means less power dissipation in the MOSFET during switching transitions. Your limit is you shouldn't exceed about 30mA from the AVR's I/O pins. So figure a value in the 166 to 200-ohm range is probably the lowest you'd want to go if VCC is 5 volts.

Hope that helps,
-Nick
 
Last edited:
Regarding the series gate resistor for the MOSFETs, it is not there to regulate gate voltage, but to limit gate current.

Yes, I understand, but how do you go about calculating those values (166-200Ω)? A current limiting resistor works because there is some defined voltage across it, and ohms law will limit the current passing through the resistor based on its resistance *and* the voltage across it.

i.e. say you are current-limiting a string of 4 LEDs with a forward voltage drop of 2.1V per each LED, and you want 20mA through the string, and are powering it from a +10V rail. Then, the LEDs take 4*2.1V = 8.4V. Whats left is 1.6V for the current limiting resistor to drop, and you select the resistance such that R = 1.6V / 20mA = 80Ω. My point is, you need to know the voltage thats going to be dropped across the resistor in order to select the proper value for it. So, if the gate acts as a cap, where is the voltage referenced from?

I plan on using NMOS devices to sink my current, so the Sources of my FETs are at ground. So do we look at the uC pin as "+5V", then a resistor, then a cap in series, and then ground? I.E. just the gate-source capacitance? Do we worry about gate-drain capacitance? If so, what voltage is my drain at (I think it would be 5V if the FET is off)
 
The gate capacitance is discharged (is a short to ground) when the micro-controller's output pin goes to +5V. So the current in a 160 ohm current-limiting resistor is 5V/160= 31.3mA.
But the pin goes to 5V only when it has no current so the datasheet must be checked to see if the output voltage is 4.5V when the load is 28.1mA (160 ohms).
 
ah, thanks for the clarification. makes sense. this thing should be fairly simple to get underway now.

the threshhold voltage on the FETs I plan on using is 1-2V, so even under a load I don't think the output pins will drop by that much. again, datasheet inspection will occur before everything is wired up to make sure this is the case.
 
the threshhold voltage on the FETs I plan on using is 1-2V, so even under a load I don't think the output pins will drop by that much. again, datasheet inspection will occur before everything is wired up to make sure this is the case.
The Mosfet current at the gate threshold voltage is only 0.25mA which is nothing. Instead of the threshold voltage you should look at the gate voltage when the Mosfet is guaranteed to be fully turned on. 4.5V or 5V for the logic-level Mosfet.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top