Trouble with neg voltages and a single-supply op-amp? Strategy suggestions?

Discussion in 'General Electronics Chat' started by howiemnet, Apr 11, 2012.

  1. howiemnet

    Thread Starter New Member

    Apr 11, 2012
    Short story:
    I have an op-amp with 0v and 12v rails; need to convert (and therefore invert) a 0v to -0.01V voltage to 0v to +5V.

    Longer story:
    I've built a simple solar lighting setup for my home. Car batteries, solar panels, LED lights etc. I want to be able to monitor the currents with an Arduino. (Already got voltage sussed - gives live readings, woo! At least until the Arduino hangs again ;) )

    At it's simplest it looks like this:


    You can see I've added a couple of shunt resistors so I can measure the load and charge currents.

    I added some op-amps (two halves of an LM358) to amplify the millivolts across the shunts up to 0-5v for the Arduino to measure:


    Trouble is, the top half works fine but the bottom doesn't. The load current op-amp gives meaningless readings - usually somewhere near the upper rail voltage (12v).

    I suspect it's because I'm presenting a negative voltage (relative to ground) to a single-supply op-amp, but I don't know how to get round the problem.

    What would be the best strategy to overcome this?

    1. Am I going to have to try and create a dual supply setup just to power the op-amp, even though I only want positive voltages out of it?

    2. Or is there a way to offset the inputs somehow? I'm only interested in measuring the absolute voltage difference, after all.

    3. Or should I use a separate op-amp chip (the two op-amps above are two halves of an LM358) and use the difficult negative voltage as a ground rail on just that chip? (it'd make the general maths work I think, but the output could end up swinging below 0v which could cause problems at the Arduino's ADC...)

    I've read as much as I can, tried swapping the op-amp inputs etc, but I'm really stuck on this. I'm good at digital stuff but analogue ain't my thing (beyond basic V=IR, voltage dividers, decoupling caps etc).

    Any help / suggestions / strategies much appreciated - I've spent ages trying to get this to work but I still feel I'm floundering in the dark.
  2. Wendy


    Mar 24, 2008
  3. StayatHomeElectronics

    Well-Known Member

    Sep 25, 2008
    Try lowering the gain of the opamp to see if that allows you to get a reading. You can always add another stage for additional gain.
    howiemnet likes this.
  4. jimkeith

    Active Member

    Oct 26, 2011
    howiemnet likes this.
  5. MrChips


    Oct 2, 2009
    You can use an ICL7660 or the charge pump on a MAX232 transceiver to generate a negative voltage.
    howiemnet likes this.
  6. ssnyde

    New Member

    Apr 4, 2012
    You have some currents listed in your diagram but since your monitoring them, they clearly vary over time. What is the range that you wish to monitor? This range will determine the value of shunt resistor, required gain, etc. You can solve the input offset issue by reducing the gain (as previous poster mentioned) and increasing the shunt resistor value, so that the measured value dwarfs the input offset. But this depends on the range of values you wish to monitor accurately.

    Also I'm confused that the top half works, this is the one which has a voltage below op-amp ground, right?. The bottom half has no negative voltage, the error is due to the problems already mentioned.

    I personally wouldn't use an op-amp for this, I'd use a high side current shunt monitor, like TI INA138 or related.

    Also, can you overcharge a car battery?
    howiemnet likes this.
  7. howiemnet

    Thread Starter New Member

    Apr 11, 2012
    Wow - thanks for all the pointers!

    I think my confusion came from an idea that both inputs to an op-amp had to be within the supply voltage range. Obviously this is true if you're making a non-inverting amplifier, but for a single-supply inverting amplifier to work at all, of course it's got to be able to accept an input below 0v.

    Just to confirm I've got this right:

    - An op-amp supplied with a single supply of 0v and +12v (say)
    - with gain set at approx 10x (say with an input resistor of 1k and a feedback resistor of 10k)
    - should happily turn a -0.2v input into a +2v output, even though the input is outside the supply voltage range.

    If so, I know where to go from here. Well, I know what to try - reducing gain to test, possibly using a different shunt resistor (or sticking a couple in series so I have a larger voltage to start with)

    I may have got my diagram the wrong way up, sorry! I've swapped wires around so many times now it's probably time to rip it all out the breadboard and remake it....

    Kinda stuck with the components I have at hand for now, but thanks for the suggestion; once a paycheck comes in I may be able to pick up something more suitable for the job :)

    What's not shown on my diagram is the MPPT solar charger that promises it won't overcharge the battery. Not to say it won't, of course.

    Thanks for all the help - very much appreciated, all.
  8. Ron H

    AAC Fanatic!

    Apr 14, 2005
    Do you really have a 250micro-ohm shunt? If so,why such a low value?
  9. howiemnet

    Thread Starter New Member

    Apr 11, 2012
    Yup - it really is (unless my maths have got confused - it's a 50mV @ 200A shunt).

    Only using it because it came with a marine battery monitor I've been using - but after reading the responses in this thread I'm going to swap it out for a larger one. Don't really need to measure anything over 15A. Yet.

    Interestingly, at least to me, the 5 metres of wiring from the monitor to the shunt used two separate wires connected together at one end of the shunt, and a third wire to the other end. I'm imagining that this allows the monitor to measure and remove any losses over the length of wire. Must be essential when you're trying to measure fractions of a millivolt.
  10. Ron H

    AAC Fanatic!

    Apr 14, 2005