Arduino Forum

Using Arduino => General Electronics => Topic started by: davivid on Apr 19, 2012, 07:07 pm

Title: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 19, 2012, 07:07 pm
So I'm planning to use a LM317 regulator to provide a constant current supply to a high power LED (3.8v 700mA) from a 12v supply, by using an adjustment resistor of 1.8ohms (if my understanding is correct?).

What would be the best way of then turning this LED on and off, I don't require dimming.

thanks.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: CrossRoads on Apr 19, 2012, 07:14 pm
Use a regulator with an enable pin. The LM317 doesn't have one.
Or put a transistor in front of the LM317 to cut off the 12V.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 19, 2012, 07:23 pm

Use a regulator with an enable pin. The LM317 doesn't have one.

Do you know of a similar regulator that does?

Quote

Or put a transistor in front of the LM317 to cut off the 12V.

What common transistor would you recommend?
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: CrossRoads on Apr 19, 2012, 10:20 pm
P-channel MOSFET, or PNP transistor.
Gate/base needs to swing up to 12V, so need an open collector NPN that the Arduino can control.
So something like this, with the LM317 wired up to suit your needs.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 20, 2012, 11:03 pm
Thanks for the example! I made up a quick circuit before I saw your reply which seems to function correctly - can you please tell me what issues it has, that should be addressed?
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: CrossRoads on Apr 20, 2012, 11:24 pm
That would work I guess, if that's the wiring for the LM317 as a constant current source.
What sets the LM317 for the votlage you started asking about?

Put a resistor, 180 ohm or so, between the arduino pin and the transistor base, to limit the current from the arduino pin.
(5V - 0.7V)/.035 = resistor value, usig 0.7v as Vbe, adjust that for the BD237's actual Vbe.


Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 21, 2012, 12:04 am
Yeah as I understand it, I just want the LM317 as a constant current source to limit the LED at 700mA and I think that's how to wire it.

1.25 (the constant reference voltage of the LM317) divided by 0.700 (the LEDs power consumption) = 1.785. Therefore 1.8ohms sets the LM317 at 700mA, independent of the supply voltage, and I hope that's enough to protect the LED.

Thanks for the tip to limit the arduino current!

Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 21, 2012, 02:55 am
Have a look at the attached schematic.  This uses just a cheap 2N3094 and is overall a better way to do this.  The caps are there for stability and transient response.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 21, 2012, 10:58 am
Is this better because your not running the high the current through the transistor, and therefore can use a cheaper cooler running component? I am interested in knowing the reasons for the design. Unfortunately I am unable to test until Monday, when I can get hold of the additional parts.

Also I am confused about which part sets the the LM317 - I thought it was a resistor 1.8, between ADJ and OUT, but here its quite different!

thanks.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: Erni on Apr 21, 2012, 12:47 pm
davivid I think Your wiring is a bit wrong, it should be like this.

Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: MarkT on Apr 21, 2012, 01:02 pm
And don't forget the heatsinking for the LM317, it'll draw about 5.5W and the 1.8 ohm resistor will dissipate 0.9W remember.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 21, 2012, 02:16 pm

davivid I think Your wiring is a bit wrong, it should be like this.

Thanks Erni, I have now amended my circuit.



Cheers MarkT, Yeah I should really do that. I have however decided this project will run of 7.5v, and so far the LM317 doesn't overheat / start shutting down like it did before (still gets v.hot tho).
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 21, 2012, 03:52 pm

Is this better because your not running the high the current through the transistor, and therefore can use a cheaper cooler running component?  


Yes, that is the main reason from an endpoint perspective.  In fact, a 2N3904 is even overkill with respect to specifications, but it is probably the cheapest transistor in the world.

Quote
I am interested in knowing the reasons for the design.

Using the adjust pin is how the design engineers intended the device to be controlled.  The device already has the ability to do the 'heavy lifting' by design, so why add a big, hot transistor to it to get the job done.

Quote
Unfortunately I am unable to test until Monday, when I can get hold of the additional parts.


From a total parts perspective, it really is only one additional resistor (the 1K).  The caps should be there in your circuit as well.  (well, in the corrected one suggested by Erni).

Quote
Also I am confused about which part sets the the LM317 - I thought it was a resistor 1.8, between ADJ and OUT, but here its quite different!


Not really.  It is still the 1.8 ohm resistor that sets 96% of the 1.25V control voltage.  Because the adjust input has a very high impedance, the 1K resistor (which is there to limit current through the transistor) has negligible effect.  The current through the adjust pin is only about 50uA.  So, doing the math, it introduces a -4% error in output current which is well below the tolerance of the rest of the circuit.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 23, 2012, 05:36 pm
Thanks for your detailed response BillO.

I have created the circuit and its working great. However setting the Control line LOW, turns the LED on? I expected the opposite behaviour, is this correct?

Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 23, 2012, 05:51 pm
Yes, that's the correct behavior.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 23, 2012, 09:33 pm
another thing I've noticed with this new circuit is its drawing slightly more current 0.72A as opposed to 0.69A. Do I need to adjust it? or does the new circuit draw more current to operate. This project calls for high reliability, so I really cant strain/damage the LED's (Typ IF=700mA) .
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 23, 2012, 10:08 pm
That's the 4% I was talking about and is the expected amount.  You can increase the 1.8 ohm resistor to 2.0 and increase the 1K to 2.7K which will drop current back down to about 693ma, or just reduce the 1K to 270 which should put it right at around 703ma.

Where the 1.8 ohm is RL and the 1K is RAdj the formula becomes:

IOut = (1.25 + (RAdj x IAdj))/RL

IAdj is usually 50 uA

Is 700ma the nominal current or the absolute maximum?
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 23, 2012, 10:55 pm
Oh right sorry, I didn't realise that's what you meant.

The only specs I have for the LED is: Forward Voltage = 3.8 and Typ IF=700mA, which I assume means Typical? What does one do in these situations? run it at 700mA, or be cautious and drop it a bit lower?

Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 24, 2012, 01:15 am
You could run it at 700 without worrying.  Do you have a heat sink for it or does it come with a heat sink?  It will need to be kept cool somehow.  LEDs hate to get hot.  They should have a temperature specification too.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 24, 2012, 12:36 pm
Great. I reduced the 1K to 270, and now it reads 0.7A.

I have mounted the LED on a heat sink, which keeps it really cool. I now just need to upgrade the 1.8 ohm resistor since its only rated for 0.6w.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 25, 2012, 04:43 am
Good.  Sounds like you've got the hang of this.
Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: davivid on Apr 26, 2012, 01:19 pm

And don't forget the heatsinking for the LM317, it'll draw about 5.5W and the 1.8 ohm resistor will dissipate 0.9W remember.



Does that mean the LM317 heatsink should have a Thermal Resistance of 6.6 °C/W?

Thermal Resistance = (60 - AmbientTemp) / Power
Thermal Resistance = (60 - 20) / 5.5
Thermal Resistance = 6.6

Those things are huge!

Title: Re: how to switch a LM317 voltage regulator / LED on and off?
Post by: BillO on Apr 26, 2012, 06:22 pm
That's a bit of overkill.

With a supply voltage of 7.5 @ .7 amps, the LM317 will be dissipating:
WD = 0.7 x (7.5 - 3.8 - 1.25), or about 1.7 watts.  Let's call it 2 to be safe

They recommend a maximum TJ of 125°C for an LM317, but let's keep it cool and on the safe side at 85°C to factor in junction to case RT.  And we'll put ambient at 25°C, again to be safe.  Then we have:

RT= (85 - 25) / 2, or about 30°C/W should do nicely.