Author Topic: Operational Amplifier for Current Sense  (Read 5735 times)

0 Members and 1 Guest are viewing this topic.

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #25 on: May 06, 2021, 07:29:52 am »
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.

10% 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?
The 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
« Last Edit: May 06, 2021, 08:50:39 am by girishv »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #26 on: May 06, 2021, 07:46:01 am »
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.
That makes sense. It just threw me because microcontrollers weren't mentioned at that point in the thread.

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.

10% 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?
The 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.

The 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µA offset.
Sorry, 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?
 
The following users thanked this post: girishv

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #27 on: May 06, 2021, 08:47:47 am »
Sorry, 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?
My mistake. It was supposed to be 200µV. Fixed the post.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #28 on: May 06, 2021, 10:59:14 am »
Sorry, 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?
My mistake. It was supposed to be 200µV. Fixed the post.
What 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.
 

Online exe

  • Supporter
  • ****
  • Posts: 2559
  • Country: nl
  • self-educated hobbyist
Re: Operational Amplifier for Current Sense
« Reply #29 on: May 06, 2021, 11:27:53 am »
The 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.

Ah, 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.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #30 on: May 06, 2021, 11:33:32 am »
The 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.

Ah, 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.
Yes, but note, that the initial accuracy is unimportant, as it's compensated for, during the callibration. Stability is more important, than accuracy/tolerance.
 

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #31 on: May 06, 2021, 12:09:12 pm »
Sorry, 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?
My mistake. It was supposed to be 200µV. Fixed the post.
What 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.
I do have few other devices in stock which will fit the bill. Trying to use MCP6232 is an exercise to dig into analog electronics

 

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #32 on: May 06, 2021, 12:16:15 pm »
The 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.

Ah, 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.
How do we build a stable current sink? ;D Even before I built a circuit, I learnt a lot from this discussion.
 

Online exe

  • Supporter
  • ****
  • Posts: 2559
  • Country: nl
  • self-educated hobbyist
Re: Operational Amplifier for Current Sense
« Reply #33 on: May 06, 2021, 12:25:42 pm »
How do we build a stable current sink? ;D Even before I built a circuit, I learnt a lot from this discussion.

What 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.
 

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #34 on: May 06, 2021, 12:49:26 pm »
How do we build a stable current sink? ;D Even before I built a circuit, I learnt a lot from this discussion.

What 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.

Yes. 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?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #35 on: May 06, 2021, 01:04:34 pm »
The 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.

Ah, 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.
How do we build a stable current sink? ;D Even before I built a circuit, I learnt a lot from this discussion.
I'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.
 
The following users thanked this post: girishv

Online exe

  • Supporter
  • ****
  • Posts: 2559
  • Country: nl
  • self-educated hobbyist
Re: Operational Amplifier for Current Sense
« Reply #36 on: May 06, 2021, 01:15:04 pm »
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?

The 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.
 
The following users thanked this post: girishv

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #37 on: May 06, 2021, 02:07:58 pm »
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/lm334

Here's a circuit I did awhile ago. It will nominally output slightly more than 50µA.
 

Online Marco

  • Super Contributor
  • ***
  • Posts: 6692
  • Country: nl
Re: Operational Amplifier for Current Sense
« Reply #38 on: May 06, 2021, 02:41:31 pm »
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.
 
The following users thanked this post: girishv

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2218
  • Country: pr
Re: Operational Amplifier for Current Sense
« Reply #39 on: May 06, 2021, 03:14:50 pm »
The 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.

Ah, 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.
How do we build a stable current sink? ;D Even before I built a circuit, I learnt a lot from this discussion.

I 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.
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19342
  • Country: gb
  • 0999
Re: Operational Amplifier for Current Sense
« Reply #40 on: May 06, 2021, 03:37:41 pm »
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.
 
The following users thanked this post: girishv

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Operational Amplifier for Current Sense
« Reply #41 on: May 06, 2021, 03:46:51 pm »
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.
 
The following users thanked this post: girishv

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3321
  • Country: nl
Re: Operational Amplifier for Current Sense
« Reply #42 on: May 06, 2021, 03:52:14 pm »
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.
 
The following users thanked this post: girishv

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #43 on: May 06, 2021, 04:42:14 pm »
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.
The 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.
 

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #44 on: May 06, 2021, 04:48:05 pm »
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.
I have 1.225V/0.2% precision shunt voltage reference which can be used as reference for ADC.
 

Online exe

  • Supporter
  • ****
  • Posts: 2559
  • Country: nl
  • self-educated hobbyist
Re: Operational Amplifier for Current Sense
« Reply #45 on: May 06, 2021, 05:25:41 pm »
I'd start with measuring the actual offset of opamps. 5mV is the worst case, it's probably much better than that.
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2218
  • Country: pr
Re: Operational Amplifier for Current Sense
« Reply #46 on: May 06, 2021, 05:30:02 pm »
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.
The 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.

Ok, 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. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Offline girishvTopic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Operational Amplifier for Current Sense
« Reply #47 on: May 06, 2021, 05:43:10 pm »
Ok, 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.
Yes. 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.
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2218
  • Country: pr
Re: Operational Amplifier for Current Sense
« Reply #48 on: May 06, 2021, 06:04:33 pm »
Ok, 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.
Yes. 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.

That 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. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Online uer166

  • Frequent Contributor
  • **
  • Posts: 872
  • Country: us
Re: Operational Amplifier for Current Sense
« Reply #49 on: May 10, 2021, 08:19:31 pm »
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.

I 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf