Dimming 1w leds with transistor and walwart issues

Hello Everyone,

I am trying to dim a 1w led (3v 350ma max) with a pwm signal from the arduino. I have a simple circuit using a 1k resistor on the base pin of a 2n2222 NPN transistor with the emitter connected to ground on the arduino and the collector to the negative terminal of the led. The positive led terminal than goes to 5v on arduino.

This circuit works perfectly fine and I am able to get it to dim correctly, however, I need to run the leds from a separate 5v power supply (walwart) while still controlling the base pin with the arduino. For some reason every time I replace the ground and 5v from the arduino with the ones from the walwart, the led will not light while using the arduino pin to control the base. If I connect the base to the positive terminal of the walwart the led will turn on.

I do not have a great understanding of circuit design as of yet and feel like I am missing something small so any help would be greatly appreciated!

It's essential to connect together the ground from the Arduino and the wall wart.

Voltages are only relative to their "ground". If the grounds aren't the same then the +5V in each part of the circuit might not be the same.

Is this 3v LED ok on 5v ?

Fungus,

Thank you very much it is working perfectly now!
I'm glad I learned that, it makes a lot of sense!

I am mainly testing this with two double A batteries as its closer to 3v, but at first I was using the 5v walwart with a 10ohm resistor and it seemed to be okay for the short tests I was doing. I will be buying a 3 volt walwart to run them as together they will take upwards of 1.4 amps.

This is ultimately for moon light control for a reef tank. I was planning on having four 1w leds wired in parallel each individually dimmable to simulate to lunar phases and cloud cover.
I am also wondering, would it be better to run the leds off of a 3volt walwart or to get a 3.3volt voltage regulator to convert a 5v supply? I am guessing the voltage regulator would be a lot more stable, yes?

I appreciate your help, I still have a lot of learning to do on the hardware side!

OK, next thing to learn is that LEDs don't work well if you try to control their voltage, they work much better if you control their current. If your LEDs need 350mA then you need a special "constant current" circuit that allows that many amps to pass.

The reason is that LEDs don't have a constant resistance, their resistance varies with voltage. Even tiny errors in voltage can lead to big errors in current, enough to damage the LED. Every LED is slightly different and needs a slightly different voltage so the only way to avoid those errors is to control the current.

You can get a special "led driver" for this or look for examples in these forums.

fungus,

I did know this already and have a constant current driver that will supply voltage to one or all of the leds, that was actually the first ting I tried to dim them with before the 5v source. Since it didn't work as I did not provide the common ground I just assumed that the constant current driver just pumped out more current to compensate for the dimming and keep the led at its max.

I just hook up the circuit with the constant current driver and it is all working as it should, thank you very much!
If you know of place off the top of your head, is their a website that provides basic electrical knowledge and covers a wide basis of topics?

Nick D.

I noticed that when I keep the led at 350mA, which I tested with a meter, the 2n2222 transistor gets very hot very quickly. So since this is too much current for the npn's can I use a TIP120 Power Darlington Transistor from adafruit for the job?

Try a smaller resistor on the transistor base, maybe 330 or 220 ohms. 1K might be too high to fully open the transistor.

with a 220 ohm it still get too hot to touch very quickly.

the 2n2222 transistor gets very hot very quickly.

That's the issue with a small device like that.

So since this is too much current for the npn's can I use a TIP120 Power Darlington Transistor from adafruit for the job?

It will help with cooling but not with power dissipation: the darlington will have considerably higher voltage drop than the 2n2222.

with a 220 ohm it still get too hot to touch very quickly.

That's fundamentally an issue with such a linear solution.

I would go with a larger npn (not a darlington), or a mosfet (irf510 for example), with a heatsink (or to put it in the tank).

nkd5025:
with a 220 ohm it still get too hot to touch very quickly.

It might be OK...but to be sure you should probably use a bigger transistor with a heatsink.

What constant current circuit are you using? Maybe the PWM signal could connect to that and drive it directly.

dhenry:
... with a heatsink (or to put it in the tank).

Water cooling!

PS: Water isn't anywhere near as conductive as most people think...

I don't know what the linking rules are here so hopefully this is alright.
http://www.rapidled.com/moonlight-driver-350ma/

Although it has a varying voltage for 1 to 4 leds. So all four of my leds would be dimmed at the same time if the pwm signal connected to it.

so a power mosfet such as the IRF510 will work fine without heating up too much?

I've used the 3W and 10W version of these guys forever (direct arduino PWM drive)... ebay #380519501055

All you need then is say a regular 19v laptop power supply for about $5 and you're golden.
Personally, I use a butchered computer power supply and run strings of 3 at a time

All you need then is say a regular 19v laptop power supply for about $5 and you're golden.

Agreed. Never understood why anyone would pay for a sub-par power supply.

Best scenario of using a "bench" computer power supply is that I can power my leds and arduino straight off the 12v rail of the power supply.

  1. Switch-mode constant current supplies such as the one you linked to are not intended to be interrupted with PWM. It may work, but you may end up putting large current pulses through the LED and shortening its life and/or the life of the constant current supply. Look for a supply with a separate PWM input, such as http://www.led-supplies.com/led-drivers-LED-power-supplies/1-10V-PWM-Dimmable-Constant-Current-LED-Drivers.html or http://www.ebay.co.uk/itm/1W-350mA-Constant-Current-LED-Drive-PWM-Dimmer-DC-DC-Buck-Power-Supply-Board-/140895009844?pt=US_Lighting_Parts_and_Accessories&hash=item20cdff3c34.

  2. The reason why your 2N2222 gets hot is that it has a high saturation voltage (up to 1.6V @ 500mA from the datasheet). You need a transistor that has high current gain and low saturation voltage at 350mA. A ZTX851 would be ideal. Even a BC337 would be run cooler than the 2N2222. You can certainly use a mosfet instead, but you do, look for one with logic level gate drive, not the IRF510 (which is designed for 10V gate drive).

Thank you very much for the explanation!

So the switch-mode constant current drivers shouldn't be pwm'ed?

So are you saying the ZTX851 would be better to use than a logic level mosfet but still not better than getting a constant current source with a dedicated pwm pin?

Can I build this circuit instead of buying a different pwm constand current driver?

a) Yes.
b) Yes.
c) Yes.

Note: A switch-mode driver will be more efficient in terms of power use than the MOSFET circuit - something to think about if it's running 24/7 (the MOSFET circuit turns the excess volts into heat!)

a) yes
b) both the ZTX851 and the logic level mosfet are good solutions at this sort of current
c) yes. Use the lower of the two schematics. Calculate how much power the mosfet will dissipate, which is (V_supply - V_leds - 0.65) * I_leds, and provide the mosfet with a sufficient heatsink.