Operational Amplifier for Current Sense - Page 1
Forum section: electronics / projects

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 01:26:20 pm
content: I want to design a high side current sense amplifier with the following specificationsLoad Current: 2A (Maximum)Load Voltage: 5V (DC)Sense Resistor: 50 mΩI want to use an op-amp in my inventory with the following specifications for the job.Supply Voltage: 1.6 to 6.0VRail-to-Rail: Input/OutputCommon-Mode Input Range: VSS–0.3V to VDD+0.3VInput Offset Voltage: ± 5mvThe Op-Amp in question is MCP6232https://www.microchip.com/wwwproducts/en/MCP6232Will MCP6232 fit the requirement?

author: Andree Henkel
author_rank: Regular Contributor
timestamp: May 05, 2021, 01:55:18 pm
content: better use a dedicated current sense amplifier like:https://www.ti.com/product/INA180

author: Marco
author_rank: Super Contributor
timestamp: May 05, 2021, 01:56:37 pm
content: It can work, but dealing with the offset voltage will be a bit of a pain.You probably don't want the offset to clamp to zero, so you need to get a bit tricky, for instance connect a 1k resistor to the sense resistor and pull 5mA through it and use the resulting voltage offset by 5mV instead, the offset in current then goes from 0-200 mA (but the drift is much smaller, so you can correct for this).Taking that into account and with a opamp+PNP high side current sense configuration, yes it can work.PS. 1k * 5m = 5m? I need sleep.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 02:05:03 pm
content: Quote from: Andree Henkel on May 05, 2021, 01:55:18 pmOf course I could have done that. I am exploring the possibility of making use of the op-amp's I have in stock and learning few tricks in the process.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 02:12:30 pm
content: Quote from: Marco on May 05, 2021, 01:56:37 pmThanks for the suggestion. I will explore.Quote from: Marco on May 05, 2021, 01:56:37 pmI am not looking for a perfect solution. I am trying to build the best possible solution with the given op-amp.

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2021, 02:16:21 pm
content: What are the accuracy requirements? You have an op-amp with an offset voltage of up to 5mV, measuring a voltage of up to 100mV, so the tolerance will be ±5mV, assuming a unity gain. The offset will be multiplied by the gain, so if it's 40, to give 4V at full range, then it will be ±200mV. Note that this is irrespective of the input current. If the current is zero and the offset is 5mV, the output will be 200mV, whilst if the offset is -5mV, the output will be zero, for currents below 100mA, as it can't be negative, without a dual power supply.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 02:28:31 pm
content: Quote from: Zero999 on May 05, 2021, 02:16:21 pmThis is for measuring the charge/discharge current in a battery charger. So, I can live with lower accuracy.What are the pitfalls of taking a reading with no load (or known load as suggested by @Marco) and use the same to correct the output with load?Here is the diagram of charge circuit I am using.

author: voltsandjolts
author_rank: Unknown
timestamp: May 05, 2021, 02:49:11 pm
content: Quote from: girishv on May 05, 2021, 02:28:31 pmIf that is the application, why not just use low-side current sensing, which is much simpler?

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2021, 03:02:35 pm
content: Quote from: girishv on May 05, 2021, 02:28:31 pmI'm not sure what you're asking. It looks like you replied, as I was edting my post. Read it again to check you've not missed anything.Basically the error will be equal to the offset, multiplied by the gain, whatever the input current is. Obviously the output voltage can't go below zero, assuming it's run off a single rail, so if the offset is negative, the output voltage will be near 0V, until the input voltage exceeds the offset.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 03:14:42 pm
content: Quote from: Zero999 on May 05, 2021, 03:02:35 pmAs suggested by @Marco, What if I used a resistor to draw a current through sense resistor to make sure there is always a drop of 5mv?

author: Marco
author_rank: Super Contributor
timestamp: May 05, 2021, 03:26:13 pm
content: Better to pull it through a separate higher value resistor which just branches off, requires less current/power.

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2021, 03:27:46 pm
content: Quote from: girishv on May 05, 2021, 03:14:42 pmBecause the offset voltage can be anywhere in between +5mV and -5mV.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 03:42:54 pm
content: Quote from: Zero999 on May 05, 2021, 03:27:46 pmI am trying to learn and understand the limitations of using op-amp for current sense applications. I could always use an op-amp with lower offset or even switch to a current sense amplifier. But, I want to see if I can do with op-amp in question.As suggested by @Marco in his last post, I could use a higher value resistor and add to sense voltage and ensure the output stays positive?

author: Marco
author_rank: Super Contributor
timestamp: May 05, 2021, 04:07:26 pm
content: I mean something like this.

author: girishv
author_rank: Regular Contributor
timestamp: May 05, 2021, 05:36:29 pm
content: Quote from: Marco on May 05, 2021, 04:07:26 pmThank you very much. If you have got time, could you post a note describing the circuit? It would very educative for uninitiated people like me.

author: schmitt trigger
author_rank: Super Contributor
timestamp: May 05, 2021, 06:03:10 pm
content: If you would like to educate yourself about current sensing, a very worthwhile endeavor in my opinion, please download App Note 105 “Current Sense Circuit Collection”, from the analog.com website.It is 118 pages of pure current sensing joy, with every every conceivable permutation: picoamps to amps, high side and low side, AC or DC, high speed, high voltage, negative voltage, unidirectional or bidirectional.Something that will keep your brain working for a long time.

author: exe
author_rank: Unknown
timestamp: May 05, 2021, 06:20:32 pm
content: "Input Offset Voltage: ± 5mv" -- that's imho too much for current sensing. There are many opamps trimmed to better than 1mV offset.What's your full-scale output voltage? (ie voltage when battery drains/charges at 2A).

author: SuzyC
author_rank: Frequent Contributor
timestamp: May 05, 2021, 07:44:47 pm
content: If you can correct your readings (Errors will be most evident only at low charge currents), the opamp you have will work perfectly fine.What you are doing with the output of the opamp is what which will make sense of your current sensing.

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2021, 08:46:05 pm
content: Quote from: Marco on May 05, 2021, 04:07:26 pmThat will only work if the offset voltage is known, which isn't the case. It might be +4mV, 1mV, -5mV etc. What happens if it's negative? Your circuit would've just made it worse. In the real world, that current source would need to be trimmable and capable of positive, as well as negative currents.

author: Marco
author_rank: Super Contributor
timestamp: May 05, 2021, 10:44:09 pm
content: It's is intended to make it worse, just unipolar. It fixes the potential clamping to 0, handling the offset is for a downstream circuit or software.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 12:04:52 am
content: Quote from: exe on May 05, 2021, 06:20:32 pmFull scale output voltage will be 3V. The output is fed to ADC of an MCU operating at 3.3V.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 12:20:55 am
content: Quote from: SuzyC on May 05, 2021, 07:44:47 pmI wanted to explore the possibility of using the output of current sense amplifier to control the duty cycle of charge/discharge.I come from applications/software domain and have very little knowledge in analog electronics. I was hoping to correct the error in software using the reading with no load. The discussion in this thread is highlighting the limitations of an op-amp with large offset voltage.

author: Marco
author_rank: Super Contributor
timestamp: May 06, 2021, 12:51:15 am
content: With software, pure offset isn't a problem as long as it doesn't decrease dynamic range of the ADC too much. With full scale being 2A and max offset 200 mA (with a circuit like I posted and a 50 mOhm shunt) that's only 10% of the dynamic range ... that's not too bad.It's the drift you've got to worry about, but 60 uA per degree Celsius doesn't seem a problem to me.There can be good reason to just use a jelly bean opamp with a PMOS or PNP transistor instead of a specialized current sense amplifier BTW. You might have a spare opamp in a multichannel package for instance, or because it's cheaper and good enough.The true downside of going discrete is that you can run into problems which the designers of the integrated solution already solved for you. For instance stability wise the circuit"Is Not So Simple". Although as the article concludes in the end, a 100 Ohm gate resistor will likely do fine ... in this case because the opamp is a very low power opamp, I'm not sure the gate resistor is even necessary though, the Rmatch in the circuit they give certainly isn't necessary here.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 01:25:50 am
content: Quote from: Marco on May 06, 2021, 12:51:15 amThank you very much for the link. I will read through the document.Furthermore, I am grateful to everyone for sharing their knowledge through this thread. I am sure whoever reads this thread in future will be as thankful as I am.

author: exe
author_rank: Unknown
timestamp: May 06, 2021, 06:54:50 am
content: Quote from: Marco on May 06, 2021, 12:51:15 am10% is horrible if you ask me. Although, chances are that the actual opamp is much better than 5mV. For one-off circuit it's also possible to just select an opamp with the best offset.The maximum supply voltage is only 7V, which is too low for my liking. I'd would use something with more voltage headroom to account for potential problems, such as user mistakes.Question to OP: do you already have MCP6232 or you only plan to buy it? If you didn't buy, I'd suggest buy something else. I think such applications are perfect for zero-drift opamps, what do you guys think?

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 07:29:52 am
content: Quote from: exe on May 06, 2021, 06:54:50 amThe charge circuit is expect to be connected to a mobile charger delivering 5V/3A.Yes. I do have few dozen MCP6232. If this does not work, I can substitute with another op-amp with maximum 200µV offset at input.Edit:Fixed the typo from 200µA to 200µV

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 07:46:01 am
content: Quote from: Marco on May 05, 2021, 10:44:09 pmThat makes sense. It just threw me because microcontrollers weren't mentioned at that point in the thread.Quote from: exe on May 06, 2021, 06:54:50 amThe idea is to callibarate out the offset. When the current is known to be zero, the microcontroller can take a sample, which is stored and subtracted from all subsequent readings. With Marco's circuit, the offset will range from 0 to 10mV, rather than ±5mV, so there's no problem with the op-amp having to output negative voltages and a single power supply can be used.Quote from: girishv on May 06, 2021, 07:29:52 amSorry, I don't understand the question. 200µA is massive for an offset current. Are you sure you're not talking about the supply current?

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 08:47:47 am
content: Quote from: Zero999 on May 06, 2021, 07:46:01 amMy mistake. It was supposed to be 200µV. Fixed the post.

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 10:59:14 am
content: Quote from: girishv on May 06, 2021, 08:47:47 amWhat are the other requirements?There are many op-amps which meet, or better that, but they probably completely unsuitable. For example the OP07 is cheap and has a much lower offset voltage, than 200µV, but it would require a -2V power supply and possibly +7V (depending on how it's configured) in your application. There's the LMP7732, which works of 5V, is very low noise, but it has a fairly high power supply current of up to nearly 8mA.

author: exe
author_rank: Unknown
timestamp: May 06, 2021, 11:27:53 am
content: Quote from: Zero999 on May 06, 2021, 07:46:01 amAh, I think I got it. His circuit always draws at least 5mA. But this offset can be nulled in software. That's smart. But then we need a stable current sink. Well, if we are not chasing PPMs here, probably tl431 will do the job.

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 11:33:32 am
content: Quote from: exe on May 06, 2021, 11:27:53 amYes, but note, that the initial accuracy is unimportant, as it's compensated for, during the callibration. Stability is more important, than accuracy/tolerance.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 12:09:12 pm
content: Quote from: Zero999 on May 06, 2021, 10:59:14 amI do have few other devices in stock which will fit the bill. Trying to use MCP6232 is an exercise to dig into analog electronics

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 12:16:15 pm
content: Quote from: exe on May 06, 2021, 11:27:53 amHow do we build a stable current sink?Even before I built a circuit, I learnt a lot from this discussion.

author: exe
author_rank: Unknown
timestamp: May 06, 2021, 12:25:42 pm
content: Quote from: girishv on May 06, 2021, 12:16:15 pmWhat analog parts do you have?PS for low-side current sensing opa189 looks like a good candidate to me if one can ensure its minimum supply voltage (4.5V). But it's kinda expensive. May be overkill for this application. But with low-side sensing one doesn't need a stable current sink.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 12:49:26 pm
content: Quote from: exe on May 06, 2021, 12:25:42 pmYes. OPA189 is kind of expensive. I remember paying about $2 each when I bought them for building a discrete instrumentation amplifier.I have few other analog parts. I have various linear regulators including couple of LDO's.I have LDO TPS70933DBVT (3.3V 150-mA, 30-V, 1-µA IQ Voltage Regulators with Enable). Probably I can use this as constant current source?I have precision shunt voltage reference TS4061BILT-1.225 (1.225V 0.2%). Another constant current source candidate?

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 01:04:34 pm
content: Quote from: girishv on May 06, 2021, 12:16:15 pmI'd recommend the REF200, as a current sink. It won't do 5mA, but a if R1 in Marco's circuit is changed to 100R, it will give an offset of 5mV, with a current of 50µA, which the REF200 can do without any external components.The INA821 and MCP6N16-010 are much better options than the MCP6232.

author: exe
author_rank: Unknown
timestamp: May 06, 2021, 01:15:04 pm
content: Quote from: girishv on May 06, 2021, 12:49:26 pmThe first part implies 3.3V drop, which is a bit too much. Also, it, in theory, needs output capacitor for stability, although I checked a few mos ldos in the past as current sources, they worked fine without capacitors. You can try... Just check with the oscilloscope that it doesn't oscillate. Also, such ldos are not very precise and often drift a lot with temperature. But, again, that's probably fine for a prototype.As of the two-terminal shunt voltage reference, it'll probably require extra parts to become a current source sink (like an opamp). I can't think of a simple circuit to turn it into a floating current sink. May be others will help here.With inamps be careful with limitations of common voltage and output voltage swing. Check the datasheet carefully, or verify performance in a simulator.PS ref200 is expensive, imho, unless bought from a questionable source.

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 02:07:58 pm
content: Yes, the REF200 is expensive, but very easy to use, as it doesn't need any external components.An LDO with a low quiescent current will also work. The voltage drop is a non-issue, as the power supply volage is 5V and only 5mV needs to be dropped across the resistor.The LM334 is cheap, but it has a positive temperature coefficient, so use the circuit on page 8, figure 15 of the data sheet. It's porbably better to aim for a lower current, than 5mA though, to minimise the temperature drift, as the LM334 will get slightly warmer than the compensation diode.https://www.ti.com/lit/gpn/lm334Here's a circuit I did awhile ago. It will nominally output slightly more than 50µA.

author: Marco
author_rank: Super Contributor
timestamp: May 06, 2021, 02:41:31 pm
content: I'd just use a simple current mirror with a resistor from the 5V or logic rail to set the current, this isn't meant to be very precise.

author: gnuarm
author_rank: Super Contributor
timestamp: May 06, 2021, 03:14:50 pm
content: Quote from: girishv on May 06, 2021, 12:16:15 pmI realize this is a learning exercise for you. So here is something to learn. It is important to not over design. The current you are talking about is to correct a small error, so the error that can be tolerated in this circuit is much larger.I would use a simple BJT with resistors to configure the currents. The resistor in the emitter leg would set the current in the collector from a voltage on the base set by two resistors as a voltage divider. This can be set pretty accurately as it mostly depends on intrinsic properties of semiconductors and resistor tolerances. It has issues with temperature stability which you need to figure out the importance of. For an offset bias it should be just fine.How exactly are you going to establish the offset of your resulting circuit? Will there be a "factory" calibration that is done exactly once? Or will the device calibrate at power up? Or maybe on some periodic basis? Those are important questions to determine how useful the offset calibration will be. I know this is just a learning experience, but these are important things to learn about.

author: Zero999
author_rank: Super Contributor
timestamp: May 06, 2021, 03:37:41 pm
content: If the current can be dropped to zero often enough, to recalibrate it, the drift is less of an issue.If the power supply voltage is stable enough, just use a resistor. It will affect the gain slightly, but that's easilly compensated for. If you can measure the supply voltage, with another ADC input, then it can be compensated for, but it would need a decent enough reference.

author: coppice
author_rank: Super Contributor
timestamp: May 06, 2021, 03:46:51 pm
content: When choosing electronics for shunt resistor current sensing think carefully about its CMRR spec, and how much common mode voltage you might see in the worst case in your design. It often gets missed in initial selections, but can really bite when the prototypes are found to perform very poorly.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 06, 2021, 03:52:14 pm
content: One thing you can do is put a small P-channel MOSfet on the output of your opamp (Or a darlington) and also add a resistor between your positive supply voltage and the Fet, and then use the opamp to make a current mirror.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 04:42:14 pm
content: Quote from: gnuarm on May 06, 2021, 03:14:50 pmThe goal is to compensate for the offset at software level. But, we need to ensure that there is no negative offset at op-amp level as is operating on single supply. Further, the design allows for measurement of output at the start of every cycle (1Hz frequency / 60-65% duty cycle) with no load. The no load measurement will be used to correct the subsequent measurements captured with load.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 04:48:05 pm
content: Quote from: Zero999 on May 06, 2021, 03:37:41 pmI have 1.225V/0.2% precision shunt voltage reference which can be used as reference for ADC.

author: exe
author_rank: Unknown
timestamp: May 06, 2021, 05:25:41 pm
content: I'd start with measuring the actual offset of opamps. 5mV is the worst case, it's probably much better than that.

author: gnuarm
author_rank: Super Contributor
timestamp: May 06, 2021, 05:30:02 pm
content: Quote from: girishv on May 06, 2021, 04:42:14 pmOk, then a cal on every 1 sec cycle means you don't need to worry about temperature drift in the bias current at all really.

author: girishv
author_rank: Regular Contributor
timestamp: May 06, 2021, 05:43:10 pm
content: Quote from: gnuarm on May 06, 2021, 05:30:02 pmYes. The load is switched with discrete buck converter controlled by micro operating at low frequency allowing for calibration at the start of every cycle. I have posted a diagram earlier in this thread.

author: gnuarm
author_rank: Super Contributor
timestamp: May 06, 2021, 06:04:33 pm
content: Quote from: girishv on May 06, 2021, 05:43:10 pmThat diagram looks like a buck switching regulator. At which point are you planning to measure current exactly? At the input or output of the pFET? That's the only point in the circuit that will be zero current in the cycle. Also, that cycle would normally be some 10's of kHz or higher. Make sure your circuit won't have problems with response time.Maybe I don't really know what you are doing. You talk about 1 second period for measuring, but show a circuit that would normally be cycled at 50 kHz or faster.

author: uer166
author_rank: Super Contributor
timestamp: May 10, 2021, 08:19:31 pm
content: Quote from: schmitt trigger on May 05, 2021, 06:03:10 pmI found that document pretty disappointing, it's more of a competition regarding how many AD/LT parts can one use unnecessarily. Combined with some bad advice like using a freewheel diode on power relays it's not a very practical/useful doc. I wish there was more info and analysis regarding normal current sense configurations and the pitfalls like offsets, common mode ranges, opamps entering/exiting saturation, instead of 1000 ridiculous circuits.