LM358 in Consant Current Circuit Problem - Page 1
Forum section: electronics / beginners

author: TheInfernoMan
author_rank: Contributor
timestamp: December 31, 2016, 03:40:58 pm
content: Hello,I am new to this forum and I have a question, regarding to my Schematic.My wish is to build a Constant Current Dummy Load like the one from Dave, but I have a lot of problems.I started on the breadboard and I think everything worked okay. Then I designed a PCB and built it up.There starts the problem. The Current is all, but not constant. At one time, there is no current, then the full 5A, instead my wish of 1A at this time.So I started debugging my circuit and I think I destroyed one LM358 (I dont know how, but I had 40V on my Circuit, but only powering with 12V Input).Now I simplified the schematic as good as I can and attached it to this post. (I used a new LM358 in the debugging circuit)The original Schematic is also attached (is there a mistake ?)If I connect the non-inverting Input to Ground and use the LM358 in a Comperator configuration my idea is that no current should flow.But in Reality there is 1.3A flowing at A1.Why is this so ? I have no idea.--I am really new to electronics and I am German, I'm Sorry for a few mistakes in my language...

author: Kleinstein
author_rank: Super Contributor
timestamp: December 31, 2016, 03:51:42 pm
content: The LM358 can easily oscillate with too much capacitive load at its output. Something like 100 pF, maybe 1 nF with some luck is Ok, but more is calling for trouble. The 2 FETs are more like in the 10 nF range.So one would need to have resistors between the OPs output and the gates (one for each FET). This is generally a good idea if there are two MOSFETs in parallel as other wise high frequency oscillations are possible.In addition there should be a fast feeedback directly around the OP: so a capacitor from OPs output to the inverting input, and a resistor in front of the inverting input.C1 in the original circuit is at a wrong place (wrong input) and rather large - more like 1 nF would be the right size.For a first test I would use just one FET, with 40 V it is possible the FETs died from to much voltage.

author: TheInfernoMan
author_rank: Contributor
timestamp: December 31, 2016, 04:01:58 pm
content: So I changed my circuit a little bit, but in this short time I could not desolder my FET's from each other.The new Circuit is now attached and the problem is likely the same, but now at A1 is only 0.02A instead of 1.3ABut if I slowly rise the Voltage at the non-inverting input the Current Rises instantly to 3AShould I desolder the FET's from each other and try ?

author: TheInfernoMan
author_rank: Contributor
timestamp: December 31, 2016, 04:12:03 pm
content: If I apply 0.1V to the Non-Inverting Input the flowing Current is like 0.5A, but if I continue rising up the Voltage to 0.15V the Current, which is flowing decreases with more Voltage at the non-inverting Input. And my buck-converter which supplies the non-inverting input makes a quiet buzzer sound. Now and then the Current oscillates (I see it on my Ammeter) from 0A to 0.9A often up and down.

author: Audioguru
author_rank: Super Contributor
timestamp: December 31, 2016, 06:08:48 pm
content: You missed an important fix to prevent the new oscillation: "In addition there should be a fast feedback directly around the OP: so a capacitor from OPs output to the inverting input".

author: TheInfernoMan
author_rank: Contributor
timestamp: December 31, 2016, 06:31:42 pm
content: Now I added a 0.022uF Capacitor betweent Output and the inverting Input, but it's not better, with Ground connected to the non-inverting Input there flows 1.5A

author: orolo
author_rank: Frequent Contributor
timestamp: December 31, 2016, 07:03:57 pm
content: Bypass the 12K in the noninverting amplifier with, say, 10nF.I have simulated the circuit and it oscillates like crazy, because of the noninverting stage.

author: Yansi
author_rank: Super Contributor
timestamp: December 31, 2016, 07:12:49 pm
content: Still the circuit needs much improvements. At least, add two separate about 220ohm gate resistor. Also each of the mosfets shall have its own current shunt. Otherwise the current won't be halved and mosfets have to be closely paired/matched - which is a pain in the ass.Also, the circuit is lacking a loop rolloff (compensation). Place a small cap across the opamp (output to inverting input) and feed the inverting input through a resistor. Lets begin with somethinh like 1k 1n.

author: Yansi
author_rank: Super Contributor
timestamp: December 31, 2016, 07:14:45 pm
content: Quote from: orolo on December 31, 2016, 07:03:57 pmNo. The 12K resistor shall be split for two separate gate resistors (to prevent HF mosfet oscillations) and shall NOT AT ALL be EVER shunted by any cap.see my previous post.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 31, 2016, 07:16:15 pm
content: R3 = 12 K is way to large. This makes R3 and the gate capacity a significant low pass, possibly even lower than the 22 nF and 3 K. A more normal value would be 100-330 Ohms, so just enough that the OPs output is not upset with the capacitive load.Another point is that there should be an RC snubber (e.g 10 Ohms an 10 µF in series) at the output - just in case the source is inductive.Make sure the second halt of the LM358 is not causing trouble.If the two MOSFETs are really tight coupled it might be OK, but the second MOSFET might not help very much, as current sharing will not be good. So you may have to separate them anyway. With more MOSFETs, each one should at least have it's own gate and source resistor. The signals from the source can than be combined with resistors (like the 3 K resistor in the circuit).With 5 mV of offset rating, there could be a current up to about 25 mA, even with the control voltage at zero. So 3 A of output suggests the circuit is still oscillating somehow, or something is broken.

author: Benta
author_rank: Super Contributor
timestamp: December 31, 2016, 07:17:16 pm
content: Before trying to compensate the circuit with caps all over the place, I have a question:Where is the supply bypass cap(s) at the opamp?I mean, this kind of currentsourcesink is normally a nobrainer, especially with an amp that's so well-behaved as the LM358.

author: Yansi
author_rank: Super Contributor
timestamp: December 31, 2016, 07:18:16 pm
content: Quote from: TheInfernoMan on December 31, 2016, 04:01:58 pmThe load current is proportional to the voltage on the noninverting input. Iload = U / R1 = U / 0.2That means 1V input yields 5 amps!Benta: Sure, that is also a good question to start with!

author: orolo
author_rank: Frequent Contributor
timestamp: December 31, 2016, 07:20:52 pm
content: Quote from: Yansi on December 31, 2016, 07:14:45 pmNo, no. Look at hiscompleteschematic. He is feeding the mosfet-driving part of the 358 with the other half acting as a non-inverting amplifier, with 3k/12k.Thereis the problem (or at least, a big problem).

author: Yansi
author_rank: Super Contributor
timestamp: December 31, 2016, 07:23:01 pm
content: Oh, sorry, I was thinking only about the first schematic, that is at least partially OK.The second one (Schaltplan.png) is very wrong of course.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 07:59:30 am
content: First I have to say, that I am really sorry for my mistakes in my schematic. But I did not know it better.I think I have to redesign my schematic. How can I make that better, if I not know all these things about oscillations etc. ? I have only seen some "basics" videos.Did somebody got a tip, how it is easier for me to Look for mistakes Like Them ?Can someone make a short schematic, of the Basic Part of the CC Load, what I should make so. I would be really thankful.I am really thankful for your help.

author: orolo
author_rank: Frequent Contributor
timestamp: January 01, 2017, 11:19:58 am
content: You can solve both problems. Instead of amplifying x5 the load voltage, divide by 5 the potentiometer reference voltage: you can do that with a follower and a divider. That way, you keep the dangerous amplifier out of your feedback loop.About the constant current, keep it simple and try an RC filter like the following. I don't mind building the circuit myself and testing it, if it gives more trouble.

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 11:48:46 am
content: Yes, that is the correct way to do it. However, you're missing a gate resistor - loading the opamp capacitively migh produce instability, or even HF oscillations of the mosfet. So adding a few hundred ohms series resistor to the gate is the simplest solution.TheInfernoMan: You shall stop watching simple videos, as obviously, you don't learn anything from them, as things aren't that simple in reality.I think Dave (EEVBlog) did make a video about designing a constant current load some time ago. Try to look it up. But I'd also recommend googling for application notes from the big semiconductor companies, as there are lot of very detailed appnotes with all the engineering in them, to make a basic up to very well behaved constant current loads.For example I remember appnote from Jim Williams designing a 100A load, this one:http://cds.linear.com/docs/en/application-note/an104f.pdf

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 12:00:36 pm
content: So first I want to say thanks to Orolo and Yansi.I built up the simple circuit from you and it works fine.You can't imagine how happy I am to see a circuit on my desk workingI would read the document you linked Yansi now, and I think I can learn a lotI will now redesign my schematic and build a new PCB.Thanks,@Orolo Can I send you my finished schematic, that you can have a look on it, I would not spend again hours to solder and then throw it awayAttached: Now the schematic that works; can I built my new schematic up from that schematic ?

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 12:18:27 pm
content: Soldering and throwing away often gives you more valuable experience, than just look at thingsEven if you build something that does not work as intended is an experience.

author: orolo
author_rank: Frequent Contributor
timestamp: January 01, 2017, 01:31:52 pm
content: Quote from: TheInfernoMan on January 01, 2017, 12:00:36 pmI'll build your circuit (with a different mosfet, I have to look what I got in the hoard) -- I'm curious about the gate resistor. Simulating your circuit, it works fine as per your schematic. It gently gets into regulation with no overshoot, no matter how big the gate resistor. However, with other mosfet models, increasing the gate resistor caused overshoot, so I think I'll put a pot there and see what happens.I'm very glad the circuit worked, but the merit is not mine at all. I took the simple circuit from The Art of Electronics, values included. In the book they don't use a gate resistor, probably because they employ a jfet instead of a mosfet.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 01:47:58 pm
content: So now I redesigned my schematic and followed the simple one.Would this circuit work now ?If, then I would begin solder it to a piece of perfboard.Attached is the new schematic.What was ment with a supply bypass capacitor? (C3 is also attached to the Opamp, is this the bypass ?)Thanks in advance

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 01:51:02 pm
content: No it won't work at all, as you are confusing the inverting and non-inverting inputs of the opamps. Have a thorough look at theorolo's schematic.Also, the buffer amp is absolutely of no use there.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 01:55:51 pm
content: Oh sorry, you are right, obviously. Now I changed the Input.What do you mean with the buffer amp? (Do you mean U1.2? It is also in the simple schematic...)

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 02:02:29 pm
content: Yes, U1.2. That's a buffer, voltage follower or whatever you call it. It does not help with anything in the circuit, only makes it worse:The noninverting input of U1.1 is already high impedance, why buffering it again?The real opamps have offset voltage. That means a voltage, that is like "added" to the real input voltage. It is usualy a few mV and drifts with temperature. The useless buffer only adds error to the signal it is buffering, as it's output voltage equals the input one, plus the offset and its temperature drift.As you already work with small voltages in the circuits (let's say hundred mV or a volt), the few mV offset voltages both from the buffer and the current regulating opamp U1.1 adds significant errors in the circuits precision. Thats because the offset voltages are becoming significant compared to the operating voltages in the circuit.The useless buffer is lowering the precision of the circuit. That will show up as the current setpoint of your CC load being more temperature dependent and not tracking the setpoint voltage (from the potentiometer) exactly.You can also verify simply with some precision voltmeter: Measure the voltage on the pin 5 to ground, and then the voltage on the shunt. In theory, these should be absolutely the same. But there will be a difference of few mV (say up to 10mV). And this voltage error will be also dependent on the temperature of the opamp.If your shunt is being 0.2 ohms, the 10mV error equals 50mA error in the load current. Also considering that LM358 has a typical offset drift of 7uV/K up to 20uV/K, that means if you raise the temperature of the opamp for 10°C, you add up to 200uV error each amplifier, resulting in 0.4mV error. Your load current will change up to 0.4mV/0.2ohm = 2mA per 10°C temperature change.Might not be of any problem here, but may be a big trouble in other applications, so better being aware of this.(not mentioning we have not counted for many other aspects, like input offset currents)

author: Richard Head
author_rank: Frequent Contributor
timestamp: January 01, 2017, 02:03:07 pm
content: An NPN bipolar transistor is a better choice in this application.

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 02:09:56 pm
content: No it is not, as it will complicate the current sensing, as you can not then simply use a shunt in the emittor. You would be measuring emitter current, not the collector one. Emitter current is Ic+Ib and Ib being significant (remember that high power BJTs have low current gain typical) compared to the Ic.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 02:14:27 pm
content: Ok, thanks for the tip regarding to the offset voltage.Would the following schematic would work now ?There are a lot of things I had not known, but I learned a lot now.But I want to build the PCB now, but there a lot of mistakes in my schematicsorry

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 02:21:18 pm
content: Add a cap accross R10. Value not critical. 100nF for example. Will work as a small noise filter. Will come handy, if you wire the potentiometer on long leads, that would pick up RF noise.Also, when making the layout, make sure that the you know signal wire/trace from pin2 (inverting input) is a high impedance and can accept interference - keep it short as possible, place both C1 and R12 close to the pin2.Place another 100nF decoupling cap close between pins 4 and 8 of the opamp. (The 10uF on the input already might be enough, but aswell might not, depending on the layout. )

author: Richard Head
author_rank: Frequent Contributor
timestamp: January 01, 2017, 03:11:01 pm
content: YansiYes, you are correct. sorry.

author: Yansi
author_rank: Super Contributor
timestamp: January 01, 2017, 03:50:06 pm
content: But to be fair, it can be done with the BJT too, even with similar simplicity: but the constant current load won't be ground terminal referenced then. But that is really no problem, if the supply for the control circuitry is floating.Note:TheInfernoMan: Now for this circuit, the buffer will come handy, as the output current is proportional to the current flowing through R1. The circuit also can be designed so that the effect of offset voltage of the buffer will play insignificant role, as the offset voltage of the buffer is effectively divided by the ratio of R1 and R2.Also good to note, that the formula for Iload works only when R2 is significantly higher, than Rsense, which for most cases is fulfilled (Rsense some tenths of ohm, R2 hundreds ohms or few Kohms)

author: orolo
author_rank: Frequent Contributor
timestamp: January 01, 2017, 09:11:17 pm
content: I have built the circuit and tested it, and it works (tested the load with an ammeter), at least up to 1 amp @ 40V. I have used your parameters, 40V for the source, an MC7812 regulator for the opamps, one LM358, etc.The schematic is attached below. If you are interested, I can post some images and probe the circuit with an oscilloscope to see how it behaves. The load current increases in an apparently linear way with the pot, but I haven't checked the precision.Some obvious points:-> If you connect the current sink directly to 40V, the mosfet will dissipatea lotof power (about 40W at 1 amp). If you are planning to go into the multiamp range, you'll need a massive heatsink and probably a fan. Study carefully the thermal aspect of the project. A quick look at the IRFZ44 datasheet tells it manages up to 50 Watts, so without source resistance that's 1.25 amps per transistor. Without a good heatsink, your mosfets will die very quickly.-> I designed the voltage divider thinking in very high currents, and used a low quality potentiometer. Design the divider carefully for the desired current range, and use a quality pot. The current is controlled by a voltage divider, which is buffered by one half of the 358, then divided by 5, and sent to the regulator.-> In my circuit I used an alleged IRF1405 bought from ebay, who knows what's really inside. It works, though. The 358 is also an ebay cheapy, bought in a lot of 50.-> Don't forget to load the 7812 with at least 5mA for it to regulate reliably. I used an LED for that.To increase stability, I thought of using the opamp to drive a 2N7000 (from the 12V supply!), which in turn drives the bigger mosfet. The 2N7000 has much lower capacitance. The idea worked in simulation, but seemed to give no real advantage. Simulating some more, I got oscillations for very light load currents with no gate resistor: with a gate resistor, the oscillations went away.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 01, 2017, 09:26:43 pm
content: Thanks for your work on your schematic, it is near to my current schematic I thinkI will solder my PCB tomorrow and test it out, I think i will post my results as an answer.Temperature is not the problem in my case. The MOSFET is not directly on the PCB it is mounted to a CPU Cooler which is capable of dissipating to 100W heat. The limitation comes from the MOSFET (IRFZ44N) which can only dissipate around ~90W maximum (Infineon Datasheet). So the CC Load would be rated to 60W at the End (to go safe).I used the L7805 for a voltage reference and I included a minimum load in my schematic, so it would be not the problem.Precision is not the most important point, important is that the current is constant, so that I can record a nice decharging graph of a battery for example.With kind regards, TheInfernoMan

author: Kleinstein
author_rank: Super Contributor
timestamp: January 01, 2017, 09:38:51 pm
content: To ensure stability with an inductive source, one might need a snubber (R and C in series) at the output. Something like 1-10 µF and 10 Ohms should be about the right size.Also a fuse in series is a good idea - just in case the FET fails with a short, which more like the normal mode of failure.The permissible power at the MOSFETs is not only limited by there Ptot rating and thus the chip temperature. There usually also is a SOA limit, that can be significantly lower if the voltage is relatively high. This especially true for relatively modern MOSFETs made for lower voltage (e.g. < 200 V). So if you need 40 V operation, look for FETs specified for 200 V switching. Something like a IRFP250 is such an older type. Different from switching applications you want types with a low trans-conductance compared to the rated power, and not the lowest R_on. For the IRFZ44 mentioned here 1.5 A at 40 V could already be too much - the DS I found has no curve specifying a DC SOA, so no guarantee it works.With MOSFETs of a dubious source, like Ebay, be prepared that there might be a smaller FET inside and thus sudden failure is possible. You would be lucky if you get an old sucker instead - but this is possible too.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 02, 2017, 04:30:52 pm
content: So I've built the schematic up on a pice of perfboard and it works very well. One improvement possibility is that it is hard to set a good Current with the help of the potentiometers (also because I used a 100k and a 25k (for fine adjustment), but it looks like its not a linear adjustment (can that be?)).So at the End, I am really thankful for the help of all here and from my side the topic is closedRegards, TheInfernoMan

author: Seekonk
author_rank: Super Contributor
timestamp: January 02, 2017, 10:52:04 pm
content: Did you by the pots as linear or are they out of some audio equipment. Those are not linear. Set pot midway and measure resistance.

author: orolo
author_rank: Frequent Contributor
timestamp: January 03, 2017, 12:30:54 am
content: My own version is quite linear, and fairly accurate, considering the design and components involved. I have tested various currents for several positions of the potentiometer: being a low quality thing, I had to wait some time for the wiper to stabilize. The measurements were:Code:OHMS CURRENT0 0.01uA72.7 68.0mA109 109.9mA114.8 113.5mA167.6 176.9mA237 0.24A440 0.48A513 0.56A620 0.68A745 0.81A1018 1.11AI tried to use the more precise mode of the multimeter for each measurement, hence the variations in precision. Anyway, it looks pretty linear, and very precise in some of the ranges.I attach a photograph of the circuit at work in one of the measurements (sorry for the size). I was running out of space in the perfboard, so the mosfet drain is fed via the heatsink. The measurements were made at 40V, as in your description.

author: TheInfernoMan
author_rank: Contributor
timestamp: January 03, 2017, 09:48:07 am
content: Thanks for your VersionYeah I think my Potentiometers are not linear, but at the End I think this is not so bad,because at the End I use the Range between 0-1A and upwards I only need (in most cases) 2,3,4A which I can achieve with the non-linear pots.

author: orolo
author_rank: Frequent Contributor
timestamp: January 03, 2017, 12:18:53 pm
content: One thing of note is that the output current of the circuit (my version) follows the formula I = 12·R / (10k + R), so it is clearly nonlinear for high currents. I wanted to see how well the circuit followed this curve, so I plotted it. The matching is pretty good.Another thing I would test is transient stability under a change of load. What happens if a load resistance is switched on and off, does the circuit ring, and for how long. In simulation there is a bit of ringing, but it dies down rather fast.

author: Kleinstein
author_rank: Super Contributor
timestamp: January 03, 2017, 01:53:02 pm
content: Ringing and possibly oscillation at the output is expected with a source that is inductive. So for the hard test, add an inductor between the voltage source and the load.To ensure stability usually an RC element in parallel to the electronic load is used or needed.

author: orolo
author_rank: Frequent Contributor
timestamp: January 03, 2017, 06:16:57 pm
content: A final detail: to test the transient behavior, I put a 270 ohm, 10 Watt resistor in parallel with a power mosfet, and used a 555 timer to switch between both in periods of about 0.5s. Then I connected this source to the current sink, after adding a fuse and the RC snubber, just as Kleinstein proposed. I programmed the current to sink 110mA, and made sure that the mosfet and resistor were alternatively conducting the current. Neither the scope nor the multimeter could discern any ringing, and the current stayed stable. If I disconnected the resistor, I could see the square wave as the mosfet switched on and off.I took a shot of the mosfet turning on wihtout the resistor, this should give an idea of how the current source starts up. My oscilloscope is not good at all, and the 555 couldn't drive the mosfet to act as a complete switch (the 555 was connected to the 12V supply). The shot is the voltage at the switching mosfet source, with 2V/100us per division, DC coupled. There is a brief peak, and then the voltage stabilizes very quickly.I think that, with the snubber, the current sink is quite stable. The fuse seems to me also an indispensable idea.

author: salami738
author_rank: Contributor
timestamp: July 13, 2019, 01:45:46 pm
content: Hi, i used the schematics from this post for my electronic load and got oscillations above a certain current.Maybe someone from this thread could look into this:https://www.eevblog.com/forum/beginners/oscillations-with-lm358-electronic-load/msg2544855/#msg2544855?Thanks for your help.