arduino and LM334 (drive high power LEDs)

Hi all,

There is a prior thread about driving high power LEDs but I thought I would post separately since I am specifically talking about using the LM334. Essentially I want to use the an Arduino PWM pin to control the brightness of an LED; so this means making it control the current passing through the LM334. This is the circuit I developed.

As you can see, the LM334 controls the current out of the base of the 2907 which is then multiplied up by the transistor to drive the LED (I have a common anode, so the "common cathode LED" shown here is just a short). This is pretty standard from the data sheet. Now on the right side, I have the logic to control the LM334's current. As you may know, the LM334 puts 68mV across that bottom right resistor , senses the resulting current, and uses that value to set the current across the other leads in the chip.

So I added a voltage divider so that when the PWM pin is high the LM334's center pin is driven above the 68mV so no current can flow out of this LM334. This shuts off the LED. And of course when the PWM is low current does flow...

All of this works. However, I do not get a clean brightness increase. If I do an analogWrite() in a loop from 0-255, then it works great until around 90. At that point the LED brightens suddenly and then continues dimming. This pulsing occurs maybe 5-10 times from 90 to 255.

Has anyone else seen similar behaviour with the PWM?


Well, in my simple mind... there are probably many ways that PWM is not just like a varying voltage source. Maybe a capacitor at the arduino pin to ground might help tame the PWM signal. That may help...

It seems that you might want to try to use maybe a 10K pot wired across 5V source and Ground (removing the arduino from the circuit!) and use the wiper to feed the voltage where the PWM was being input from the arduino. This way you get to see how your circuit behaves with a REAL varying voltage instead of the PSEUDO voltage value PWM is trying to create.

If PWM still doesn't behave... you could always use a device like an AD5220 (controlled by arduino). It is an Increment/Decrement Digital Potentiometer.

I tried the pot and that works fine.

I was thinking of hooking up a capacitor to smoother the PWM also. But I'm not sure how to do it. Would I need a diode to protect the arduino pin from being driven by the cap (when the pin is low, or does that not matter)? And also I would need resistor-cap in series, right, not just a cap?

Thanks for your help!

Yes, you would want something like an an R/C Snubber. 100ohm in series with load, .01uF accross the load, but this is not really an ideal way to solve the problem.

To me personally, PWM has limited usefulness. For some things, it works great... other situations... not so much. Using a DAC or Digital Pot seems like a better way to me.

Analog dimming is not generally considered the best way to control LEDs, because then you have to deal with the brightness curve of the LED in relation to current, and you also waste a lot of power as heat. PWM gives you much more repeatable results and uses less power while dimming. It would be worthwhile to do analog dimming only in cases where you can't have the LED blinking, such as video applications.

macegr: Is this true for high current 350ma applications as well? I was a bit worried about stuff like RF with that kind of power. But anyway, I was actually trying to use PWM to blink the LEDs but it doesn't seem to work to drive the LM334 using PWM, as I described. Do you have any other ideas on how to change the circuit but preserve the constant current feature? I would rather not put another power transistor inline with the LED... not sure why it just seems to me that the power path should be as simple as possible.

I did try putting a NPN transistor between the base of the 2907 and the LM334 and connect the base of that to the Arduino's PWM line... and got a lot of weird effects. Other completely unrelated LEDs light up. The LED lights brighter when I am touching the base than when the Arduino drives it to +5v...

I also just tried putting the NPN transistor between the LM334 and ground (below the current select resistor path as well). That seems to basically work. However digitalWrite(pin,1) is brighter than analogWrite(pin,255)... so I still think that the PWM code might need a to be looked at.

And it would be neat to use a simple passive component and let the LM334 do the whole job.

An NPN transistor would affect the circuit too much, mess up the current control. Too much voltage drop. You could probably switch power to the LEDs with a MOSFET and not affect things too badly.

Current regulation with high power LEDs is a pretty tricky subject. One approach is to use switching regulators for best efficiency, but what with external diodes and coils can get expensive. Another approach is to use a linear regulator and a supply voltage just high enough to power the LED + dropout of the regulator.

The second approach is a lot simpler. The STCS05 chip is a good example of a linear regulator, with a PWM switch input and everything. The fact that it requires a precision current sense resistor kind of sucks, but it could be worse, and you won't need an external transistor.