Author Topic: uSupply implementation - problem with current sensing  (Read 15439 times)

0 Members and 1 Guest are viewing this topic.

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
uSupply implementation - problem with current sensing
« on: August 24, 2014, 10:38:23 pm »
Hi there,

First post for me, I take the occasion to thank Dave! Thanks to the videos I understood a lot more about electronics. I'm a computer programmer, and I've been into electronics as a hobby for a little more than a year now, using mainly arduinos and ready to use modules. But I now take more and more interest into understanding the real basics of electronics.

As the videos regarding the uSupply design were really enlightening, I tried to implement a simplified version of it. Got myself an LT3080, an LM334 load... And the voltage regulation works quite well from the filtered PWM of the micro controller.

The problem though, comes from the current sensing circuit, which is actually the most interesting part of the whole design in my beginner view. To test the principle I used a 1R 5W resistor, 4 10k resistors and an LM358. The load I use is a 27R power resistor, in order not to blow anything if the current control doesn't work. None of the used resistors are precision ones, it's just for the sake of proving the design. The 10k resistors pair nicely though. The op amp output is floating (except for the negative feedback).

In my test the LM358 is powered by 12V/GND and the load is powered by the arduino 5V line (to avoid too much power being dissipaded).
If the load is not connected to ground the output is sitting at 0.68V
If the load is connected (and gets warm quick ^^) the voltage drop accross the 1ohm resistor is 160mV according to my measurement, and the opamp output doesn't change a bit.

I tried many combinations, but I can't get the opamp putting its output to 0V or 160mV as expected. Any idea would be welcome (even though I know I will go facepalm if I read that I made a silly mistake :) ).
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
Re: uSupply implementation - problem with current sensing
« Reply #1 on: August 25, 2014, 01:29:26 am »
I tried many combinations, but I can't get the opamp putting its output to 0V or 160mV as expected.
maybe try ALL combinations using automated  spice scripts TI.com: LM358, LM358A PSpice Model (Simulation Models)  without risking  :-BROKE too many chips?
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline mij59

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nl
Re: uSupply implementation - problem with current sensing
« Reply #2 on: August 25, 2014, 04:30:38 am »
Hi,

The LM358 is not a rail to rail opamp, its not designed to sink current at zero volt output.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #3 on: August 25, 2014, 06:19:03 am »
The LM358 output stage is saturating trying to get to 0 volts.  It can sink very little current below about 0.6 volts.  Some operational amplifiers have outputs which will perform better but none will sink current when the output is at their negative power supply potential.

The easiest way to fix this is to bias the ground reference up by 1 or 2 Vbe drops.  I prefer using a different current sense circuit which does not require matched resistors although it will not work with the LM358 either but for a different reason:

http://www.linear.com/solutions/1189
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #4 on: August 25, 2014, 09:37:32 am »
Thanks for your answers  :)

I know the LM358 is not rail to rail, but the datasheet says that it can get its output down to VDD/GND, so I supposed it would work (and it actually outputs down to 0V without the feedback resistor... without current flowing).
So if I get it correctly the current flows through the feedback resistor and cannot get sunk in the op amp output. That current would be 5V/20k = 2.5mA. This would too high for the output at 0V?
I measured different voltages on the inputs of the opamp, that seemed weired as I understood the opamp with a negative feedback had always its input at the same voltage, while in the operational range of course.

Does this mean that Dave's design 3 is not working at all? :) (I tried using the buffer stage as in his design, not knowing what to do to make this work, and I figured by myself that it couldn't work with less than 1.5V drop, i.e. 1.5Amps, which defeats the whole purpose,  but I thought the rest of the design could work ok).

I'll try adding a bias, never done that before so I suppose it's a good exercice as well  ;)

Thanks again.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #5 on: August 25, 2014, 01:38:23 pm »
I know the LM358 is not rail to rail, but the datasheet says that it can get its output down to VDD/GND, so I supposed it would work (and it actually outputs down to 0V without the feedback resistor... without current flowing).
So if I get it correctly the current flows through the feedback resistor and cannot get sunk in the op amp output. That current would be 5V/20k = 2.5mA. This would too high for the output at 0V?

Absolutely it is too high for an LM358 which can only sink 2.5 milliamps down to about 0.9 volts.

Quote
I measured different voltages on the inputs of the opamp, that seemed weired as I understood the opamp with a negative feedback had always its input at the same voltage, while in the operational range of course.

If the output is saturated, then there is no negative feedback.

Quote
Does this mean that Dave's design 3 is not working at all? :) (I tried using the buffer stage as in his design, not knowing what to do to make this work, and I figured by myself that it couldn't work with less than 1.5V drop, i.e. 1.5Amps, which defeats the whole purpose,  but I thought the rest of the design could work ok).

I would need to see the original design.

Quote
I'll try adding a bias, never done that before so I suppose it's a good exercice as well  ;)

I would add a pair of diodes in series with the ground connection to the lower 10k resistor and use that point as a virtual ground.  Another option is to add a current sink to the output of the operational amplifier but that will not be possible (*) without a negative supply in which case that could be used directly anyway.  There are better amplifiers which can get closer to to their negative supply but none will sink current at 0 volts.

(*) There are a couple of ways to do this without a negative supply but they amount to making a negative supply anyway.
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #6 on: August 25, 2014, 04:56:40 pm »
Quote
I would need to see the original design.

It can be found here : http://www.eevblog.com/projects/usupply/
The revision C is the one using LM358 opamps. I thought it was a good choice for me as I have some of them lying around (and the other opamp used in rev A and B are low voltage apparently - I'm planning to use a 24V power supply).

Quote

I would add a pair of diodes in series with the ground connection to the lower 10k resistor and use that point as a virtual ground.  Another option is to add a current sink to the output of the operational amplifier but that will not be possible (*) without a negative supply in which case that could be used directly anyway.  There are better amplifiers which can get closer to to their negative supply but none will sink current at 0 volts.

(*) There are a couple of ways to do this without a negative supply but they amount to making a negative supply anyway.

Thanks for the tip. The words make sense but I'm not sure I see how to implement this... Does the joined schematics correspond to your description? If I use a pair of silicon diodes it would increase the bottom reference of the lower 10k resistor (gnd) point by 2x0.6V, so 1.2V. That would make my reference signal 3.7V instead of 2.5V. Am I correct? And then to use this result I should use another way to sustract the 1.2V when using the output value?  :-//
BTW how is that different from changing the 10k/10k ratio to get the proper reference to 2.5V? The response from the opamp seems linear in either way from the LTSPICE simulation I just ran, but maybe I got it wrong at some point...
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #7 on: August 25, 2014, 05:18:49 pm »
Quote
I would need to see the original design.

It can be found here : http://www.eevblog.com/projects/usupply/
The revision C is the one using LM358 opamps. I thought it was a good choice for me as I have some of them lying around (and the other opamp used in rev A and B are low voltage apparently - I'm planning to use a 24V power supply).

The LM358 is a fine operational amplifier.  It just has to be applied correctly.

It looks to me like the design shown in the revision C schematic has some problems.  The common mode input range of U12A is violated and U12B has the same problem with the output saturating close to the negative supply.  My guess is that it works because it is only intended to measure and limit high currents (great than 1 amp) where those issues are not a problem.

Quote
Quote
I would add a pair of diodes in series with the ground connection to the lower 10k resistor and use that point as a virtual ground.  Another option is to add a current sink to the output of the operational amplifier but that will not be possible (*) without a negative supply in which case that could be used directly anyway.  There are better amplifiers which can get closer to to their negative supply but none will sink current at 0 volts.

(*) There are a couple of ways to do this without a negative supply but they amount to making a negative supply anyway.

Thanks for the tip. The words make sense but I'm not sure I see how to implement this... Does the joined schematics correspond to your description? If I use a pair of silicon diodes it would increase the bottom reference of the lower 10k resistor (gnd) point by 2x0.6V, so 1.2V. That would make my reference signal 3.7V instead of 2.5V. Am I correct? And then to use this result I should use another way to sustract the 1.2V when using the output value?  :-//
BTW how is that different from changing the 10k/10k ratio to get the proper reference to 2.5V? The response from the opamp seems linear in either way from the LTSPICE simulation I just ran, but maybe I got it wrong at some point...

That is correct but the junction between the upper diode and the lower resistor becomes the virtual ground for the output so the 1.2 volt change does not alter the output when measured from that point.  This is inconvenient if you wanted a singled ended output referenced to the negative supply which is ground in this case but if you can make that virtual ground which is about 1.2 volts above the negative supply your output signal ground, then it is an easy way to solve a lot of problems.

The alternative is to find a negative supply voltage for the operational amplifier or use a circuit like the one I linked although it requires an operational amplifier with an input common mode range that includes the positive supply which the LM358 is not.  Designers used to use the ancient LM301 for that but today there are lots of choices.
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #8 on: August 25, 2014, 06:44:46 pm »
It looks to me like the design shown in the revision C schematic has some problems.  The common mode input range of U12A is violated and U12B has the same problem with the output saturating close to the negative supply.  My guess is that it works because it is only intended to measure and limit high currents (great than 1 amp) where those issues are not a problem.

From what I saw in another subject the U12A case was signaled and Dave acknowledged it. It was a long time ago, I don't know if the project is still ongoing. Maybe he changed his specs during design between rev B and C but it seemed to me that he intended to reach quite a fine precision in all parts of his design, with a 1mA precision on the limiter and a 1A maximum for the output current (maximum for the LT3080, although 2 could be used in parallel).

Quote
That is correct but the junction between the upper diode and the lower resistor becomes the virtual ground for the output so the 1.2 volt change does not alter the output when measured from that point.  This is inconvenient if you wanted a singled ended output referenced to the negative supply which is ground in this case but if you can make that virtual ground which is about 1.2 volts above the negative supply your output signal ground, then it is an easy way to solve a lot of problems.

The alternative is to find a negative supply voltage for the operational amplifier or use a circuit like the one I linked although it requires an operational amplifier with an input common mode range that includes the positive supply which the LM358 is not.  Designers used to use the ancient LM301 for that but today there are lots of choices.

Got it. Thanks a lot. I'll try to include this virtual ground in my design, don't know yet how to use it to limit the current using a comparator and an NPN but I will think of it a bit.

Best regards
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #9 on: August 26, 2014, 05:05:07 pm »
Okay, I tried to find how to deal with the virtual gnd according to the initial specs : 0 to 1V from the uControler (using a filtered PWM and voltage divider) equals 0 to 1A limitation.
If I don't want to deal with the virtual ground in software I have, I assume, to add the virtual ground to the signal from the uControler.
So adding an opamp in summer configuration should do the trick.

Here is what I came to with LTSPICE. I suppose it works properly from the different values tried (the comparator would drive an NPN to take the regulator's SET pin to ground). The bottom voltage source represents the Set voltage from the micro controler.

I'm going to try this on breadboard. But I'm curious to know if my solution is the right one or if there is a more direct/obvious way to deal with it?

« Last Edit: August 26, 2014, 05:10:33 pm by mat_fr »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3614
  • Country: gb
Re: uSupply implementation - problem with current sensing
« Reply #10 on: August 26, 2014, 09:12:13 pm »
Creating a virtual ground is a perfectly acceptable way of doing things if you don't have a negative supply handy.  However, forwards biased silicon diodes don't make good voltage references in practice due to their relatively high dynamic impedance at low currents and their temperature sensitivity (though fine for a quick proof of concept).  A proper bandgap voltage reference would be a much better solution for your final design, even something very cheap like a TL431 would give far better stability than two forward biased silicon diodes.

Note that raising the zero current voltage will reduce your available resolution if you are planning to hook an ADC up to the op-amp.

The other option is to create a negative supply using e.g. a flying capacitor switcher, which are cheap and fairly easy to use.  They can be quite electrically noisy though, especially when hooked up on a breadboard so bear that in mind.
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #11 on: August 26, 2014, 09:41:08 pm »
I have an LM385Z-2.5 available for this project, I suppose that would do.
But with the diodes even if the virtual ground change slightly (I had 1.06V on my breadboard test), the goal is to add the same value to the signal from the micro, isn't it? In that case no matter if it's not hyper stable, or am I missing something?

I tested it on breadboard and the output of the adder, once connected to the comparator, doesn't go lower than 1.20V instead of the expected 1.06 (virtual ground+0). I don't understand why, it seemed rather accurate before plugin it into the comparator. I suppose there is an interaction between the opamps/feedbacks...

« Last Edit: August 26, 2014, 09:58:03 pm by mat_fr »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3614
  • Country: gb
Re: uSupply implementation - problem with current sensing
« Reply #12 on: August 26, 2014, 10:01:30 pm »
I have an LM385Z-2.5 available for this project, I suppose that would do.
But even if the virtual ground change slightly (I had 1.06V on my breadboard test), the goal is to add the same value to the signal from the micro, isn't it? In that case no matter if it's not hyper stable, or am I missing something?

In terms of the actual current control, providing your the set-point voltage has the same offset as the feedback value then yes, it doesn't matter if it varies.  However, if you are monitoring the current with an ADC that uses a separate voltage reference, then clearly any change in your virtual ground will cause inaccuracy in the monitored value. 
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #13 on: August 26, 2014, 10:10:55 pm »
Ideally the signal is processed relative to the new virtual ground so the change in common mode voltage do to the diodes is irrelevant.  An ADC with differential input can do that automatically with a minimum of performance loss.

If a comparator or error amplifier is used, then any reference voltage is setup relative to the virtual ground instead of the negative supply so again, drift cancels out.

Maybe you would be better off using an operational amplifier which can operate linearly closer to the negative supply.  That will not get you to zero but you can get closer to the negative supply than the LM358 can.

 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #14 on: August 26, 2014, 10:58:48 pm »
I hear you both, thanks for your advices.
Concerning another op amp which would get closer to its negative supply I'm a little lost, as I thought that the LM358 was capable of doing so. What spec am I looking for to be certain the op amp is right for my usage?
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
Re: uSupply implementation - problem with current sensing
« Reply #15 on: August 27, 2014, 09:50:40 am »
However, if you are monitoring the current with an ADC that uses a separate voltage reference, then clearly any change in your virtual ground will cause inaccuracy in the monitored value.
Why not to use the same external voltage reference on AVref MCU pin?
Only unsure which is minimum possible external VRef eg. on AVR MCUs-used to use TL431I between 2.495V and 4.20V on ATTiny85 AVR's.

Update: AVR ATTiny85 for example has AVref in range minimum: 2.0V to Vcc (172-175p of its full datasheet), so it can be a trap if someone tries to use lower external reference voltage than allowed for given MCU  ::)
« Last Edit: August 27, 2014, 10:07:57 am by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline Kevin.D

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: england
Re: uSupply implementation - problem with current sensing
« Reply #16 on: August 27, 2014, 09:57:32 am »
Hi there,



In my test the LM358 is powered by 12V/GND and the load is powered by the arduino 5V line (to avoid too much power being dissipaded).
If the load is not connected to ground the output is sitting at 0.68V
If the load is connected (and gets warm quick ^^) the voltage drop accross the 1ohm resistor is 160mV according to my measurement, and the opamp output doesn't change a bit.

I tried many combinations, but I can't get the opamp putting its output to 0V or 160mV as expected. Any idea would be welcome (even though I know I will go facepalm if I read that I made a silly mistake :) ).

I dont know what data sheet you and others have been looking at but the data sheets I have for lm358 , all specify Output Voltage swing
 V(ol) = 5mV typ to 20mV max thats with a 10k load on the output .

So seems like you have a broken opamp.Are your two supplies sharing a common gnd ?.  What does the output go down to if you pull the + input down to gnd .?
It should go down to at least 20mV max with your 10k load.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #17 on: August 27, 2014, 01:19:40 pm »
For a better operational amplifier you want one where the negative output voltage saturates closer to the negative rail.  The LM358 gets to about 0.9 volts at 2.5 milliamps.  An LT1013 which is a direct upgrade gets within about 0.3 volts.  An LT1638 (up to 30 volt supply) or LMC6082 (up to 15 volt supply) will get within about 0.15 volts.  Off hand I do not know of any operational amplifiers which will do better while sinking 2.5 milliamps.

A pull-down resistor on the output of the amplifier will help but not enough to bother using.  A better option would be to increase the value of the feedback resistor so the output sink current requirement is relaxed but this will require a low input bias current amplifier to maintain accuracy which is not a problem.  The alternate high side current sense circuit I linked does even better than this by having no load pulling the output up.

If you want to sink current all the way to zero volts, then a virtual ground or negative supply is needed.
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #18 on: August 27, 2014, 02:20:06 pm »
So seems like you have a broken opamp.
I have a bunch of them actually (some "inherited"from my father, too happy to give me his old thirty years old electronic parts, some got as samples from TI recently), the ones I used seemed to behave the same way but I'd have to make some more tests to be sure.

Quote
Are your two supplies sharing a common gnd ?
Absolutely: both lines come from the Arduino board (Vin <=> 12V and regulated 5V), both share the same ground on the board.
Quote
What does the output go down to if you pull the + input down to gnd?

It should go down to at least 20mV max with your 10k load.
Got to check that out.

For a better operational amplifier you want one where the negative output voltage saturates closer to the negative rail.  The LM358 gets to about 0.9 volts at 2.5 milliamps.  An LT1013 which is a direct upgrade gets within about 0.3 volts.  An LT1638 (up to 30 volt supply) or LMC6082 (up to 15 volt supply) will get within about 0.15 volts.  Off hand I do not know of any operational amplifiers which will do better while sinking 2.5 milliamps.
If you want to sink current all the way to zero volts, then a virtual ground or negative supply is needed.

Ok, I think I will stick with the virtual ground solution if I can get something usefull out of it. I'm doing this as a learning project, so I don't intend to buy too much new components. Beside,  I don't aim an extremely accurate current limit, but I'd like it to be rather low... the way I see it the advantage of a lab supply is to be able to feed a limited amount of current so as not to blow everything up in case of a problem. If 0.3 V corresponds to 300 mA it seems a rather high current already...

BTW I'm still curious about the solution presented in LTSPICE in my message yesterday... Is it the correct solution to add the virtual ground to the input signal using a third op amp or is there a more intelligent solution (without using other fancy parts I mean)?  :)
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 18745
  • Country: us
  • DavidH
Re: uSupply implementation - problem with current sensing
« Reply #19 on: August 27, 2014, 03:05:24 pm »
BTW I'm still curious about the solution presented in LTSPICE in my message yesterday... Is it the correct solution to add the virtual ground to the input signal using a third op amp or is there a more intelligent solution (without using other fancy parts I mean)?  :)

The solution does not require a third operational amplifier.  The output voltage is taken differentially between the signal output and virtual ground instead of the negative supply ground.

In your case that means that any reference and the comparator use the virtual ground as their signal ground which completely solves the problem allowing currents down to zero within the accuracy of the preceding stages.

 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #20 on: August 27, 2014, 04:10:12 pm »
OK that makes sense when reading a voltage from a voltmeter, I take the virtual ground as a reference point, and if reading the value from an ADC (I plan on using the Atmega one, so it's not that obvious how to do it). But if I want to use an opamp to drive the output transistor depending on the target/measure comparison I don't see how else to do it, unless I use the virtual ground as the op amp negative supply, but in that case I will want to output a value equals to the negative supply and the same problem occurs again...

That's why I was searching how to add the virtual ground to the Target value from the micro...
 

Offline Kevin.D

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: england
Re: uSupply implementation - problem with current sensing
« Reply #21 on: August 27, 2014, 04:49:52 pm »
Sorry ,forget what I said my brain is fried today  :=\  .The lm358's are fine .without sinking anything they will get down to V(ol) of course but not whilst sinking  any amount of current  above a few uA  .

For want you want It's prob easier at the end of the day to provide  a  negative rail for your opamps ,since if you want the output to go down to 0 (u didn't say) then you will need one anway for a min load sink etc .
« Last Edit: August 27, 2014, 04:51:48 pm by Kevin.D »
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #22 on: August 27, 2014, 06:22:26 pm »
That would probably be easier, but I was planning on using a 24V DC supply so I suppose a negative rail would be complicated to obtain  :-//

With a virtual ground as the negative supply the opamp used as comparator (without feedback) connected to a NPN should be OK, as nothing would be sunk anyway in case of a 0V output.
But if I supply it with Vin/VirtGND the 0V output will be the virtual ground itself, so I might have a problem with the NPN turning on unexpectedly.

Another problem I have is that my test circuit on breadboard doesn't regulate the current properly, more "shut it down once the limit has been reached". I don't now why but it seems that something is wrong in my "whole feedback" loop...  :-\

Seems to work properly in LTSPICE though...
« Last Edit: August 27, 2014, 10:58:40 pm by mat_fr »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3614
  • Country: gb
Re: uSupply implementation - problem with current sensing
« Reply #23 on: August 28, 2014, 08:43:48 am »
However, if you are monitoring the current with an ADC that uses a separate voltage reference, then clearly any change in your virtual ground will cause inaccuracy in the monitored value.
Why not to use the same external voltage reference on AVref MCU pin?
Only unsure which is minimum possible external VRef eg. on AVR MCUs-used to use TL431I between 2.495V and 4.20V on ATTiny85 AVR's.

Update: AVR ATTiny85 for example has AVref in range minimum: 2.0V to Vcc (172-175p of its full datasheet), so it can be a trap if someone tries to use lower external reference voltage than allowed for given MCU  ::)

It depends entirely on what else the micro is doing.  Using a very poor external reference just to make one of the inputs ratiometric may be ok, but that means you can't make any accurate measurements of values that are not referenced to the horrible virtual ground with the other channels.

Davids suggestion of using an ADC with a differential input is a good idea if it's available, and you could also create pseudo-differential input by measuring the virtual ground with one channel and the current sense value with another channel and subtracting them in the firmware.
 

Offline mat_frTopic starter

  • Contributor
  • Posts: 42
  • Country: fr
Re: uSupply implementation - problem with current sensing
« Reply #24 on: August 28, 2014, 11:15:26 am »
and you could also create pseudo-differential input by measuring the virtual ground with one channel and the current sense value with another channel and subtracting them in the firmware.

That's actually what I had in mind, as I don't have any ADC available but plenty of Analog Channels on the Atmega328. But it prevents me from using a lower voltage reference for AREF, thus reducing the measurement precision (using 2.5V as AREF means 2.5/1024~=2.5mV per bit resolution, but if measuring the virtual ground I have to use the onboard 5V reference which gives a 5mV per bit resolution). No idea how to evaluate the accuracy though.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf