Constant current mode for DIY power supply - Page 1
Forum section: electronics / projects

author: aiq25
author_rank: Regular Contributor
timestamp: February 18, 2019, 02:53:23 am
content: 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 18, 2019, 03:58:34 am
content: 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

author: David Hess
author_rank: Super Contributor
timestamp: February 18, 2019, 04:16:19 am
content: The two operational amplifier functions can and should be combined into one to simply frequency compensation.

author: xavier60
author_rank: Super Contributor
timestamp: February 18, 2019, 04:56:54 am
content: 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 18, 2019, 05:20:41 am
content: Quote from: xavier60 on February 18, 2019, 04:56:54 amYeah, 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

author: xavier60
author_rank: Super Contributor
timestamp: February 18, 2019, 05:45:09 am
content: 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?

author: OM222O
author_rank: Frequent Contributor
timestamp: February 18, 2019, 05:46:55 am
content: I believe dave made a video series about this, watch the uSupply series.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 18, 2019, 07:43:45 am
content: 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).Tim

author: David Hess
author_rank: Super Contributor
timestamp: February 18, 2019, 10:26:00 pm
content: 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.

author: aiq25
author_rank: Regular Contributor
timestamp: February 19, 2019, 04:39:26 am
content: Quote from: T3sl4co1l on February 18, 2019, 03:58:34 amI'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.Quote from: T3sl4co1l on February 18, 2019, 03:58:34 amNot sure what "ring of two" style circuit is, I will have to search this.Quote from: T3sl4co1lI'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: OM222OI 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 19, 2019, 11:04:41 am
content: 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

author: The Soulman
author_rank: Super Contributor
timestamp: February 19, 2019, 12:14:30 pm
content: 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 combinationwith a voltmeter, handy for testing switches and connections.

author: not1xor1
author_rank: Frequent Contributor
timestamp: February 20, 2019, 05:56:52 am
content: Quote from: The Soulman on February 19, 2019, 12:14:30 pmyou can't put itaftercurrent 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

author: aiq25
author_rank: Regular Contributor
timestamp: February 22, 2019, 03:32:47 am
content: Quote from: The Soulman on February 19, 2019, 12:14:30 pmI 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.

author: German_EE
author_rank: Super Contributor
timestamp: February 24, 2019, 11:51:01 am
content: Quote from: not1xor1 on February 20, 2019, 05:56:52 amWhy 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 24, 2019, 12:40:28 pm
content: 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

author: aiq25
author_rank: Regular Contributor
timestamp: February 24, 2019, 07:46:08 pm
content: Quote from: German_EE on February 24, 2019, 11:51:01 amI 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.

author: not1xor1
author_rank: Frequent Contributor
timestamp: February 25, 2019, 03:05:37 pm
content: Quote from: aiq25 on February 24, 2019, 07:46:08 pmYou 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.

author: aiq25
author_rank: Regular Contributor
timestamp: February 26, 2019, 05:00:24 am
content: Quote from: not1xor1 on February 25, 2019, 03:05:37 pmI 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.

author: not1xor1
author_rank: Frequent Contributor
timestamp: February 26, 2019, 08:53:54 am
content: Quote from: aiq25 on February 26, 2019, 05:00:24 amJust 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 = currentR = R1 valueV = U2 voltageNow we haveR*I = V*wi.e. the regulated current I is I= V*w/RThe 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.

author: aiq25
author_rank: Regular Contributor
timestamp: February 27, 2019, 04:21:54 am
content: Quote from: not1xor1 on February 26, 2019, 08:53:54 amThank 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.

author: not1xor1
author_rank: Frequent Contributor
timestamp: February 28, 2019, 08:53:35 am
content: Quote from: aiq25 on February 27, 2019, 04:21:54 amThe 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