Mosfet driver for op-Amp based constant current source. - Page 1
Forum section: electronics / beginners

author: 4kruby
author_rank: Contributor
timestamp: January 20, 2022, 02:35:50 pm
content: Hello,I am trying out a circuit for a constant current load for discharging Lithium batteries using mosfet and op-amp.I am using LM358 for op-amp and IRFZ44N for the mosfet from a 5v (500mA max) power supply.First I tried a circuit like this (file : circuit_1):Here, I got the output of the op-amp as around 3.7v which is not enough to switch the mosfet completely. Moreover, as you can see, I was using the same power source for powering mosfet as well as to connect the mosfet drain. I observed that very little current was flowing and mosfet became very hot.I have a few questions here:Can I use a single transistor to drive the mosfet? Most of the circuits I encountered had the mosfet gate connected to the collector of the BJT where the logic will be reversed (mosfet OFF when op-amp is ON).Is it possible to connect the mosfet to the low-side (emitter) of the BJT and switch it ON?Thanks.

author: ledtester
author_rank: Super Contributor
timestamp: January 20, 2022, 04:06:59 pm
content: Quote from: 4kruby on January 20, 2022, 02:35:50 pmIt seems you are using +5V to power the op-amp. The LM358 only has a voltage swing of 0 to the positive supply - 1.5V. How about using a higher supply voltage for the op-amp? Or a different op-amp (with rail-to-rail output) or a different MOSFET with a lower Vgs.QuoteA schematic of what you're intending would be helpful.Do you mean the op-amp output is driving an NPN base with the emitter driving the MOSFET gate?

author: magic
author_rank: Super Contributor
timestamp: January 20, 2022, 09:14:34 pm
content: This circuit is not very accurate because LM358 draws additional 0.5~1mA from the battery which is not measured by the resistor.If this is not a problem, you can replace the MOSFET with any random TO220 NPN transistor. Base current will not be an error because it comes from LM358 which takes it from the battery. So all current measured by the 1Ω resistor comes from the battery and the only error is the small current flowing through LM358 ground pin, which is not counted, as before.

author: 4kruby
author_rank: Contributor
timestamp: January 20, 2022, 09:15:33 pm
content: Quote from: ledtester on January 20, 2022, 04:06:59 pmI was naïve enough to think that a transistor would do the trick with the 5v supply forgetting the fact that the transistor will drop a good 0.6volts atleast which will then be under the 4.5v gate threshold.Quote from: ledtester on January 20, 2022, 04:06:59 pmYes Exactly.I came to my senses a bit now. A 5v is not sufficient even if a transistor is introduced (unless there is a boost circuit of some sort).So, the supply voltage has to be increased. In that case, since the Opamp should be able to handle a wide range of voltage, I can altogether use the same circuit with a higher voltage as you suggested and throw away the great idea of including a transistor (unless we need a fast switching of course for the gate current which I need to determine).

author: 4kruby
author_rank: Contributor
timestamp: January 20, 2022, 09:18:46 pm
content: Quote from: magic on January 20, 2022, 09:14:34 pmWell, obviously I did not think about this too. (The assumption of an ideal opamp - which I should try to erase from my brain).Is there a way I can mitigate this? I mean make the circuit more accurate?

author: magic
author_rank: Super Contributor
timestamp: January 20, 2022, 09:21:22 pm
content: I have a bunch of old TS27L2 opamps with 20µA current consumption, so I would simply pull one of those. TLC27L2 is a TI equivalent.If you can find them, or some other ultra low power CMOS opamps, that might be the laziest solution. Many CMOS opamps have rail to rail outputs too (but not xx27L2).Wait, sorry. I don't think this chip would be good for operation down to 3V - its output needs even more positive voltage headroom than LM358.Of course you can always use external supply for the opamp, if you don't mind that. Or try to pass LM358 ground current through the 1Ω resistor, but this requires a slightly more complex circuit where the opamp works in inverting configuration.There is also the question what happens when the battery is fully discharged and the opamp continues drawing current from it. Not good for unprotected cells.

author: Benta
author_rank: Super Contributor
timestamp: January 20, 2022, 09:27:59 pm
content: Quote from: 4kruby on January 20, 2022, 02:35:50 pmYou'll see that it can get MUCH hotter. All the energy from the battery will have to be dissipated by your MOSFET (and a little bit but the sense resistor). You'll need to buy some aluminium chunks somewhere to cool it.

author: 4kruby
author_rank: Contributor
timestamp: January 20, 2022, 09:40:39 pm
content: Quote from: magic on January 20, 2022, 09:21:22 pmWhat do you mean by "always use external supply for the opamp" ? I am sorry for the circuit as it does not show the opamp power terminals. The opamp will be powered by a separate supply other than the battery.Yes. the discharging should not continue. I would either protect the battery with a battery protector IC or might include a microcontroller to monitor the whole thing.I consulted the datasheet of LM358 and found that it can source or sink 20mA of current (average). But I am not sure whether this is enough for a frequency of say 150khz (the gate charge of the mosfet I am using to be 63nC). (150Khz is a fancy switching frequency of the opamp output which I saw in one of the videos where a similar setup was tested).Quote from: BentaYes thanks, I am planning to install a heatsink.

author: magic
author_rank: Super Contributor
timestamp: January 20, 2022, 09:49:42 pm
content: Quote from: 4kruby on January 20, 2022, 09:40:39 pmWell, this is exactly what I mean. If the opamp has a separate supply than its internal current doesn't discharge the battery and there is no error.Give the opamp a slightly higher supply, like 12V perhaps, and all your problems are solved. Or stay with 5V and look for a logic level MOSFET. Or darlington - its base current error will be low (easily <0.1%) due to very high β, except for low currents like a few mA (depends on type) where β decreases.

author: 4kruby
author_rank: Contributor
timestamp: January 20, 2022, 09:59:38 pm
content: Quote from: magic on January 20, 2022, 09:49:42 pmI thought you might be talking about the current consumed by the inverting input terminal of the opamp (which must be very negligible I suppose).Quote from: magic on January 20, 2022, 09:49:42 pmHigher supply it is then. Logic level mosfets are hard to find in place where I live. I am trying to find a solution with the parts I already have.I had one more question though. If we keep the discharge current of the battery to be very less say, below 500mA, will a medium power transistor such as 2n2222 would suffice instead of the mosfet ?The 2n2222 is rated for atleast 600mA continous current and it does not need a heat sink right? - just curious.

author: ledtester
author_rank: Super Contributor
timestamp: January 20, 2022, 11:00:30 pm
content: Quote from: 4kruby on January 20, 2022, 09:59:38 pmYou are still limited by the max power dissipation of the device which for the 2n2222 is 500mW.

author: magic
author_rank: Super Contributor
timestamp: January 20, 2022, 11:06:58 pm
content: A few 2N2222 could be connected in parallel with separate emitter resistors, if you can't find anything in TO220.

author: 4kruby
author_rank: Contributor
timestamp: January 21, 2022, 04:30:08 am
content: Quote from: ledtester on January 20, 2022, 11:00:30 pmI'm sorry if this sounds absurd. But what does that mean? I can't find the junction resistance for the bjt like the mosfet.how does this limit the current draw / operation of the circuit?Quote from: magic on January 20, 2022, 11:06:58 pmI have one in TO-126 package - a D882 :http://www.ps-pfs.com/pdf/DYNATRON/D882.pdf- I think this is also a good candidate. Right?

author: Terry Bites
author_rank: Super Contributor
timestamp: January 21, 2022, 08:41:08 am
content: This kind of current source is prone to AC instabilty. Addd components as shown in this bipolar example.https://www.edn.com/error-compensation-improves-bipolar-current-sinks/You just dont have enough headroom. If you have set the input to 4V the mosfet will have 4V subtracted from its Vgs. G is already at 4V. So the mosfet gate need Vgs +4 V to tun on.

author: magic
author_rank: Super Contributor
timestamp: January 21, 2022, 10:10:20 am
content: Power dissipation is collector-emitter voltage (= battery voltage) times load current (you said: 500mA). So up to 2.1W with a fully charged Li-ion battery. TO126 is OK for 2W with a heatsink.Base current of NPN will cause error because it is measured by the 1Ω resistor but it doesn't come from the battery. Actual discharge current is ~1% lower than 1Ω resistor current (assuming β=100).

author: 4kruby
author_rank: Contributor
timestamp: January 21, 2022, 11:50:03 am
content: Quote from: magic on January 21, 2022, 10:10:20 amI agree since the bjt's are current operated device and base current also will flow through the emitter path. Then if I need accuracy, raising up the supply voltage and using a mosfet is the better choice. The one thing I was considering is the switching frequency of the mosfet. Whether the opamp will be able to cope up with switching the mosfet ON (supplying enough current) at the switching frequency.Quote from: Terry Bites on January 21, 2022, 08:41:08 amI don't quite understand this statement. Do you mean that if the Gate threshold voltage is 4.5v, I need 8.5v to turn on the Mosfet? Can you please explain it?

author: ledtester
author_rank: Super Contributor
timestamp: January 21, 2022, 03:43:09 pm
content: Quote from: 4kruby on January 21, 2022, 11:50:03 amThis is based on your use of a 1 ohm shunt resistor. The MOSFET source is at I*R volts where R is the shunt resistance and the gate needs to be raised above that.

author: 4kruby
author_rank: Contributor
timestamp: January 21, 2022, 04:49:14 pm
content: Quote from: ledtester on January 21, 2022, 03:43:09 pmSo if I understand you correctly, if the current is set to 0.5A, and if the gate threshold Vgs is 4.5 volts, then I have to apply 5v as the source will be at 0.5v right?

author: ledtester
author_rank: Super Contributor
timestamp: January 21, 2022, 04:52:14 pm
content: Yes. Just use a smaller value shunt resistor - like 0.1R or even 0.05R. Then fix things up on the setting side with an appropriate voltage divider.

author: 4kruby
author_rank: Contributor
timestamp: January 21, 2022, 05:18:18 pm
content: Quote from: ledtester on January 21, 2022, 04:52:14 pmThanks. I understand it better now.But I don't have lower value resistors (like 0.1R) - might order them at later point of time.For now, I guess these modifications should work :1. Increase the supply voltage of the opamp to 9v or 12v.2. Determine the current (which should not be changed) - example 1A3. Measure the opamp output and bias the mosfet gate such that it gets 5.5v (4.5 threshold + 1v source voltage).Is the above approach good enough?Thanks.

author: ledtester
author_rank: Super Contributor
timestamp: January 21, 2022, 06:22:01 pm
content: Sounds like a good plan. You can use multiple 1R resistors in parallel to create a lower value resistor.

author: Vovk_Z
author_rank: Super Contributor
timestamp: January 21, 2022, 09:32:37 pm
content: It is fine to have 0.5 Ohm shunt for 0.5 ADC rated current source. It'll give 0.5R*0.5A = 0.25 V voltage, just fine. (And 0.125 W dissipated across it - fine too).So, it is two 1 Ohm resistors in parallel.

author: flowib
author_rank: Contributor
timestamp: January 23, 2022, 05:32:01 am
content: 10PC metal film 1R resistors in parallel will suffice as a shunt, and likely be more accurate as well.Ideally you use something like a LT1010 or LH0002 to isolate the opamp from the mosfet capacitance.The LH0002 internal circuitry is just four resistors and four transistors.I like RFP12N10L for current sources but there are beter fets available, there is the IXTH80N075L2 which is nearly indestructible and designed for this application.

author: magic
author_rank: Super Contributor
timestamp: January 23, 2022, 08:33:27 am
content: You don't need buffers unless for a high bandwidth load. Most simple project isolate the capacitance with a resistor if it becomes a problem and/or use an RC feedback network to stabilize the whole loop.IXTH80N075L2 looks nice on paper but it's too large to be useful: its RthJC is less than 2x its RthCS - you lose 35% of rated dissipation simply by going from Tc=25°C to Ts=25°CGiven its high price, it may be better to parallel a few smaller ones if you need that sort of power.

author: 4kruby
author_rank: Contributor
timestamp: January 23, 2022, 02:16:47 pm
content: Thanks for your replies guys,My knowledge limits my understanding and I need to get some knowledge on the gate capacitance affecting the opampFor starters,I tried the circuit as given in the attachment, and got some results. But not accurate enough.I set the potentiometer to 0.5V.When I measured the current (I measured it from the 1ohm resistor to the ground), I got only 0.4A.Why is there error of 0.1A? Is it due to accuracy of the 1 ohm resistor? or is it something else in the circuit?Also, any improvement in the circuit is welcome.Thanks.

author: ledtester
author_rank: Super Contributor
timestamp: January 23, 2022, 07:14:41 pm
content: Can you provide a link to the Falstad circuit?Also, you should become familiar with LTSpice - it's a much better simulator.https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html

author: 4kruby
author_rank: Contributor
timestamp: January 24, 2022, 05:19:58 am
content: Hi,Thanks. I am planning to learn LTspice.The Falstad circuit is working fine. I just use the interface to draw the circuit to give a snapshot here. However, I tried the same circuit on a solderless prototype board. The circuit in simulator (Falstad) is working fine. However, in reality, it is not.Moreover, I tried to avoid the bias resistors (to the gate of the mosfet) with the same result (I tried this since, the mosfet datasheet says that it's gate can handle +/- 20v and giving a gate voltage of 10v means that the operating region will change - in this case the Drain source can allow more current).I am doubting on the Multimeter probes which I am using to measure the current since when I short the probes in ohmmeter mode, the reading sways between 0.3 to 0.6.I think I have to use the current sensor like the ACS712 model and measure the voltage at its output. By that method, I think we can get a more accurate current right? Because, as per the datasheet of that current sensor IC, it outputs few millivolts for every ampere. But I doubt whether the multimeter can measure such a small voltage.Thanks

author: ledtester
author_rank: Super Contributor
timestamp: January 24, 2022, 06:32:13 am
content: Quote from: 4kruby on January 24, 2022, 05:19:58 amHonestly, I've never seen those bias resistors on this type of circuit.QuoteIt is very possible that your op-amp is oscillating. This circuit generally needs a capacitor between the op-amp output and the inverting input to quash those oscillations. Being able to look at the op-amp output on a scope would be very helpful.This video has some good tips -- you can start at 3:35:Electronic DC Load - Performance Improvements - theBreadboardhttps://youtu.be/rh32ylmlz-A?t=3m35s

author: 4kruby
author_rank: Contributor
timestamp: January 24, 2022, 07:04:16 am
content: Quote from: ledtester on January 24, 2022, 06:32:13 amI am confused. Didn't you mention this inQuote from: ledtester on January 21, 2022, 04:52:14 pmOr is the voltage divider you mentioned here is for the input of the opamp?Quote from: ledtester on January 24, 2022, 06:32:13 amUnfortunately, I don't have a scope. The two basic things I lack are a scope and a bench power supply. What value capacitor can I start with? most probably I should get the anser from the below video I suppose?Quote from: ledtester on January 24, 2022, 06:32:13 amThanks. Let me check the video and see if I get any pointers.

author: ledtester
author_rank: Super Contributor
timestamp: January 24, 2022, 08:26:08 am
content: Quote from: 4kruby on January 24, 2022, 07:04:16 amI meant the input of the op-amp.What I meant by "fixing things up" is that when you change the shunt resistance you'll have to adjust the voltage to the non-inverting input of the op-amp and that can be fixed up with a voltage divider.Usually the voltage presented on the non-inverting input is derived from a stable voltage reference -- like a TL431.This is the video that precedes the one I mentioned:Electronic DC Load Design and Testing -- theBreadboardhttps://youtu.be/vd5IBFFjnOcIt's a little long, but might be worth watching / skipping / browsing through.