Question on PWM LED Drive

Discussion in 'General Electronics Chat' started by Sonoma_Dog, Sep 11, 2008.

  1. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    Hi, I Have designed this very simple PWM LED Driver, but have couple question needs to make sure before i order all the parts and build a prototype.

    This circuit will be controlled with a 5v PWM from a microcontroller and that signal will go through a comparator turns the 5v PWM singal to 12v. Then the singal will drive the power mosfet and it will light up the LEDs.

    ok The questions i have is..

    1) what kind of power mosfet should i use? If i only want to draw 3A of current MAX.

    2) for the comparator, I can just pick up any cheapo op-amp and it should be fine right?

    2) Why at that node (red arrow) the voltage goes below zore, from what i learned from school, that node should never go below zore right?


    Thanks so much in advance,

    Sonoma_Dog
     
    • 1.JPG
      1.JPG
      File size:
      192.8 KB
      Views:
      169
  2. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,440
    368
    What's the comparator for? A common-emitter transistor stage is the usual way to go.

    Aside from the unnecessary comparator, since the LEDs are being driven from a PWM source, you could be a bit braver and go for smaller value series resistors.
     
    Last edited: Sep 11, 2008
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    If you end up using an AVR microncontroller, most of them possess a built in PWM generator. I have used the PWM from an AVR microcontroller to fade LEDs and it works great.

    hgmjr
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    It would be much more simple if you used a MOSFET that was capable of being driven by logic-level signals, like an IRLIZ14 or IRLZ14. They're rated for 8A, but using components that are rated for 2x or more the expected load is good practice. This would enable you to drive the MOSFET directly from the output of the uC. Use a resistor to limit max current between the gate and the I/O pin of the uC.

    Also, in your schematic you are using an N-ch MOSFET on the high side of the LEDs and their resistors. Instead, use the MOSFET to switch the ground side of the LEDs on and off. Otherwise, you will have to keep the gate voltage higher than the drain voltage to keep it turned on. You can't do that without using a high-side driver IC or equivalent.

    Logic-level MOSFET, specified above.

    You should never use an op amp as a replacement for a comparator. Op amps were not designed to be run in constant open-loop; this keeps their output in constant saturation, leading to heating and a short life.

    The simulation isn't handling the circuit well, because you've used the MOSFET incorrectly. It needs to be between ground and the low side of the LEDs.

    As far as the current limiting resistors for the LEDs, calculate them as:
    Rlimit = (Vsupply - Vf(LED))/LEDCurrentDesired
    For the moment, assume 100% duty cycle for PWM (on all the time)
    Vf(LED) is the typical forward voltage of the LED at the specified current.
    So, if your Vf was 2.1v, and your desired current was 20mA, your Vsupply is 12v:
    Rlimit = (12 - 2.1)/20mA
    Rlimit = 9.9/0.02 = 495 Ohms.
    The closest standard value >= 495 is 510 Ohms.
    I(LED) = 9.9/510 = 19.4mA. Close.
    Let's calculate wattage required:
    P=EI, or Power in Watts = Voltage x Current
    P = 9.9 x 0.0194 = 0.19206 Watts
    For reliability, we double that result to 0.38412 Watts.
    You will need to use 510 Ohm resistors rated for 1/2 Watt for this example.

    However, you could also run multiple LEDs in series. This will waste less current on heating up resistors, and instead spend it lighting up LEDs.
    One reliable way to figure out how many you can run in series is
    INT((Vsupply-1)/Vf(LED))
    Or, subtract 1 volt from your supply voltage, divide that result by your LED's typical Vf, and use the integer result.
    In our example:
    INT((12-1)/2.1) = INT(11/2.1) = INT(5.2381) = 5
    Then you would need to subtract the total Vf of the 5 LEDs from your Vsupply instead of just a single LED in the above equation.
     
    Last edited: Sep 11, 2008
  5. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    Yeah i have used a CE NPN transistor configuration before (see picture, i lost the scehmatic, but i think that's what i had ), the transistor heats up pretty quick and i think is because the the voltage drop across the collector and emitter is big, so it increases the power dissipation. i might be wrong tho.

    That's why i wanted to convert the 5v PWM to 12v. so it will decrease the voltage drop across the collector and emitter.

    and also, the current will decreases when i add more LEDs in parallel . that's why i decided use a mosfet .

    Please give me some more recommendation and advices.

    Thank you so much.
     
    • 12.JPG
      12.JPG
      File size:
      45.2 KB
      Views:
      140
  6. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    oh wow, looks like it can be done in just a very simple circuit.

    i am going to simulate it then build the prototype and test it out.

    hopefully this time i wont be blowing anything up as i always do.

    thanks SgtWookie!!!
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    In that schematic, you had the transistor basically shorting out the supply instead of gating the current through the LEDs! :eek:

    If you had instead used the NPN transistor to control the LED's ground path, your circuit would have been much better.
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I added more information to my 1st reply after you'd replied to it.
     
  9. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0

    I thought the LEDs will turn on when the NPN transistor is in it's cut-off mode.
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Yes, they will. However, it would be a far more efficient circuit if you had used the transistor as a switch to turn the current to the LEDs on and off, rather than causing all of that power to be dissipated in the transistor and the collector/emitter resistors. Besides, you could also get rid of R2 and R8, as they would no longer be necessary.
     
  11. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    I am going to do all the calculation and draw out the schematic, i will post it in a little bit.

    Got another question, I am going to use one of these LEDs (see link). and it said it's resistor free. So is that mean the resistor is already integrated within the LED?

    if the resistor is already integrated in the LED, the resistor values would be Vf(LED)/forward_current(LED) = 3.5V/20mA = 175ohm ?


    Link: http://cgi.ebay.com/Lot-of-100-X-3mm-Green-LED-15000-mcd-Free-Resistors_W0QQitemZ280262600089QQihZ018QQcategoryZ66954QQssPageNameZWDVWQQrdZ1QQcmdZViewItem
     
  12. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    I thought that the gate input resistance for the mosfet is big and it's a voltage controlled transistor. Do i still need an additional resistor between the I/O port and the gate? it seems like it's not necessary.
     
  13. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    ok here is the circuit i have, what do you think? :)

    And also, where can i find the spice model for IRLZ14? i looked around the LT yahoo group, i dont think it's there.

    Thanks
     
    • 1.JPG
      1.JPG
      File size:
      83.2 KB
      Views:
      81
    Last edited: Sep 11, 2008
  14. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    They are not "resistor free", they come with resistors at no extra charge!

    You specify the voltage that you will use the LEDs with, and they send appropriate resistance value resistors along with them - to be used 1 resistor per LED. However, if you're going to use multiple LEDs in series, you will need a different resistance value.
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    The gate has nearly infinite resistance, however it DOES have capacitance. Without going through a lot of math at the moment, limit that maximum current to what the uC can source or sink, whichever is less.

    If you're going to use a PIC uC, they can sink or source up to 25mA. Since R=E/I, your Vcc is 5v and your max current is 25mA:
    R= 5/0.025 = 200 Ohms.
     
  16. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    More on those green LEDs:
    At 20mA, Vf is specified to be 3.2 - 3.6v. You should use the lower voltage in your calculations; that's the typical Vf. If you use the higher voltage, you will wind up putting too much current through those LEDs with a lower Vf; which will be most of them.

    In a given batch of LEDs, about 80% will have a Vf in a very narrow range. Then you'll get perhaps 8% that are rather low, and another 8% that are rather high. You'll have a few % that are very low or very high. That's just the way it works out. You can't order them for a specific Vf, only brightness and focus.
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Use 3.2 for the LED's Vf.

    Where are your calculations for the wattage required for the resistors? That's important too.

    I don't happen to have a model for the IRLZ14, nor can I find one.

    However, here is a model for an IRLIZ24, which is a step up in current handling capacity:
    Code ( (Unknown Language)):
    1. .SUBCKT irliz24n 1 2 3
    2. **************************************
    3. *      Model Generated by MODPEX     *
    4. *Copyright(c) Symmetry Design Systems*
    5. *         All Rights Reserved        *
    6. *    UNPUBLISHED LICENSED SOFTWARE   *
    7. *   Contains Proprietary Information *
    8. *      Which is The Property of      *
    9. *     SYMMETRY OR ITS LICENSORS      *
    10. *Commercial Use or Resale Restricted *
    11. *   by Symmetry License Agreement    *
    12. **************************************
    13. * Model generated on Apr 24, 96
    14. * Model format: SPICE3
    15. * Symmetry POWER MOS Model (Version 1.0)
    16. * External Node Designations
    17. * Node 1 -> Drain
    18. * Node 2 -> Gate
    19. * Node 3 -> Source
    20. M1 9 7 8 8 MM L=100u W=100u
    21. * Default values used in MM:
    22. * The voltage-dependent capacitances are
    23. * not included. Other default values are:
    24. *   RS=0 RD=0 LD=0 CBD=0 CBS=0 CGBO=0
    25. .MODEL MM NMOS LEVEL=1 IS=1e-32
    26. +VTO=2.28964 LAMBDA=0.0215953 KP=15.2899
    27. +CGSO=4.31343e-06 CGDO=3.57832e-07
    28. RS 8 3 0.0565541
    29. D1 3 1 MD
    30. .MODEL MD D IS=6.86381e-12 RS=0.0132391 N=1.12746 BV=55
    31. +IBV=0.00025 EG=1 XTI=1 TT=0.0001
    32. +CJO=3.01404e-10 VJ=1.71721 M=0.517385 FC=0.5
    33. RDS 3 1 2.2e+06
    34. RD 9 1 0.0001
    35. RG 2 7 9.08134
    36. D2 4 5 MD1
    37. * Default values used in MD1:
    38. *   RS=0 EG=1.11 XTI=3.0 TT=0
    39. *   BV=infinite IBV=1mA
    40. .MODEL MD1 D IS=1e-32 N=50
    41. +CJO=4.34473e-10 VJ=0.5 M=0.70039 FC=1e-08
    42. D3 0 5 MD2
    43. * Default values used in MD2:
    44. *   EG=1.11 XTI=3.0 TT=0 CJO=0
    45. *   BV=infinite IBV=1mA
    46. .MODEL MD2 D IS=1e-10 N=0.429456 RS=3e-06
    47. RL 5 10 1
    48. FI2 7 9 VFI2 -1
    49. VFI2 4 0 0
    50. EV16 10 0 9 7 1
    51. CAP 11 10 1.16271e-09
    52. FI1 7 9 VFI1 -1
    53. VFI1 11 6 0
    54. RCAP 6 10 1
    55. D4 0 6 MD3
    56. * Default values used in MD3:
    57. *   EG=1.11 XTI=3.0 TT=0 CJO=0
    58. *   RS=0 BV=infinite IBV=1mA
    59. .MODEL MD3 D IS=1e-10 N=0.429456
    60. .ENDS
    61.  
    [eta]
    International Rectifier's models are avaliable on this page:
    http://www.irf.com/product-info/models/
     
    Last edited: Sep 11, 2008
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Even more on the resistors:
    Whatever voltage you tell them that you are running the LEDs with, they will supply you with the correct value of resistance for that voltage for a single LED. However, the resistors will be 1/8W, which is not adequate for running them at 12v.
    12v-3.2 = 8.8V to drop across the resistor at 20mA
    20mA x 8.8v = 176mW. 1/8W is 125mW. But don't forget, for reliability you double the power, to 0.352W. 1/2W would be the wattage of choice.

    But if you're running two in series, that changes things.
    INT((12-1)/3.2) = 3. Why not run three in series? It's certainly do-able.
    Rlimit = (12-3*3.2)/20mA = 2.4/0.02 = 120 Ohms
    P(Rlimit) = 2.4 x 0.02 = 0.048W, double it to 0.096W. You can use 1/10W resistors and get good reliability.
     
  19. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    I am actually going to use a ATMega168 microcontroller, I was looking at the datasheet, but it doesn't tell me anything about the max I/O port current it can handle. But as i recall the ATmega 128 can handle 5mA of current.
     
  20. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    Great! I looks like i am going put three LED in series!

    for the LTspice, how do i simulate LEDs? I right click on part and it poped up a diode properties window, it shows the forward current but it wont allow me to edit anything.
     
    • IMG.jpg
      IMG.jpg
      File size:
      115.7 KB
      Views:
      77
Loading...