Constant current PWM dimming with a mosfet

Thread Starter

matthehat

Joined May 12, 2015
2
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?
 

cmartinez

Joined Jan 17, 2007
8,252
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?
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.
 

crutschow

Joined Mar 14, 2008
34,420
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.
 

cmartinez

Joined Jan 17, 2007
8,252
Use a PWM frequency of at least a 100Hz.
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?
 

ian field

Joined Oct 27, 2012
6,536
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?
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.
 

crutschow

Joined Mar 14, 2008
34,420
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?
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.
 

MikeML

Joined Oct 2, 2009
5,444
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:

Thread Starter

matthehat

Joined May 12, 2015
2
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!
 

MikeML

Joined Oct 2, 2009
5,444
... I wasn't sure if the mosfets would somehow interfere with the current regulation...
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.
 
Top