PWM RGB LED - help understanding

Discussion in 'General Electronics Chat' started by yehezkel2, Oct 10, 2009.

  1. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    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:

    [​IMG]


    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: Oct 12, 2009
  2. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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.

    [​IMG]
     
    Last edited: Oct 10, 2009
  3. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    the mosfet need is known to me, as i plan on using power leds.

    but, can you please refer to my questions ?

    thank you !
     
  4. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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.

    [​IMG]

    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.

    [​IMG]
     
    Last edited: Oct 10, 2009
  5. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    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 ?
     
  6. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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: Oct 10, 2009
  7. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    trying to understand your RGB led drivers on the second schematic,
    could you explain its controls please ?
     
  8. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0

    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
     
  9. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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.

    [​IMG]

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

    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.

    [​IMG]
     
    Last edited: Oct 10, 2009
  10. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    ............
    [​IMG]
     
  11. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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: Oct 10, 2009
  12. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    OK i got it.

    thank you !
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  14. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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?

    [​IMG]

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

    Expert

    Jul 17, 2007
    22,182
    1,728
    dOH! :rolleyes: That's what I get for posting when I'm tired. ;)
    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.
     
  16. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    Still seems backwards to me, Source is ground, Drain is the power supply.
     
  17. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    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 !
     
  18. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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...

    [​IMG]

    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.
     
  19. yehezkel2

    Thread Starter Member

    Oct 2, 2009
    31
    0
    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 ?


    [​IMG]
     
  20. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    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.
     
Loading...