0
\$\begingroup\$

I need a current limiter for a project that I am working on. I understand that I can use a device like the LM317 in constant current mode, but how would I add a bypass circuit so that my microcontroller can decide whether or not to limit the current to 250mA? The circuit needs to run with supplies ranging from 10-24V.

Along the same lines, is there a better option than the LM317 for generating a constant current source?

\$\endgroup\$
7
  • \$\begingroup\$ What all do you need? Do you need a voltage source with optional current limit? Or a current source that can be disabled under MCU control? What does "bypass" mean, exactly? \$\endgroup\$ – jonk Jul 19 '20 at 3:08
  • \$\begingroup\$ "bypass" - meaning that I can select with the MCU whether the power supply is current limited or not. \$\endgroup\$ – David Cutting Jul 19 '20 at 4:27
  • \$\begingroup\$ So, you want a voltage regulator with an included current limiter supporting an enable/disable control line? \$\endgroup\$ – jonk Jul 19 '20 at 4:50
  • \$\begingroup\$ I don't need a regulator as part of the circuit. This is being fed from a benchtop power supply that is assumed to be outputting the correct voltage. But otherwise yes. \$\endgroup\$ – David Cutting Jul 19 '20 at 5:27
  • \$\begingroup\$ David, did you ever discuss your MCU rail voltage? I may have missed it, if so. And yes there are better options. \$\endgroup\$ – jonk Jul 22 '20 at 1:39
3
\$\begingroup\$

LM317 Discussion

The LM317 requires at least \$3\:\text{V}\$ between its input and its output in order to function. When acting as a current source, it will need another (up to) \$1.3\:\text{V}\$.

See the datasheet entries indicated here:

enter image description here

So you must plan to lose at least \$4.3\:\text{V}\$ of voltage overhead if you use the LM317. If you are supplying \$10\:\text{V}\$ with the power supply, then unbypassed and when supplying a constant current of \$250\:\text{mA}\$ your compliance voltage range for your load will be \$\le 5.7\:\text{V}\$. (And dissipation in the LM317 and resistor will be from \$1.1\:\text{W}\$ to \$2.5\:\text{W}\$.) With \$24\:\text{V}\$ your compliance voltage range for the load will be \$\le 19.7\:\text{V}\$. (And dissipation in the LM317 and resistor will be from \$1.1\:\text{W}\$ to \$6\:\text{W}\$.)

From the above notes, you can see that you'll need to design something that can dissipate, safely, at least \$6\:\text{W}\$. Given the LM317 arrangement, the resistor will have to dissipate as much as \$325\:\text{mW}\$. A half-watt or better can do that. But the LM317 may have to dissipate as much as \$5.7\:\text{W}\$. And that's not so easy.

To disable the current regulation, you could wrap the LM317 with a relay and activate the relay using your MCU. (If you don't care anything at all about what happens to the load when you switch things around, this would work.)

Another Approach

Given the relatively high and variable voltages you might apply (anything from \$10\:\text{V}\$ to \$24\:\text{V}\$), it would be easier in practice for the MCU to control things from the low side rather than the high side. The price of this approach is that your load won't be referenced to ground. The benefit is the simplicity of the circuit and the smaller number of parts involved. But let's keep it simple for now and regulate things on the low side, knowing in advance that this means your load won't be ground-referenced.

The starting idea I'd like to suggest (and it doesn't include a method to bypass it, there) is described in an answer to this EESE question: How to calculate the tolerance of this constant current circuit?. The starting schematic possibilities, from there, may look like either of the following:

schematic

simulate this circuit – Schematic created using CircuitLab

The MOSFET will require a higher gate voltage but doesn't require any recombination current. If you intend on controlling things at high speed (you've not stated that), then there will be many more considerations that I'm not going to address here. But if this is for "slow speed" usage, then either of these arrangements are roughly equivalent. The differences are then about the drive current required (a worry for when \$Q_1\$ is a BJT but only a momentary worry if it is a MOSFET) and the achievable in-line voltage drop across \$Q_1\$ when the circuit is disabled (we'll get to that, later.)

In either case above, \$R_\text{DRIVE}\$ is needed. For both the BJT and MOSFET cases, it allows \$Q_2\$ to measure and control the load current. For the BJT case, it also supplies the base drive for \$Q_1\$. Either way, it's needed. There are just different considerations in sizing its value.

(If \$Q_1\$ is a MOSFET, you'll need to find one that can operate at low voltages. You've mentioned that you have \$3.3\:\text{V}\$ as the MCU rail voltage. You should expect no better than \$3.2\:\text{V}\$ at the I/O output. Since \$Q_2\$ in this case doesn't need to sink a lot of current, it's possible that its \$V_\text{BE}\lt 620\:\text{mV}\$. But that still implies that you need a MOSFET where a useful \$V_\text{GS}\le 2.4\:\text{V}\$ -- as the resistor must drop a little something when in control.)

Since \$Q_2\$ is responsible for measuring the current, when current control is active, it helps to add a little emitter degeneration:

schematic

simulate this circuit

The added resistor, \$R_\text{DEGEN}\$, makes the circuit better able to function more consistently over a wider range of ambient temperatures. And with an added \$150\:\text{mV}\$ the cost (the added voltage overhead needed) is usually worth it. But that doesn't mean you have to do it. The choice is yours.

Disabling the Circuit

Now, you'll need a way to disable the circuit. This isn't too hard to add:

schematic

simulate this circuit

Here, \$Q_3\$ is operated as a switch (both sides.) If \$Q_3\$ is a BJT then \$R_B\$ is there to limit the base current to something reasonable while at the same time still saturating the BJT. If \$Q_3\$ is a MOSFET then \$R_G\$ could be eliminated but may be desired to stem oscillations (just make it some "small" value like \$220\:\Omega\$, for example.)

(In this new case if you use a MOSFET for \$Q_1\$, there's even more pressure on its \$V_\text{GS}\$ as the voltage drop used for degeneration subtracts still further from the available MCU I/O pin voltage. So, if \$150\:\text{mV}\$ is reserved out, you may have now only \$V_\text{GE}\le 2.2\:\text{V}\$, instead.)

In general, I'd like to see temperatures staying under \$85\,^\circ\text{C}\$. As ambient rarely exceeds \$45\,^\circ\text{C}\$ but can in some cases get a little higher than that, this leaves perhaps an allowance of a \$30\,^\circ\text{C}\$ rise in temperature. This would mean less than \$5\:\frac{^\circ\text{C}}{\text{W}}\$ total for \$Q_1\$. Since a TO-220 package alone will take up about \$2\:\frac{^\circ\text{C}}{\text{W}}\$ going from junction to case, that's puts a lot of pressure on the heat sink you'll need and the interface between the package and the sink. There's only one such heat sink listed as available at Digikey. It's this one. So not a lot of choices. And that one leaves no room for heat sink compound, air gaps between case and sink, etc. So I'd need to relax my tight requirements a bit, I think. But that does show you that things can be a bit tricky with regards to dissipation.

On that account, I cannot speak well to \$Q_3\$'s dissipation since you've said nothing at all about the current that may be passing through it. You'll just have to work that part out for yourself.

\$\endgroup\$
2
  • \$\begingroup\$ Wow, thank you for the write-up. I also should have specified earlier - I only need the current to be limited for about 100ms, then my microcontroller will turn the load (an H-bridge) off if the current demand continues to be >250mA. Do you have a guide to calculate the values for the resistors in this circuit? Lastly- should VDRIVE be sourced from VCC or from my microcontroller? \$\endgroup\$ – David Cutting Jul 25 '20 at 2:18
  • \$\begingroup\$ @DavidCutting Yes, I have a guide for the resistor computations. It's at the "how to calculate" link already mentioned in this answer. Did you miss it? (It doesn't include the emitter degeneration version, but you probably don't care about that anyway.) And yes, it always helps if you write a LOT MORE. More is better. \$\endgroup\$ – jonk Jul 25 '20 at 6:56
1
\$\begingroup\$

It's hard to say whether the LM317 is best for your application without more information.

However, adding a bypass to your current-limiting circuitry shouldn't be a problem. Just put, in parallel with your current-limiting circuitry, a relay of some sort - either mechanical or solid-state - and connect the input pin of the relay to an output pin of your microcontroller through a suitably sized resistor (to avoid high currents through the microcontroller output pin).

If you're feeling a little more adventurous, you may be able to use a MOSFET for the same purpose. Just make sure that the gate-emitter voltage will still be high enough when you have it turned fully on, which generally means your microcontroller voltage will have to be higher than your load voltage; or else, put the current-limiting circuitry and the bypass MOSFET below the load, electrically, so they act as current-sinking devices. Again, whether that's practical is application-dependent.

I'm guessing that a solid-state relay in parallel with your LM317 or other current-limiting device is going to be your best bet.

Let me know what you decide!

\$\endgroup\$
1
  • \$\begingroup\$ What more information do you need to tell me if the LM317 could be supplanted by a better part? \$\endgroup\$ – David Cutting Jul 23 '20 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.