1. OCAU Merchandise now available! Check out our 20th Anniversary Mugs, Classic Logo Shirts and much more! Discussion here.
    Dismiss Notice

LM324 to isolate ground voltage for 5V Analog input MCU?

Discussion in 'Electronics & Electrics' started by Soarer GT, Jul 20, 2014.

  1. Soarer GT

    Soarer GT Member

    Joined:
    Sep 26, 2007
    Messages:
    2,813
    Location:
    Melbourne
    Hi Everyone,

    Hopefully someone with a bit more experience on linear op-amps can help me here.

    The problem is the controller I have has common ground across all the analog inputs but I want to measure the "voltage difference" between multiple points in a battery bank circuit. To do this, I need to isolate the source voltage and match it to the 5v analog input. The source voltage across all the points is below 5V which is what the analog controller can read.

    eg:
    <-- Gnd
    Battery here < 5v
    <-- measure voltage here for analog input 0. This is gnd for analog input 1.
    Battery here < 5v
    <-- measure voltage here for analog input 1. This is gnd for analog input 2.
    Battery here <5v
    <-- measure voltage here for analog input 2.
    And so on for 21 batteries (21S)

    Obviously the easy way is to do a simple voltage divider. The problem with this is the resolution decreases in line with the number of batteries you have. Needs to be within 0.03 resolution.

    I've been doing a bit of research and it seems I need a linear Op Amp on each battery input to isolate the ground and just feed the differential voltage to the analog input of the mcu.

    In comes the LM324 (Quad linear op amp) : http://www.jaycar.com.au/products_uploaded/ZL3324.pdf

    I think I need to use the "Non-inverting DC Gain" schematic (Page 9) or the "Voltage Follower" so that the input voltage matches the output voltage. Which one of these Is this the right schematic?

    As mentioned, the Vin (to chip) is 5V and I want to measure a range of 3-5V on the inputs.

    Is there a better linear op amp I should be looking at?

    Thanks in advance!
     
  2. Technics

    Technics Member

    Joined:
    Apr 29, 2002
    Messages:
    2,015
    Location:
    Brisbane, AU
    Neither of those is correct. One will amplify the voltage between the input and ground and the other will buffer the voltage between the input and ground (I.e amplify with the gain of 1). You want to measure the difference between two voltages that are both above the ground of your ADC.

    They show the classic differential amplifier at the bottom right of page 13. This circuit would do what exactly what you need (though the resistors must be closely matched for accuracy and good CMRR). Except for one problem. The input common mode voltage range of the op amp.

    In the data-sheet for the LM324 it is specified as (positive supply voltage) - 1.5V. Because you want to reference your voltages to analogue ground of your MCU it's a fair assumption that the negative supply voltage of the op-amp is also tied to the same ground (unless you had something else in mind?). So assuming you were using say 21 Lithium ion cells in series (I don't know what cells you're actually using) with a maximum voltage of 4.2V/cell and that the negative of the pack is tied to ground and you're running the LM324 off of a 32V supply (the absolute maximum rating of the device) then the maximum common made rage is up to (32-1.5V) 30.5V. This means that the maximum number of cells that fit within the common mode rage is (30.5V/4.2V) = 7 cells. For the 8th cell the input is outside the common mode range and the op amp will no longer output the correct voltage for the ADC.

    There are some seriously complicated ways of measuring multi cell packs that involve things like transformers across each cell for isolation. Doing it that way would be expensive, large and heavy. If it were me I'd start by treating it as 3 packs of 7 cells in series and build 3 identical 7-cell sensor boards. Each sensor board would contain the 7 differential amplifiers and a microcontroller to measure each voltage. Each board would have a different ground potential to the others (I.e. the negative of the corresponding 7 series cells) so you would need to use either level shifters (a couple of fets) or opto-isolators (if isolation was required, a good idea for preventing safety issues should a fault occur) but the advantage is that if you were using say a serial output from each board to report the voltage of each cell then you would only need to level shift a single line from each board. So only 3 level shifters/opto-isolators (possibly only two because one board would be referenced to system ground).

    If you were to go that way then the LM324 wouldn't be the best choice. You would want to use an op amp that has a input common mode range that is truly rail to rail such as the LT1367. That way the op amp can be powered off the cells directly and you don't need to come up with a supply that is higher voltage than the pack. Because the LT1367 can run up to 36V you would have enough margin to handle up to 5.14V/per cell without damaging anything. There are probably plenty of other op amps that would work. It was just based on a quick google.
     
  3. RobRoySyd

    RobRoySyd Member

    Joined:
    Jan 24, 2008
    Messages:
    8,162
    Location:
    Sydney
    I'm probably showing my age but the way this very problem used to be solved was with a flying capacitor input.
    In this a capacitor is connected to the voltage to be measured by a set of relay changeover contacts. When the voltage is to be read the relay switches the capacitor from the input to the ADC.
    The advantages of this are complete common mode voltage isolation and one ADC can be used to measure hundreds of analogue inputs.
    On the downside one needs fast reed relays, the right capacitors and it takes time to read the inputs. Not really a problem with batteries though.

    The more modern approach is boards with isolating DC - DC converters and opto-isolators for a serial bus. Here everything floats at the input's common mode voltage.
     
  4. starkers92

    starkers92 Member

    Joined:
    May 12, 2012
    Messages:
    294
    I believe you can buy isolated op-amps :thumbup:
     
  5. Elder

    Elder Member

    Joined:
    May 15, 2004
    Messages:
    1,212
    Location:
    Brisbane
    How cheap do these circuits need to be?

    You can buy specially made op amps that do what Technics is talking about with high CMRR. Basically to increase CMRR significantly what they do is:

    precision voltage divide both inputs -> diff amp -> precision amplify output

    The problem is they'll set you back ~$5ea, and you need plenty of them. You're effectively paying for the internal precision resistors they use to do this very well, and a fairly niche item.

    I imagine isolated op amps mentioned above may be even dearer again though.

    If you need to keep costs down the best balance might be to do your own divide->diff->amp configuration rather than buying one of the specialized IC's (it's still only one op amp in the end - just have to set the resistors right, have a look at the diagrams in the specialized high CMRR diff amps). You're resister matching will need attention and still you will end up with less accuracy and worse CMRR then the specialized ICs but I'm fairly sure you could still easily achieve what you need.
     
  6. OP
    OP
    Soarer GT

    Soarer GT Member

    Joined:
    Sep 26, 2007
    Messages:
    2,813
    Location:
    Melbourne
    Thanks for the help guys. The batteries are LiPo (between 3.7v - 4.2v).

    I wanted to keep the cost to about $50 give or take $10 for this part of the circuit, so I guess my idea is shot for now until something else comes along =(

    Can I just voltage divide each line with diff resistors and do some funky maths on the mcu side?

    eg:
    <-- Gnd for all items :
    A. Battery here < 5v
    <-- measure voltage here for analog input 0. No pull down resisitor as its below 5V
    B. Battery here < 5v
    <-- measure voltage here for analog input 1. One pull down resistor here.
    C. Battery here <5v
    <-- measure voltage here for analog input 2. bigger pull down resistor here.
    And so on for 21 batteries (21S)

    Then do the maths on the mcu side to calculate the vdiff of Battery C by taking the pull down voltage adjusted by the pull down voltage of B? Or is that just going to end in tears later on?

    I had a look at isolation amplifiers and stumbled across the HPCL7840 ~ $2-3 each which isnt too bad :

    http://datasheet.octopart.com/HCPL-7840-000E-Avago-datasheet-9713090.pdf

    The circuit looks more complex than what I'm ready to theory craft with though (I literally hatched this idea last week and spent a few nights learning... I'm not sure I'm good enough to wire up something that complex ).. I thought you could just measure points like with a voltmeter... and read that into the MCU... ANYWAYS....
     
  7. dakiller

    dakiller (Oscillating & Impeding)

    Joined:
    Jun 27, 2001
    Messages:
    8,070
    Location:
    3844
    You're asking for $2 per battery sense circuit, that just isn't going to happen.

    The issue with the resistor dividers is that you won't get the resolution at all at the top of the battery stack. You have 88.2v full and 84v if you go down to 0v on that cell. Resistor dividing by ~17x to get into the 5v range, you only get ~250mV swing in your ADC for your full range battery voltage, and you are effectively wiping off 4 bits of your ADC.

    One idea I had is put a battery gas gauge on each battery (~$3-4 each) and opto-couple ($2-3 each) them onto a main data bus, but you will have to find a protocol that likes being optocoupled, as the protocol to use if you didn't need optocoupling, i2c, probably isn't the easiest to isolate. Further, an IC that can have 21 different addresses is an issue too.
     
  8. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    You can do linear optocoupling, where each battery feeds an optocoupler via a current limiting resistor, or for greater accuracy a dedicated opamp drive. The output of the optocoupler then responds in a well characterised way and you read that with your ADC. It may require some linearisation and calibration, the main issue is it will present a more significant load on the batteries to drive the optocoupler (5 - 20mA). An example designed specifically for this purpose is this: http://www.digikey.com/product-detail/en/IL300/751-1292-5-ND/1731525

    Alternatively you can do a voltage to frequency conversion on each battery and pass that signal though a regular optoisolator (or to save cost even just a coupling capacitor), and count pulses using digital inputs on your micocontroller. E.g. http://www.ti.com/product/lm331. This has the potential to be very low cost as the LM331 can be had for as low as 50c each. Counting pulses on a 10kHz signal should be doable with a 8MHz Arduino, and you should be able to get 1% accuracy or better within 0.1 seconds worth of pulses.
     
    Last edited: Jul 21, 2014
  9. SLATYE

    SLATYE SLATYE, not SLAYTE

    Joined:
    Nov 11, 2002
    Messages:
    26,851
    Location:
    Canberra
    I was looking at this problem a while back. The solution I eventually came up with was a pair of 8-to-1 analogue demultiplexers, which select the + and - inputs of each cell to sample (and leave all other cells disconnected). There's a high-value (10K+) resistor between each cell and the demux (because the demux I picked will handle high voltages as long as the current is limited). One demux output goes to ground, the other goes to the ADC input.

    The advantages are that it's fairly cheap and you can get lots of inputs with few pins (3 pins to select the input channel, 1 pin for the ADC itself). It also neatly solves the resolution problem. The disadvantages are that the battery absolutely must be separated from everything else - you can't use it to power the board while measuring voltage, and you can't use it to power anything else that shares a ground connection.
     
  10. 2xCPU

    2xCPU Member

    Joined:
    Jan 21, 2005
    Messages:
    3,328
    Location:
    Saigon
  11. RobRoySyd

    RobRoySyd Member

    Joined:
    Jan 24, 2008
    Messages:
    8,162
    Location:
    Sydney
    I think that's already been recommended.
    I'm curious to know more about this device than is revealed in the spec sheet.
    Am I correct in assuming that the supply to the input circuit has to be separate and floating from the supply to the output side?

    From the data sheet this device is an ADC that feeds its output through an opto-isolator to a DAC. It's a pity the isolated ADC output is not directly available.
     
  12. OP
    OP
    Soarer GT

    Soarer GT Member

    Joined:
    Sep 26, 2007
    Messages:
    2,813
    Location:
    Melbourne
    I actually thought about this solution as well, however most of the mux units I've looked at have common ground across the inputs (it multiplies inputs but assumes they're all on the same circuit... if that makes sense?) I havent seen one that has separate +ve and -ve. Which demux did you use?

    As for keeping the circuits seperate, as the battery bank I'm measuring is between 50-100V would a DC-DC converter/regulator (100V down to 5V 3A) separate the circuit electrically or does it actually have to be a completely separate battery ?
     
  13. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    You would have to get an isolated DC-DC converter. They are not as common and more expensive.

    Getting one that handles 100V input will be a problem - at that voltage it's effectively a mains power switching topology (rectify mains to high voltage DC, switch though an isolating transformer, then DC-DC convert down to low voltage) and you might be able to cheat by using a US 110V AC switch mode power supply.
     
    Last edited: Jul 22, 2014
  14. OP
    OP
    Soarer GT

    Soarer GT Member

    Joined:
    Sep 26, 2007
    Messages:
    2,813
    Location:
    Melbourne
    Original idea was to use one of the old thinkpad laptop PSU's. regulated 16V out from 240/110V in. I dont think it cares if in voltage is AC or DC since it goes through a rectifier anyway? Then that goes to a iPhone USB adaptor for regulated 5V... Or just plug directly into a iPhone USB 5v adaptor and remove the laptop PSU?

    How do you tell if a power supply/converter is isolated?
     
    Last edited: Jul 22, 2014
  15. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    All mains power supplies should be isolated from neutral / active, it would be very unsafe if they weren't. Some of them have DC minus tied to earth but you wont be using that.
     
  16. bradleyk

    bradleyk Member

    Joined:
    Nov 22, 2009
    Messages:
    247
    Location:
    Brisbane

Share This Page

Advertisement: