Connect with us

Battery Level Monitor

Discussion in 'Electronic Basics' started by Michael, Sep 17, 2006.

Scroll to continue with content
  1. Michael

    Michael Guest


    I'd like to create a 12V battery monitor and interface it to a PICAXE-08M
    running at 3.3V.

    What would be the best way to do this? I was thinking about using a 3.3V reg
    for the picaxe and then use a voltage divider so the changes in voltage can
    be picked up using the onboard ADC.

    Would I be right in assuming the resistor values should be about 10Kohms and


  2. Chris

    Chris Guest

    Hi, Michael. First, your 3.3V power supply does change some things
    (see prior thread, "Interfacing A Pressure Sensor" ). You need a weak pulldown (say, 33K or so)
    resistor at the final output of the LM324 to get the output down to 0V
    (actually 20mV or so). With the pulldown, you're going to be somewhat
    limited as to maximum output voltage -- about 1.5V or so less than the
    + supply. That means you're talking about a maximum output from the
    LM324 of 1.8V. And that means you're throwing away 45% of your counts,
    which might be a problem -- it certainly isn't optimal. If you want to
    stick with the LM324, then set your pairs of gain resistors so that
    maximum output is about 1.8V (i.e. if your maximum sensor output is
    200mV, make it a gain of 9 using 11K and 100K resistor pairs).

    This inexpensive solution should get you better results than the
    initial effort of putting both inputs of the Wheatstone bridge directly
    at the PICAXE inputs. If you want to do better, you'll have to
    consider a rail-to-rail input and output quad op amp like the R-to-R op
    amp like the TLV2374ID, which is out of stock at RS.

    As far as the voltage divider to read battery voltage, you'll have to
    provide more information. Basically, whether your 3.3V is coming off
    the battery voltage or not, you will have to be concerned with the Vin
    at the PICAXE input pin exceeding the voltage at the Vcc pin of the
    PICAXE. It's trivially easy to latch up a uC by exceeding that
    voltage, and you'll have to give that some serious thought.

    If you're working off battery voltage to power your PICAXE (say, with
    an LM317), all you have to worry about is powerup/powerdown sequencing.
    It might be a good idea to use a smaller divider with diode
    protection, and then use the 4th op amp to boost it up, like this (view
    in fixed font or M$ Notepad):
    | VCC
    | +
    | |
    | .-.
    | | |10K
    | | |
    | '-'
    | | ___ |\
    | .---o---|___|--|+\
    | | | 10K | >--o---->
    | | .-. .-|-/ |
    | V | |100 | |/ .-.
    | - | | | | |11K
    | | '-' | | |
    | | | | '-'
    |=== | | |
    |GND === '-------o
    | GND |
    | .-.
    | | |1K
    | | |
    | '-'
    | |
    | ===
    | GND
    (created by AACircuit v1.28.6 beta 04/19/05

    The 100:1 divider cuts your 13.8V down to about .138V. That's not
    enough to cause serious conduction in the diode, but will protect the
    op amp input. Then the 11:1 ratio for the feedback will give a gain of
    12, which will bring your .138V up to 1.65V, adequate to have a good
    handle on the battery voltage. Use a 1N4148 or 1N914 for the diode.
    This may look overly complex, but you're making sure that, under any
    circumstances, the LM324 input isn't seeing more than 0.6V or so, and
    also that the PICAXE input will never see more than Vcc. It's not
    elegant, but it should do, especially for a hobbyist with a limited

    I hope this has been of use.

    Good luck
  3. Michael

    Michael Guest

    Thanks Chris,

    I was thinking that the PICAXE should be run off a regulator, and then use a
    voltage divider for detecting the voltage....Or is that what your getting

  4. Chris

    Chris Guest

    Hi, Mike. You didn't describe the environment in which you're powering
    the PICAXE. It might be possible you're using this in a car, or
    something else.

    The point is, you want to try to make things so you don't exceed the
    maximum input voltage at any pin. This is particularly important with
    microcontrollers, where the reverse current can cause mysterious
    glitches which might crash the uC program, even if it doesn't damage

    If you're monitoring an external battery, and your regulator is getting
    power from that battery, you'll have a problem at turn-on, when the
    full 12V is present, but the regulated output voltage is ramping up.
    This may only be a millisecond or so, but it's enough to cause

    Let's assume a 12V battery is hooked up to your voltage divider with
    the PICAXE unpowered. As your PICAXE is powered up, your series
    resistance might prevent latchup (a destructive condition common to
    CMOS where reverse currents caused by a low impedance voltage at a pin
    above or below the power rails causes a destructive SCR effect).

    However, it might cause unintended effects on the uC chip which prevent
    a normal reset or reliable operation. Better to be safe. Especially
    if you're cost is only an LM324, a couple of more resistors, and a
    protection diode.

    Good luck
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day