# Easiest way of creating a constant current source controlled by a micro

I'm trying to figure out the easiest way of constructing a digitally controllable current source. The operation conditions are: 0 - 12 V (regulated by a voltage regulator) at 0 - 1 A. A microcontroller should be able to set the maximum current which is between 0A and 1A.

Are there any common and widely available linear ICs which will do the job?

I've some LM317Ts and found this schematic. But there is a potentiometer which needs to be replaced by a digital controllable circuit.

• Can you create a voltage? then an opamp and a mosfet and a shunt will do it. – PlasmaHH Oct 7 '16 at 14:52
• Have a look at this: electronics.stackexchange.com/questions/28546/… in the first answer there's an example on how to build a current source which uses a voltage as a reference. You can make this voltage from a DA converter controlled by the micro or you could use the micro to make a PWM signal, filter that (poor man's DAC) and use that as the voltage reference. – Bimpelrekkie Oct 7 '16 at 14:52
• Any reason why you can't employ a digital potentiometer in a circuit? (e.g. sparkfun.com/products/10613) – JIm Dearden Oct 7 '16 at 15:09
• See this question - & my answer there has some useful links. – Russell McMahon Oct 7 '16 at 15:16
• A linear voltage-controlled current source is easiest if the load does not need to be grounded and if there is substantial headroom between the compliance of the current source and the supply voltage. For example, 10V maximum output voltage compliance at 0-1A out with a 12V supply, with the load connected to +12V and a transistor. If you need the load grounded, then it takes a few more parts to shift the voltage. If you need low headroom it gets progressively more difficult to do a good job as the headroom decreases. Whether it is practical will depend on how accurate you need it. – Spehro Pefhany Oct 7 '16 at 23:26

The 0-12V spec requires a 50mV shunt and Op Amp and low RdsOn MOSFET to regulate any current you can afford to keep cool with a heatsink wasted on voltage drop.

If it were 2.5-12V then your LM317 method works for the range of current and heatsink also required.

When you use PWM with an RC filter and current shunt, you can cut all the losses and heatsink but need a MUCH bigger cap (\$) rated for the RMS current you intend to deliver.

Then when you put a choke rated for the peak current in series with your PWM and regulate the current, now you have a a BUCK REGULATOR, which you can design using a registered email to www.ti.com's home page for a start, then use the datasheets to convert from CV to CC mode, where possible or other sources.

These are now readily available to consumers and Meanwell is a major supplier. It is also possible to modified universal laptop chargers to perform the same task over a limited range like 5-40V

**

New parts come out every day. THIS DOES WHAT YOU WANT.

**

LM317 output voltage can go as low as $1.25\ \mathrm{V}$, if you want to be able to limit the maximum current with any load connected you must bee able to set the output to $0\ \mathrm{V}$.

Imagine this case:
you connect a $1 \ \Omega$ resistor with maximum current set to $1\ \mathrm{A}$. In order to keep the output current below $1\ \mathrm{A}$ your output voltage has to go below $1.25\ \mathrm{V}$ (which is less than the minimum output voltage of the LM317).
In this situation you cannot maintain current limmiting (without blowing anything up)

I'd suggest using a LT3080. With a shunt resistor measure the output current and use this information to adjust the SET pin.