PWM RGB LED - help understanding

Thread Starter

yehezkel2

Joined Oct 2, 2009
31
OK,

I want to hook up a power led (RGB) to 3 mosfets, and drive each mosfet by a PWM circuit.

Each PWM circuit has to be driven by a voltage, from a capacitor charged by a logic output.
i.e. - the logic output goes HIGH for the RED channel - slowly charging a big capacitor at the output, which will make the fade in of the led.
so i need the PWM circuit to be controlled by that capacitor - 1% duty cycle when empty, and 99% duty cycle when full).

so if we look here:




R5 determinate the duty cycle ? (PWM brightness)
R1 only determinate the frequency ? (which should be above 33Hz)
did i get it right ?

in other words, the + of the comparator (between 1/3 and 2/3 Vcc) will set the led brightness ?
 
Last edited:

Wendy

Joined Mar 24, 2008
23,415
Yes. You should use a LED driver, as the LM339 doesn't have much drive current (16ma max). I'll eventually update this drawing to reflect this with a simple PNP common collector transistor.

*****************************************

I went ahead and modified the article and the schematic based on your input. Thanks.

 
Last edited:

Wendy

Joined Mar 24, 2008
23,415
I answered them, the answer is yes. You understand it correctly.

Just be aware of the voltage requirements for a MOSFET. Unless you have a logic level device you will need at least 10V to drive it, a BJT doesn't have that issue.

You might want to test select R4 and R6 to get the ratios max and min where you want them. Here is one of my early schematics for this design.



If you're thinking of driving a RGB diode I have another concept in the works (as in not finished). It uses a CMOS hex Schmitt trigger, the CD40106. You'll need a similar transistor drive as I showed earlier.

 
Last edited:

Thread Starter

yehezkel2

Joined Oct 2, 2009
31
thanks.

on another thread, i've been told that BJT are NOT good for this use, since Ic is liked to Ib, and this will prevent getting full current on the emitter-collector.

thus,
i decided using MOSFETs.
i saw a schematic using a STP36NF06 mosfet driven directly by a cmos output, although i cant find 'logic level' in its datasheet, but a Vgs of 2v.

will it be OK with it ?
 

Wendy

Joined Mar 24, 2008
23,415
Maybe, MOSFETs are a weakness for me. But it may still have the problem. We are talking equivalent to saturation. Maybe one of the other guys can help.

The BJT will drop 0.6 volts, the chips go down to 3V. I don't see a major issue with the BJT.

*********************

Thinking about it, I see where the BJT issue is, but that can be fixed by going with a common emitter design for the transistor driver. What is the current you're using for the LEDs, and the power supply?
 
Last edited:

Thread Starter

yehezkel2

Joined Oct 2, 2009
31
Thinking about it, I see where the BJT issue is, but that can be fixed by going with a common emitter design for the transistor driver. What is the current you're using for the LEDs, and the power supply?

I'll use 12v as source,
LED's will be 1W for each color, around 350mA.
a mosfet will allow me even connecting a few 1W LEDs for each color
 

Wendy

Joined Mar 24, 2008
23,415
OK, this would work for 4V to 5V on the power supply, though R7 and R8 need tweaked (I figured for 5V). Anything above 5V the other design would work better.



****************************

Did the math, using the common collector the transistors would disappate ¼W max, which is OK. Don't know who told you different, but in this particular case it would work. At 12V the MOSFET would work better, I tend to think worst case, which is low voltage power supplies in this case.

**********************

Here is how I think a MOSFET version would look.

 

Attachments

Last edited:

Wendy

Joined Mar 24, 2008
23,415
Just modify the comparitors as I've shown. The theory of operation is basically similar, this is a fader circuit however. It turns the LEDs slowly on and off. The slow oscillators (the three on the bottom) are used to modulate the LEDs on and off slowly. The top oscillator is fast, plan around 1Khz or so.

It is meant to be random, and generate every color in the rainbow. Substitute the 555's with the CD40106 (AKA 74C14) and you have two chips total.

This is the end of my day, I'll be back tomorrow (my tomorrow, 3rd shift is weird).
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
OK, this would work for 4V to 5V on the power supply, though R7 and R8 need tweaked (I figured for 5V). Anything above 5V the other design would work better.

Bill,
In the above schematic, the 2.4k resistor will only supply 4.6mA to the base of the transistor with a Vcc of 12v. The "rule of thumb" for transistor saturation is Ib = 1/10 Ic, so above 46mA the transistor will be out of saturation, thus dissipating power as heat.
****************************

Did the math, using the common collector the transistors would disappate ¼W max, which is OK. Don't know who told you different, but in this particular case it would work. At 12V the MOSFET would work better, I tend to think worst case, which is low voltage power supplies in this case.

**********************

Here is how I think a MOSFET version would look.

In this schematic, the MOSFET is upside-down, and the drain and source labels are swapped.
R8 should be around 1.5k Ohms.
On R7; you can place current limiting resistors for LEDs wherever you wish in series with the LED, but I prefer to have the LEDs closest to ground. Less of a chance of a disaster if something gets shorted out.
 

Wendy

Joined Mar 24, 2008
23,415
Bill,
In the above schematic, the 2.4k resistor will only supply 4.6mA to the base of the transistor with a Vcc of 12v. The "rule of thumb" for transistor saturation is Ib = 1/10 Ic, so above 46mA the transistor will be out of saturation, thus dissipating power as heat.

In this schematic, the MOSFET is upside-down, and the drain and source labels are swapped.
R8 should be around 1.5k Ohms.
On R7; you can place current limiting resistors for LEDs wherever you wish in series with the LED, but I prefer to have the LEDs closest to ground. Less of a chance of a disaster if something gets shorted out.
Doesn't work well for RGB diodes, which was mentioned earlier.

I'll correct the schematic. I still have a problem with MOSFETs, as you can tell.

So does this look any better?



I may have accidently erased the old image, I think it was overwritten because I used the same filename.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Doesn't work well for RGB diodes, which was mentioned earlier.
dOH! :rolleyes: That's what I get for posting when I'm tired. ;)
I'll correct the schematic. I still have a problem with MOSFETs, as you can tell.

So does this look any better?

Yes, that's much better.

The 10k pull-up resistor is pretty large. Aim for about 5-6mA current when the comparator's output is low (sinking current). There should also be a small resistor (10 Ohms) between the pull-up resistor and the gate to keep it from "ringing" when the comparator begins to sink current.
 

Thread Starter

yehezkel2

Joined Oct 2, 2009
31
well, i decided to try my circuit with the PWM.

the scheme will be:
a 4029 CMOS driving a singe color LED:
the output will go high, then feeding a big (100-1000uF) capacitor to make the LED fade in softly.
then the voltage raise in this capacitor will control and raise the duty cycle by raising the comparator voltage of the LM399.

am i right until now ?

OK,
on the last schematic just a post above, the + leg of the comparator sets the duty cycle, by 1% at 1/3 Vcc to 100% at 2/3 Vcc (the 555 output is between 1/3 and 2/3 Vcc)

I need help with the schematic that will connect between the fade capacitor and the comparator input.

in other words, how should i make the capacitor give to the comparator:
1/3 Vcc when the capacitor is empty
2/3 Vcc when the capacitor is full (by the CMOS 4029 output)

if you could help with schematics and needed resistors values,
i dont have many components to try this out, so i prefer buying precise values after calculations are done,

thanks a lot for helping !
 

Wendy

Joined Mar 24, 2008
23,415
I've done fadings several ways, it will be my next chapter in my blog. (always a work in progress). Seems we've had a lot of requests for these kind of circuits lately (this being 4 or 5 in a month). Care to show a schematic?

I suspect you're going to have to use a transistor scheme similar to this...



The OP on another thread using a similar scheme I suggested wound up using one transistor, as the duration was too long. Note, prepackaged darlingtons such as a TIP107 will not work as they have built in resistors.
 

Thread Starter

yehezkel2

Joined Oct 2, 2009
31
that's not what i meant...
and BTW, all your led's are reversed in the last schematic ;) what's going on ?

i meant the cmos output and capacitor (just like in your last schematic) will drive the PWM of the previous schematic.
____________________________________________________________

Let's look here:

MY QUESTION IS:
how should look the connection between C6, and the comparator + input ?
ive marked this wire in red.
keeping in mind i want the comparator to get 1/3 Vcc when C6 is empty, and get 2/3 Vcc when C6 is full

i drew what may work, but i need you to check if i'm wrong:
in the following schematic the comparator + is connected to 1/3 Vcc, plus it has the input of C6.
do i need a diode between them to prevent the 10K resistors discharging the capacitor ?


 

Wendy

Joined Mar 24, 2008
23,415
Your right, I messed up. The LEDs are backwards.

You're idea will work, but you'll find it is not self adjusting like the other design on post #10.
 
Top