Constant current PWM dimming with a mosfet

Discussion in 'General Electronics Chat' started by matthehat, May 12, 2015.

  1. matthehat

    Thread Starter New Member

    May 12, 2015
    2
    0
    Hi there

    I've got some high powered LEDs that I want to control with a microcontroller and I'm trying to do it on the cheap. Power consumption isn't important but the LEDs need to be driven at about 300mA. I know I can build a relatively stable CC supply using an LM317, but how can I add PWM dimming to it? Would an N channel mosfet be enough?
     
  2. Kermit2

    AAC Fanatic!

    Feb 5, 2010
    3,795
    951
    you could just make the feedback resistance of your 317 variable and reduce current that way.
     
    cmartinez likes this.
  3. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,574
    2,545
    Yes it would be, assuming that you choose the right mosfet. But keep in mind that leds are current driven devices. So a current limiting/controlling circuit is advisable, and not just a simple resistor.
     
  4. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    If efficiency is not critical then just add a resistor in series with the LED to give 300mA with the supply voltage you have.
    The resistor must be rated for the power it will dissipate from I^2R loss.

    To this add a logic-level type MOSFET with the source to ground and the drain in series with the LED/resistor.
    Control the gate of the MOSFET with a PWM signal from your micro.
    Use a PWM frequency of at least a 100Hz.
    100% duty-cycle will give full brightness and 0% will be off.
     
  5. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,574
    2,545
    That's very interesting advice.... I assume the 100 Hz low limit is to prevent the appearance of "flicker" to the human eye?
    Also, what would then be the upper limit for frequency? Would it depend on the LED's capacitance? would it affect its efficiency?
     
  6. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    Maybe the old textbook dual-comparator PWM. One is wired as an oscillator and produces a sawtoot, while the other compares that sawtoot to a reference voltage. Normally the Vref would simply be a pot across the rails so you can vary the M/S ratio - but you could just feed Vref from a DAC in the micro.

    You can sense the current with a low R from the LEDs to GND and feed that level into an ADC.

    You'd probably want a LPF between the DAC and the Vref point on the first comparator - I think the delay as values are processed would cause the brightnes to swing up and down otherwise.
     
  7. crutschow

    Expert

    Mar 14, 2008
    13,052
    3,244
    The main reason to keep the frequency as low as possible is that there is less switching loss.
    It should be apparent that the more times you have to switch the current the higher the total loss.
    The upper limit would likely be due to switching and other parasitic losses, long before you reach any LED limitations at those currents.
     
    cmartinez likes this.
  8. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Here is a constant-current hi-power LED driver that can be PWMed. The NFet must have a low Vth. A TO220 package will handle the dissipation. R1 sets the max current. With a 5V supply, one high-power LED with a Vf of ~3.6V can be driven. The average current through the LED is proportional to the PWM duty-cycle.
    65.gif
     
    Last edited: May 13, 2015
    cmartinez likes this.
  9. matthehat

    Thread Starter New Member

    May 12, 2015
    2
    0
    Thanks for all the replies. I've ordered some logic level mosfets so hopefully when they arrive I'll be able to knock something together. I wasn't sure if the mosfets would somehow interfere with the current regulation.

    Cheers!
     
  10. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    In the circuit I posted, the NFET is key to the current regulation. The NFET is part of an active current regulator... It is that it can be turned on-off in step with the pwm.
     
Loading...