EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: girishv on May 05, 2021, 01:26:20 pm

Title: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 01:26:20 pm
I want to design a high side current sense amplifier with the following specifications

Load 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.0V
Rail-to-Rail: Input/Output
Common-Mode Input Range: VSS –0.3V to VDD +0.3V
Input Offset Voltage: ± 5mv

The Op-Amp in question is MCP6232

https://www.microchip.com/wwwproducts/en/MCP6232 (https://www.microchip.com/wwwproducts/en/MCP6232)

Will MCP6232 fit the requirement?
Title: Re: Operational Amplifier for Current Sense
Post by: Andree Henkel on May 05, 2021, 01:55:18 pm
better use a dedicated current sense amplifier like: https://www.ti.com/product/INA180 (https://www.ti.com/product/INA180)
Title: Re: Operational Amplifier for Current Sense
Post by: Marco on May 05, 2021, 01:56:37 pm
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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 02:05:03 pm
better use a dedicated current sense amplifier like: https://www.ti.com/product/INA180 (https://www.ti.com/product/INA180)
Of 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 02:12:30 pm
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).
Thanks for the suggestion. I will explore.

Taking that into account and with a opamp+PNP high side current sense configuration, yes it can work.
I am not looking for a perfect solution. I am trying to build the best possible solution with the given op-amp.

Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 on May 05, 2021, 02:16:21 pm
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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 02:28:31 pm
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 5±mV, 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, which could be zero and the output might still be up to 200mV.
This 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.



Title: Re: Operational Amplifier for Current Sense
Post by: voltsandjolts on May 05, 2021, 02:49:11 pm
This is for measuring the charge/discharge current in a battery charger.

If that is the application, why not just use low-side current sensing, which is much simpler?
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 on May 05, 2021, 03:02:35 pm
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 5±mV, 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, which could be zero and the output might still be up to 200mV.
This 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.
I'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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 03:14:42 pm
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.

As 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?
Title: Re: Operational Amplifier for Current Sense
Post by: Marco on May 05, 2021, 03:26:13 pm
Better to pull it through a separate higher value resistor which just branches off, requires less current/power.
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 on May 05, 2021, 03:27:46 pm
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.

As 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?
Because the offset voltage can be anywhere in between +5mV and -5mV.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 03:42:54 pm
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.

As 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?
Because the offset voltage can be anywhere in between +5mV and -5mV.
I 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?
Title: Re: Operational Amplifier for Current Sense
Post by: Marco on May 05, 2021, 04:07:26 pm
I mean something like this.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 05, 2021, 05:36:29 pm
I mean something like this.
Thank 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.
Title: Re: Operational Amplifier for Current Sense
Post by: schmitt trigger on May 05, 2021, 06:03:10 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe on May 05, 2021, 06:20:32 pm
"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).
Title: Re: Operational Amplifier for Current Sense
Post by: SuzyC on May 05, 2021, 07:44:47 pm
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.

 
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 on May 05, 2021, 08:46:05 pm
I mean something like this.
That 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Marco on May 05, 2021, 10:44:09 pm
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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 06, 2021, 12:04:52 am
"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).
Full scale output voltage will be 3V. The output is fed to ADC of an MCU operating at 3.3V.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 06, 2021, 12:20:55 am
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.
I 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Marco on May 06, 2021, 12:51:15 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.

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" (http://techtime.news/2018/05/09/analog-design-tip/). 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv on May 06, 2021, 01:25:50 am

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" (http://techtime.news/2018/05/09/analog-design-tip/). 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.
Thank 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe on May 06, 2021, 06:54:50 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?
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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?
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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

Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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?
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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 (https://www.ti.com/lit/gpn/lm334)

Here's a circuit I did awhile ago. It will nominally output slightly more than 50µA.
(https://www.eevblog.com/forum/projects/operational-amplifier-for-current-sense/?action=dlattach;attach=1217288;image)
Title: Re: Operational Amplifier for Current Sense
Post by: Marco 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.
Title: Re: Operational Amplifier for Current Sense
Post by: gnuarm 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Zero999 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.
Title: Re: Operational Amplifier for Current Sense
Post by: coppice 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.
Title: Re: Operational Amplifier for Current Sense
Post by: Doctorandus_P 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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.
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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.
Title: Re: Operational Amplifier for Current Sense
Post by: exe 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.
Title: Re: Operational Amplifier for Current Sense
Post by: gnuarm 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. 
Title: Re: Operational Amplifier for Current Sense
Post by: girishv 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.
Title: Re: Operational Amplifier for Current Sense
Post by: gnuarm 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. 
Title: Re: Operational Amplifier for Current Sense
Post by: uer166 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.