• Source: Likely a boost converter IC (30v)
  • Load: max 4mA (with 0.1mA accuracy), resistance varies (~1k-100k ohms).
  • Need an MCU to control the constant-current output, ideally it can also monitor load impedance to deter short circuits.
  • Similar to this post: High voltage adjustable constant current source controlled by MCU but lower voltage requirement.

More Info:

I'm trying to build a high-power current-controlled source that can be adjusted using a microcontroller (like an ESP32). I've explored the LM317 as a potential option (by tying the adj pin to Vout), but it didn't get the results I'm looking for.

The advice I've gotten so far is as follows:

  • Build a high-voltage current pump (outside my scope of knowledge) or
  • Measure the output current (from a boost converter) using a very small shunt & current sense amp, and then read it into the micro to adjust the output voltage/maintain the correct current.

Can someone explain common solutions for current-controlled sources and how I might control the output using an MCU? I'm also a bit confused if I should also control the boost converter to ensure the constant-current source has enough voltage.

  • 1
    \$\begingroup\$ If you can suffer low side current sensing and control then this would be very straightforward with a microcontroller. Adding some more requirements such as bandwidth, tolerance to overcurrent and load characteristics would improve the quality of the answers you’ll receive. \$\endgroup\$
    – Bryan
    Commented Nov 22, 2022 at 17:59
  • \$\begingroup\$ Instead of thinking current-controlled source, think voltage-supply that monitors current instead of voltage and tries to keep that constant. Or a voltage source that always operates in current-limiting mode. The hardware is quite similar if not identical. Just the control is different. \$\endgroup\$
    – DKNguyen
    Commented Nov 22, 2022 at 18:22
  • \$\begingroup\$ @DKNguyen Would that align with the second solution I mentioned? It seems like a good idea just trying to understand if it's actually effective compared to a true current-controlled source? \$\endgroup\$
    – Dionysus
    Commented Nov 22, 2022 at 18:25
  • \$\begingroup\$ @JakeAdler Technically yes, but it would be faster to just have the MCU control the switching directly than to try and use the adjust pin on a boost controller. The adjust pin on a boost controller will only have limited adjustment range which means the available output voltages will be smaller. There might be control loop issues trying to mix the two together. \$\endgroup\$
    – DKNguyen
    Commented Nov 22, 2022 at 18:27
  • \$\begingroup\$ @DKNguyen Can you elaborate on what the MCU is switching other then the adjust pin? (still a noobie) \$\endgroup\$
    – Dionysus
    Commented Nov 22, 2022 at 18:32

1 Answer 1


For that voltage and current you should be able to do it with an opamp and a couple of transistors like this: enter image description here enter image description here

The opamp senses the voltage across R2 and compares it to the input voltage V1, then drives the transistors, a Sziklai pair, so that the voltage across R2 is the same as the input voltage. From Ohm's law the current will be the voltage divided by the resistance and Q1's collector current will be nearly the same (plus Q2's base current which should be negligible).

You could use a micro with an analog output to supply the input voltage, I've selected R2 to give 0.1 mA per 25 mV with 1 V giving 4 mA.

I used 48 V for the supply, as that's generally considered the limit of what's considered 'low voltage'. You could increase this if you need more but then you get into 'high voltage' and you need to worry more about safety.

The opamp used is going to need to be able to work with a single supply and rail to rail, LT1006A works in simulation.

  • \$\begingroup\$ So I'd attach the micro to V1, the boost to V2 - just confused where the output would be. \$\endgroup\$
    – Dionysus
    Commented Nov 22, 2022 at 18:44
  • 1
    \$\begingroup\$ @JakeAdler See R1 labeled 'load'? That's where your load goes, between the supply voltage and the emitter of Q1. This is a low side sensing circuit, meaning it senses the current in what we normally consider the ground side of the load. If that's not possible, for instance if you have a load that's grounded, you would need to use high side sensing which I believe is a little more difficult, but the idea is the same, sense the voltage across a fixed resistor and adjust the drive to keep it at a certain value. \$\endgroup\$
    – GodJihyo
    Commented Nov 22, 2022 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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