Maker Pro
Maker Pro

lm317 sub?

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
I'm looking for a low cost constant current LED driver. An LM317 has too much voltage drop for my applications, but otherwise rather nice.

Any suggestions?
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
Is there any special requirements in choosing q1? Looks like q2 just needs to handle the desired current.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
No, no special requirements. You're right.
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
See any issues with 24v and multiple LEDs in series? Probably use enough to get about 21v of vF, then this to set current.
Is this somewhat acurate over a wide range of currents? I'm thinking 50 to 500mA.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
If Q2 is dropping significant voltage, you should calculate the power dissipated in Q2 to see whether a heatsink will be needed. In your case you are keeping most of the voltage dropped across the LEDs, with only 2~3V across the transistor, which is good. But at 500 mA, 3V across the transistor is 1.5W dissipation, which does require a small heatsink (for a TO-126 or TO-220 package).

Secondy you need to make sure that there's enough headroom for when the LED forward voltages are higher than nominal, and when you run them at maximum current. Ideally, if the data sheet tells you the maximum forward voltage at the highest current you'll be running them at, multiply that by the number of LEDs, and subtract that from the minimum power supply voltage, to see the worst case minimum voltage across the transistor. If it's negative, or less than about +1V, there COULD be a problem if you happened to get all of those worst cases at the same time. In that case, reduce the number of LEDs in the string as needed.

Then you can recalculate the maximum dissipation in the transistor when the LEDs are at their minimum forward voltages and the power supply is at maximum voltage, with maximum current flowing, and resize the heatsink appropriately. These are the steps a conservative and responsible engineer would take.

That circuit is reasonably accurate but it is not easy to adjust the current, for two reasons. First, current is proportional to the reciprocal of the emitter resistor, so using a linear potentiometer or rheostat in that position does not give a linear relationship between position and current, and second, the output current flows through the emitter resistor, so you may need a pot/rheostat rated for half a watt or more continuous dissipation. Also you can't control the current from another circuit - a microcontroller for example.

These problems are avoided if you use an op-amp to drive the pass device. This is presented quite nicely at http://modulatedlight.org/optical_comms/LED_linear_modulator.html. His diagram shows only one LED but of course you can add more in series. You can use a MOSFET, or a Darlington transistor, as the pass element.
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
Interesting! I don't need external control, but I'd like to set at 500mA and have that be 500mA regardless of the vF of the LEDs to allow for changes as they heat up and change vF. If I set R2, will the current change as vF shifts?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
If I set R2, will the current change as vF shifts?

No. Or not a lot. The current will decrease if the Vf of the LED(s) approaches the supply voltage. Otherwise the circuit will hold the current constant to maybe a couple of percent or better.
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
So to get these to turn on with .65v on the base, it's 0.65v / R2. If I wanted 100ma, then 6.5 ohms. This seems like it would be the voltage the feedback will always try to keep across R2.

The problem is as I want higher currents, like 500mA, the math says I need a 1.3hm resistor to do this.
Correct? Workable?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
the math says I need a 1.3hm resistor to do this

Yep, for the 2 transistor constant current sink, 1.3 ohms is correct. (For an LM317, the voltage is 1.25V, so you would need a 2.5 ohm resistor.)

Remember to calculate the dissipated heat (I * I * R) and get a resistor rated at about twice this or greater.

Note that R1 needs to be capable of delivering enough base current to Q2. If the laser diode has nominally 3.3V across it, the transistor has a minimum gain of 80, and you want 500mA, R1 must be 3.3 * 80 / 0.5 = 528 ohms (use 470 ohms).
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Yes, and yes. You can construct the current sense resistor from a fixed resistor of 1.5Ω (to take most of the current) and a 20Ω trimpot (using the wiper and one end) in parallel, for fine adjustment. Alternatively, you can use the 1.5Ω fixed resistor, connect a 100Ω trimpot aross it, and feed the current sense transistor's base from the wiper of the trimpot, like this:

270646.001.GIF

VR1 is a 100Ω trimpot (the value isn't critical). Set it fully counter-clockwise initially and adjust it for the exact current you want. This circuit isn't exact, and variations in supply voltage and LED forward voltage will affect the current somewhat, but not much.

At 500 mA collector current, Q2 will need significant base current. The base current needed by Q2 is equal to the LED current divided by Q2's current gain, but Q2's current gain varies with its collector current! It gets lower as the collector current increases. I've assumed that Q2 has a current gain of at least 20 at 500 mA collector current, so it needs 25 mA base current. We also want a few mA flowing into Q1's collector, so let's say the total current available from RB needs to be 28 mA. Q2's base will sit at around 1.7V, leaving 22.3V across RB, so from Ohm's Law, RB should be about 22.3 / 0.028 which is 796Ω. To guarantee at least that much current, we use the next lower preferred value, which is 680Ω.

For best accuracy, arrange your circuit putting the main current path first. That is the path through the collector and emitter of Q2 and the current sense resistor RS. Then tack the trimpot, the other transistor and the base current supply resistor onto that circuit.

Edit: Other comments following on from Steve's post:

Re the current gain of a BD135/137/139. Fairchild, ON Semiconductor and STMicroelectronics all state a minimum current gain at a collector current of 500 mA, and it is 25. I assumed 20 in my calculations above. But that figure is with Q2 not very strongly saturated. The upshot is that you should use something a lot lower - 330Ω perhaps. But that would dissipate 2W and get pretty hot.

The best solution is to replace Q2 with an N-channel MOSFET, which requires almost no gate current and will saturate very nicely, with a low forward voltage. RB (which should then be called RG) can be increased to around 4k7 to give about 4 mA collector current for Q1. You should add a zener of around 15V (use a 1/2W one) with its cathode to Q2's gate (also Q1's collector) and its anode to 0V, to protect the MOSFET gate from overvoltage if the load becomes disconnected.

You could also use a Darlington transistor for Q2 but this will increase the dropout voltage significantly.

Adding the trimpot to provide easy adjustment of the current increases the dropout voltage slightly because RS is higher than the "perfect" RS. Assuming RS is exactly 1.5Ω it will drop 0.75V at 500 mA. Q2's dropout voltage will be at least 0.25V for a transistor, and somewhat less for a MOSFET, so the total dropout voltage should be around 1V.

Here's the MOSFET version I described.

270646.002.GIF

There are several smaller MOSFETs that would be suitable for Q2 but I only suggested TO-220 devices because they're easier to heatsink.
 
Last edited:

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
This first one seems ok with a 10k base resistor, but I never really calculated what it should be. Whats the downside of it being too high a base current?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
A 10k resistor gives a LOWER base current than a 680Ω resistor. Ohm's Law says I = V / R, so if voltage is constant, I (current) is proportional to 1 / R, the reciprocal of resistance. Higher resistance means lower current.

A 10k resistor can only supply about 2 mA of base current to Q2. Multiply this by the worst case (lowest) Q2 current gain, which is 25, and Q2 can only sink 50 mA through its collector. So even if you reduce the emitter resistor to try to get 500 mA flowing, it won't. Q2 will not conduct hard enough, and it may also overheat.

If you want to be able to supply 500 mA, you need to reduce the base resistor a lot. For example, 330Ω will be able to supply about 67 mA of base current. Multiply that by the worst case current gain, you get 1.7A maximum collector current. That is not the current that the circuit will operate at; the operating current will be set by the emitter resistor. But the extra current is needed to ensure Q2 saturates properly. That would probably be OK, but it wastes about 67 mA of current, which you can avoid completely if you use a MOSFET for Q2 instead of a bipolar transistor.

If you don't care about wasting 67 mA, either option is fine.
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
I'm just getting back to this.

Used a 1k base res to get enough saturation.

In my test version the current seems to vary a lot as the circuit warms up. Once warm, it seems to stabilize. At that point I can change the LED vF and the feedback seems to hold the current pretty constant.

Does it make sense that the current will shift as the transistors warm up? It's not as stable or prediucatble as I'd like.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I would be increasing Rg since mosfets don't have a saturation current.

This design is not guaranteed to be particularly stable, and making it variable doesn't help.

What variance in LED current do you see from cold to warm?
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
I would be increasing Rg since mosfets don't have a saturation current.

This design is not guaranteed to be particularly stable, and making it variable doesn't help.
What variance in LED current do you see from cold to warm?

I built the BJT version. Maybe 10% current variation from cold to stable.

It looks like the Vbe on Q1 varies with temperature, which causes that change.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I built the BJT version. Maybe 10% current variation from cold to stable

Yeah, that's similar to what I'd expect.

It looks like the Vbe on Q1 varies with temperature, which causes that change.

It certainly does. You may find that if you have Q1 and Q2 in close thermal contact that some of the variation will be eliminated.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
1k is too high for reliable saturation of the transistor at 500 mA collector load.

It depends on what you mean by "a lot", but yes, the current will vary as the circuit warms up. If you want to avoid that, you use an op-amp in the control loop, and use an emitter resistor with low temperature coefficient, since it will warm up too.

Here's a diagram of the "proper" way to reduce current variation with temperature. An op-amp is used in the feedback loop, so the output transistor's base-emitter voltage, which varies with temperature, is no longer important.

270646.003.GIF

I've switched back to using a BD139 transistor for the output device since you seem to want to stick with that. Q1 is needed because the op-amp can't source much current itself. RC and RB reduce the gain of the external circuit for better stability. U1 provides a fixed reference voltage (nominally 2.495V) and VR1 provides an adjustable amount of that voltage to the op-amp's non-inverting input on pin 3.

The op-amp will adjust its output (which controls the transistors) in order to keep the voltage on its inverting input (pin 2) the same as the voltage on its non-inverting input. 500 mA output current corresponds to 0.75V across RS, so if you adjust VR1 for 0.75V on pin 3 of the LM358, you will get 0.75V across RS which corresponds to the 500 mA you want.

Temperature will affect U1's voltage, and RS's resistance, but these effects will be a lot less significant than the variation in VBE that was causing problems with the simpler circuit. RS should probably have a low temperature coefficient.

The choice of 0.75V for the shunt resistor voltage used to be determined by the base-emitter voltage of the feedback transistor, but with this circuit, it isn't, and you could use any voltage. But 0.75V is a good choice. If you make the voltage too low, variations in the input offset voltage of the op-amp will have a bigger effect; if you make the voltage too high, the dropout voltage of the current sink could become too high.
 

docb

Feb 11, 2010
131
Joined
Feb 11, 2010
Messages
131
While I like this, the BOM because is a bit too high. I think I can accept that temp variation.

RB is now 200r, but I see enough current that it needs to be a 2512 now. About 0.5w, with 9v across it.
For Q1 I've used a SMT MMBD2222. Do others have less variation with temperature?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
If you can keep both transistors at the same temperature you will see less variation. SMT will make that harder
 
Top