Author Topic: Constant current mode for DIY power supply  (Read 5582 times)

0 Members and 1 Guest are viewing this topic.

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Constant current mode for DIY power supply
« on: February 18, 2019, 02:53:23 am »
I'm working on a home made power supply (for fun). I simulated the attached circuit and it seems to work. I don't remember if I came up with this circuit or if I got it from somewhere, I have been working on this project for a while, on/off redesigning it multiple times. The output of this circuit will feed into a LM317 for voltage regulation. This is a lower power, power supply, ~1.25V to 12V regulated output and I would like current adjustment. I'm going with a linear design for the voltage regulator because I already have all the parts and heatsink I can use and it will be easier for me to understand and analyze.

I would appreciate some feedback. I'm not sure if I will go with LM324 but that's what I put in the simulation. Also not sure of what MOSFET to use. I just choose one that is in TI-TINA.

Basically I'm looking for some feedback on anything that I should be careful with or drawback of this design.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22398
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Constant current mode for DIY power supply
« Reply #1 on: February 18, 2019, 03:58:34 am »
How precise does it have to be?

In my experience, a "ring of two" style circuit, with a thermistor to compensate for Vbe tempco, performs at least as well as you'd need for a "precision" CCS upstream of an LM317 (which draws some current itself, so you can't expect the output current to be quite accurate to what your CCS is doing).

I suspect you'll have problems with compensation, for which a series resistor to U1 -IN and an R+C across U1 (OUT to -IN) will do.  Values depend on T1 capacitance and T1, T3 and U3 gains.

LM324 just barely works as shown, either by accident, or by the SPICE model being oversimplified (which often happens -- don't trust your SPICE models, verify them when you can..).  Namely, you need VCC >= VIN to deal with the input common mode range of LM324 (which is about 1.5V below VCC; the diff sense divider happens to read a common mode of 9/10ths of VIN, or exactly 1.5V below, a rather handy coincidence at this voltage :) ).  Better options include TLV2372 (18V max, not really the best here), TL072 (includes +V rail, but not -V; beware phase reversal and output voltage range -- probably unsuitable for U1), or uhh, some other RRIO amps that I'd have to go shopping for (except for the OPA2192 that does come to mind, but you surely don't need the precision and cost of that one :) ).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17128
  • Country: us
  • DavidH
Re: Constant current mode for DIY power supply
« Reply #2 on: February 18, 2019, 04:16:19 am »
The two operational amplifier functions can and should be combined into one to simply frequency compensation.
 

Online xavier60

  • Super Contributor
  • ***
  • Posts: 2940
  • Country: au
Re: Constant current mode for DIY power supply
« Reply #3 on: February 18, 2019, 04:56:54 am »
If the resistors in the balanced amplifier were all 10K, the op-amp's common mode voltage will be half of VIN.
If there is instability, local negative feedback can be added to U1 although it will cause some extra delay in limiting when a sudden overload occurs.
HP 54645A dso, Fluke 87V dmm,  Agilent U8002A psu,  FY6600 function gen,  Brymen BM857S, HAKKO FM-204, New! HAKKO FX-971.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22398
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Constant current mode for DIY power supply
« Reply #4 on: February 18, 2019, 05:20:41 am »
If the resistors in the balanced amplifier were all 10K, the op-amp's common mode voltage will be half of VIN.
If there is instability, local negative feedback can be added to U1 although it will cause some extra delay in limiting when a sudden overload occurs.

Yeah, diff amps kinda suck if you can't get common mode to behave AND you need gain. :(

You can also pull down the inputs -- consider for example, 10k+10k from sense resistor to input to ground.  Or to put that another way, take the circuit as shown, but add a pull-down from each input to ground.  You get a common mode of ~1/2 VIN, and half the differential signal at the inputs.  Put in feedback resistors as usual (including the resistor from input to ground, or its parallel-combined equivalent), and you get whatever gain you wanted -- but now your noise gain is doubled (which means input offset error, and input referred noise, are both doubled with respect to the output).

A ready-made solution, like an INA1xx current sense amp, gets attractive in this case. :)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online xavier60

  • Super Contributor
  • ***
  • Posts: 2940
  • Country: au
Re: Constant current mode for DIY power supply
« Reply #5 on: February 18, 2019, 05:45:09 am »
The more I look at it, the worse it gets. If the resistors aren't precisely matched, there will be significant offset and poor rejection of VIN fluctuations.
If the offset happens to make the op-amp want to go negative, it can't. This will cause the inability to set the current regulation to low values.
Does the shunt need to be in the positive rail?
HP 54645A dso, Fluke 87V dmm,  Agilent U8002A psu,  FY6600 function gen,  Brymen BM857S, HAKKO FM-204, New! HAKKO FX-971.
 

Offline OM222O

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Constant current mode for DIY power supply
« Reply #6 on: February 18, 2019, 05:46:55 am »
I believe dave made a video series about this, watch the uSupply series.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22398
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Constant current mode for DIY power supply
« Reply #7 on: February 18, 2019, 07:43:45 am »
Yeah, I meant to add that too: the resistors need to be that much better balanced as you divide down the input (increase the noise gain).  Internally laser-trimmed resistors -- in an IC -- get attractive very quickly.

0.1% resistors aren't pricey, at least!

On the upside, the GND-side dead band can be addressed by adding a small offset, i.e., moving the diff amp's output reference node to a slightly elevated voltage.  (You can use a resistor divider for this, but mind the Thevenin resistance of it, which acts in series with the ref side resistor -- or reference the rest of your circuit to that node as well.)  This offsets the setpoint by the same amount, which is fine because that eliminates a possible dead band there too.  If it needs a precision input, you should probably arrange an offset and gain calibration stage; this offset then just gets absorbed into that.  If you really need a no-cal design, you can just keep following the offset back through the circuit and offset the input accordingly (basically, same thing but with hard-wired cal pots :P ).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17128
  • Country: us
  • DavidH
Re: Constant current mode for DIY power supply
« Reply #8 on: February 18, 2019, 10:26:00 pm »
It took me a while to find this; I ran across it a few weeks ago and it applies to what you are trying to do.

This is from the application section of the LT1010 buffer datasheet.  It shows how a single operational amplifier, A3, can be used in a grounded instrumentation configuration to both sense the high side current and act as the current error amplifier while overriding the voltage error amplifier.  In this particular case it does this by pulling the reference voltage down but alternatively it could pull the output of A1 down or be combined with the output of A1 which is more typical for CC/CV power supplies.

The disadvantage mentioned by T3sl4co1l of using a 4 resistor instrumentation amplifier is very apparent here.  Resistor tolerance becomes more important as instrumentation amplifier gain is decreased and here with a gain close to 1, it is very important indeed and 0.1% resistors are shown.  Resistor mismatch results in poor current regulation as the output voltage changes or low output impedance.  The last time I designed current regulation somewhat like this, I included a trimmer with R7 which was adjusted for zero current change with changes in output voltage.

Greater performance is available if current error amplifier A3's inputs are reconfigured to follow the output voltage as two single ended inputs with the current control signal level shifted up to the output voltage by a second operational amplifier which is not within the control loop.  Now the precision is limited only by the error amplifier's common mode rejection and not resistor matching.
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Constant current mode for DIY power supply
« Reply #9 on: February 19, 2019, 04:39:26 am »
How precise does it have to be?
I'm thinking 10 mA accuracy would be ideal but even if its within 50mA I will be okay with it. I'm looking to limit the current during prototype builds and just basic use, so not much accuracy is required for me. Typically the lowest current limit I set is > 100mA but I'm thinking as I work more with microcontrollers 50mA would be good. Not sure how achievable this is, I will try to do some calculations.

In my experience, a "ring of two" style circuit, with a thermistor to compensate for Vbe tempco, performs at least as well as you'd need for a "precision" CCS upstream of an LM317 (which draws some current itself, so you can't expect the output current to be quite accurate to what your CCS is doing).
Not sure what "ring of two" style circuit is, I will have to search this.

Quote from: T3sl4co1l
I suspect you'll have problems with compensation, for which a series resistor to U1 -IN and an R+C across U1 (OUT to -IN) will do.  Values depend on T1 capacitance and T1, T3 and U3 gains.

A ready-made solution, like an INA1xx current sense amp, gets attractive in this case.

0.1% resistors aren't pricey, at least!
I'm planning to use 0.1%, 25ppm resistors. I will look into a ready-made solution IC but I would like to stick with discrete solution. I was really trying to use the parts I already had to make this but more importantly I don't have much analog circuit experience, so looking to expand my knowledge as well.  :)

Quote from: OM222O
I believe dave made a video series about this, watch the uSupply series.
I looked into this before. I was trying to separate the current limit and voltage regulator into two different blocks.

Thank you David Hess. I will look into this. I can go with a instrumentation configuration.

Thank you for all the replies, I appreciate it. I will create an updated schematic based on the feedback and post it here.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22398
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Constant current mode for DIY power supply
« Reply #10 on: February 19, 2019, 11:04:41 am »
Oh hey, I do have an example handy!



You'd flip this low-side sink upside down (NPN --> PNP, N-ch --> P-ch, flip diodes, flip -V for +V supply) for the high side source, but otherwise it shows the "ring of two".

Q1's source current (can also be a BJT with basically no changes) is set by Q2's Vbe, so that:
Is = Vbe / R(R5)
Although, it's a bit more than that, because of the R3+(R4+R6) voltage divider, which you don't usually see in this circuit.  R4 is an NTC thermistor (B ~ 3000) which compensates for Q2's voltage coefficient, keeping current stable as temperature rises (whereas otherwise it falls with rising temp, which really isn't too bad for a protection circuit as is).

In general, R8 and C2 values will change with component choice, so just play around with that when you drop in other components.  The playing is driven by the step response -- note the pulse source on the right for simulating that, as well as L1 which represents wiring inductance (about a meter's worth of cable) and R7+C1 (which dampens L1 and the CCS).  (Ignore R1, it's just there to measure drain current in the simulation.)  And, R2 also depends on devices; in this case it was relatively low to get reasonable response time into Q1's gate capacitance, but it can be set based on hFE(sat) when using a BJT for Q1.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: aiq25

Online The Soulman

  • Super Contributor
  • ***
  • Posts: 1022
  • Country: nl
  • The sky is the limit!
Re: Constant current mode for DIY power supply
« Reply #11 on: February 19, 2019, 12:14:30 pm »
I'd use a second lm317 for current limiting after the voltage regulation.
The datasheet likely will have examples, but not much is needed.
You can either use a pot to make it adjustable or a multi position switch to switch between predetermined settings,
such as 10mA, 50mA, 100mA and 500mA.
The lower amperage's also come in handy for led testing, the higher also for measuring low ohm values in combination
with a voltmeter, handy for testing switches and connections.
 
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
Re: Constant current mode for DIY power supply
« Reply #12 on: February 20, 2019, 05:56:52 am »
I'd use a second lm317 for current limiting after the voltage regulation.

you can't put it after
current limit must precede voltage regulation in case of LM317 voltage regulator and BTW another LM317 would add a 1.25 + 1.5 or more volts of dropout
 
The following users thanked this post: aiq25

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Constant current mode for DIY power supply
« Reply #13 on: February 22, 2019, 03:32:47 am »
I'd use a second lm317 for current limiting after the voltage regulation.
The datasheet likely will have examples, but not much is needed.
You can either use a pot to make it adjustable or a multi position switch to switch between predetermined settings,
such as 10mA, 50mA, 100mA and 500mA.
The lower amperage's also come in handy for led testing, the higher also for measuring low ohm values in combination
with a voltmeter, handy for testing switches and connections.
I might try to make it with this but I also wanted to learn by using a different approach. Still not decided on which way to go though.
 

Offline German_EE

  • Super Contributor
  • ***
  • Posts: 2399
  • Country: de
Re: Constant current mode for DIY power supply
« Reply #14 on: February 24, 2019, 11:51:01 am »
I'd use a second lm317 for current limiting after the voltage regulation.

you can't put it after
current limit must precede voltage regulation in case of LM317 voltage regulator and BTW another LM317 would add a 1.25 + 1.5 or more volts of dropout

Why should this be the case? In its simplest form a fuse is a current limiter and if you exceed the rated current the supply will 'disconnect'. It should be possible to build some form of electronic circuit that will disconnect the output of a regulated supply at a specific current draw and put this after the voltage regulation.
Should you find yourself in a chronically leaking boat, energy devoted to changing vessels is likely to be more productive than energy devoted to patching leaks.

Warren Buffett
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22398
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Constant current mode for DIY power supply
« Reply #15 on: February 24, 2019, 12:40:28 pm »
He's referring to the voltage drop. If you want voltage regulation as priority, you can't afford a load dependent 0-1.25V drop. :)

An electronic fuse is perfectly possible, by the way -- but such circuits are quite a bit more complicated than a pair of LM317s.  The OP may not be quite adventurous enough to do that.

Incidentally, electronic fuse behavior can be very annoying -- you're connecting a power supply to circuits with bypass capacitors very often, and those capacitors need a lot of charge.  Simply shorting an active supply to an electrolytic cap can draw 100A inrush easily, or take milliseconds to charge from around an ampere.  Milliseconds is in the range of blowing transistors from high dissipation.

An electronic fuse that opens in microseconds is easy enough to make, and adequate to protect power transistors, but also rather inconvenient to use.

An electronic fuse that opens in milliseconds is hard to make, for currents over a few amperes and voltages above 10 or 20V.  The problem is power dissipation in the pass transistor.

Best is both, a limited current of about double what you need for the target, with a modest active period (preferably dependent on voltage drop, so the on-time corresponds to peak temperature reached by the limiter -- maximizing the startup time you get).

The limiter can also be made switching, so that the pass transistor dissipates a tiny fraction of full power, and the dropped power is passed on to something more robust (a resistor or TVS, say), or even returned to the source.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Constant current mode for DIY power supply
« Reply #16 on: February 24, 2019, 07:46:08 pm »
Why should this be the case? In its simplest form a fuse is a current limiter and if you exceed the rated current the supply will 'disconnect'. It should be possible to build some form of electronic circuit that will disconnect the output of a regulated supply at a specific current draw and put this after the voltage regulation.

I have done this before for a work project actually, overcurrent and overvoltage protection. Not exactly a fuse but protection circuitry. But that's not exactly what I'm looking for here though, I want a constant current mode. I think T3sl4co1l explains it well above.
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
Re: Constant current mode for DIY power supply
« Reply #17 on: February 25, 2019, 03:05:37 pm »
Why should this be the case? In its simplest form a fuse is a current limiter and if you exceed the rated current the supply will 'disconnect'. It should be possible to build some form of electronic circuit that will disconnect the output of a regulated supply at a specific current draw and put this after the voltage regulation.

I have done this before for a work project actually, overcurrent and overvoltage protection. Not exactly a fuse but protection circuitry. But that's not exactly what I'm looking for here though, I want a constant current mode. I think T3sl4co1l explains it well above.

You would have more chances of success by using a single opamp, but you have to take into account the working input voltage range and output limits and use a high side reference.
You might use a rail-to-rail opamp or higher/lower supply rails to keep the values within the working limits or some other tricks like in the circuit below where a couple of LT1004 (replaceable with LM385) are used to keep the maximum input voltage within the bounds of the LT1013 specifications and another one, plus a potentiometer, to provide a variable reference for the current control.

« Last Edit: February 25, 2019, 03:08:23 pm by not1xor1 »
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Constant current mode for DIY power supply
« Reply #18 on: February 26, 2019, 05:00:24 am »
You would have more chances of success by using a single opamp, but you have to take into account the working input voltage range and output limits and use a high side reference.
You might use a rail-to-rail opamp or higher/lower supply rails to keep the values within the working limits or some other tricks like in the circuit below where a couple of LT1004 (replaceable with LM385) are used to keep the maximum input voltage within the bounds of the LT1013 specifications and another one, plus a potentiometer, to provide a variable reference for the current control.
I understand the basics of this circuit but one thing I can't figure out is the actual equation to figure out what the current limit is... If you can explain it, I would appreciate it. This seems like an interesting circuit and will definitely consider it.
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
Re: Constant current mode for DIY power supply
« Reply #19 on: February 26, 2019, 08:53:54 am »
You would have more chances of success by using a single opamp, but you have to take into account the working input voltage range and output limits and use a high side reference.
You might use a rail-to-rail opamp or higher/lower supply rails to keep the values within the working limits or some other tricks like in the circuit below where a couple of LT1004 (replaceable with LM385) are used to keep the maximum input voltage within the bounds of the LT1013 specifications and another one, plus a potentiometer, to provide a variable reference for the current control.
I understand the basics of this circuit but one thing I can't figure out is the actual equation to figure out what the current limit is... If you can explain it, I would appreciate it. This seems like an interesting circuit and will definitely consider it.

Just remember that thanks to the feedback opamp inputs are kept at the same voltage.
Dismiss the 2.5V of U3 and U4 as they are not relevant for the purpose.
The circuit just tries to keep the voltage through R1 (0.33*I in this test circuit) equal to the value between the cathode-like terminal of U2 and the potentiometer cursor.
When the voltage drop trhough R1 is less than that value the darlington (Q1+Q2) is in saturation and there is no current regulation.

The maximum current is when the pot cursor is connected to the anode of U2.
So let's call:
w = wiper position ranging from 0 (min current - close to the cathode) to 1 (max current - close to the anode)
I = current
R = R1 value
V = U2 voltage
Now we have
R*I = V*w
i.e. the regulated current I is I= V*w/R

The potentiometer value is not critical. High values are more affected by opamp bias, but in any case the intrinsic non-linearity of the potentiometer would likely be greater.
« Last Edit: February 26, 2019, 09:00:38 am by not1xor1 »
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Constant current mode for DIY power supply
« Reply #20 on: February 27, 2019, 04:21:54 am »
Just remember that thanks to the feedback opamp inputs are kept at the same voltage.
Dismiss the 2.5V of U3 and U4 as they are not relevant for the purpose.
The circuit just tries to keep the voltage through R1 (0.33*I in this test circuit) equal to the value between the cathode-like terminal of U2 and the potentiometer cursor.
When the voltage drop trhough R1 is less than that value the darlington (Q1+Q2) is in saturation and there is no current regulation.

The maximum current is when the pot cursor is connected to the anode of U2.
So let's call:
w = wiper position ranging from 0 (min current - close to the cathode) to 1 (max current - close to the anode)
I = current
R = R1 value
V = U2 voltage
Now we have
R*I = V*w
i.e. the regulated current I is I= V*w/R

The potentiometer value is not critical. High values are more affected by opamp bias, but in any case the intrinsic non-linearity of the potentiometer would likely be greater.

Thank you for the explanation. Is there a way I can make the current setting digital? It will be ideal if I can use a PWM signal to get DC voltage and set the current but I can't figure out how to do it with this circuit, that way I can use a micro to set it. I like the analog solution as well.

I came up an idea by adding a differential amplifier to replace the pot and subtract the voltage from a DC source from the anode of U2. But then this solution again becomes two op-amp solution. Attached is what I came up, sorry it's a bit messy layout, I was just messing around in SPICE.

I modified the circuit by changing to TL431 as the references and also use a P-Channel MOSFET.
« Last Edit: February 27, 2019, 04:26:21 am by aiq25 »
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
Re: Constant current mode for DIY power supply
« Reply #21 on: February 28, 2019, 08:53:35 am »
Just remember that thanks to the feedback opamp inputs are kept at the same voltage.
Dismiss the 2.5V of U3 and U4 as they are not relevant for the purpose.
The circuit just tries to keep the voltage through R1 (0.33*I in this test circuit) equal to the value between the cathode-like terminal of U2 and the potentiometer cursor.
When the voltage drop trhough R1 is less than that value the darlington (Q1+Q2) is in saturation and there is no current regulation.

The maximum current is when the pot cursor is connected to the anode of U2.
So let's call:
w = wiper position ranging from 0 (min current - close to the cathode) to 1 (max current - close to the anode)
I = current
R = R1 value
V = U2 voltage
Now we have
R*I = V*w
i.e. the regulated current I is I= V*w/R

The potentiometer value is not critical. High values are more affected by opamp bias, but in any case the intrinsic non-linearity of the potentiometer would likely be greater.

Thank you for the explanation. Is there a way I can make the current setting digital? It will be ideal if I can use a PWM signal to get DC voltage and set the current but I can't figure out how to do it with this circuit, that way I can use a micro to set it. I like the analog solution as well.

I came up an idea by adding a differential amplifier to replace the pot and subtract the voltage from a DC source from the anode of U2. But then this solution again becomes two op-amp solution. Attached is what I came up, sorry it's a bit messy layout, I was just messing around in SPICE.

I modified the circuit by changing to TL431 as the references and also use a P-Channel MOSFET.

The differential amplifier is out of the feedback loop so it doesn't affect the circuit stability. Just remember to add a buffer between the filtered PWM and the differential input.
TL431 should be fine, just ensure to properly bias them (i.e. current must by >= 1mA). They are cheap, so you might by a few tenths or even 100 for few dollars and select a matched pair.
The MOSFET might be a problem since most of them are unsuitable for linear operations. The one you used in the simulation is specified for DC operations (in the SOA graphic) but would be able to dissipate 42W only with an ideal (0K/W) heatsink.
Provided that the specified SOA is real (not just calculated), to withstand (12V less LM317 dropout) * 1.5A you would need to solder that MOSFET directly to a large copper heatsink
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf