how to detect a low battery condition

Discussion in 'Embedded Systems and Microcontrollers' started by strontium, Dec 20, 2010.

  1. strontium

    strontium Thread Starter New Member

    Joined:
    Apr 6, 2009
    Messages:
    3
    Hi, i need help detecting a low battery situation. I want to power a small system with a 9V battery but using a 5V regulator. However I want to know how can I detect the battery low condition using a micro controller, so that when it is detected I can turn on a LED to let the user know he should change the battery.

    I found out that some PICs come with a HLVD, but I am not sure if I must include a constant power supply that wont degrade to compare it with, or if everything is done internally and I don't have to include anything else.

    In case I were to use a PIC without HLVD, how would you recommend doing it?

    Thanks
  2. thatoneguy

    thatoneguy AAC Fanatic!

    Joined:
    Feb 19, 2009
    Messages:
    6,356
    Location:
    Midwest USA
    Use one ADC port and measure off a 50% precision voltage divider (two 500k 1% in series). When the battery goes below 1.3V/Cell (7.8V), that will give a bit of warning, you could cut off at 8V (4V sensed, variable). "Dead" is around 7V on most 9V cells, and they decline quick near the end.

    One measurement at the top of the main program loop or other continually called function when no other pressing needs are happening is plenty. If it spends a lot of time in sleep, a long timer can wake it up to update the voltage if this is for a long term idle application.

    I'd suggest AA batteries and a 3.3V LDO regulator if the rest of your circuit can work with 3.3V. 3AAs will last quite a bit longer than 1 9V, and the size difference is small.
    strontium likes this.
  3. AlexR

    AlexR Well-Known Member

    Joined:
    Jan 16, 2008
    Messages:
    735
    Location:
    Australia (UTC+10)
    The HLVD feature won't help you in this case. The voltage reg will keep the supply constant till the battery voltage falls below the regulator drop-out level and then the regulator will drop out leaving you with a dead circuit.
    You could use a PIC and its AtoD converter but that seems a massive overkill just to light a low-battery indicator LED. The simplest way to do it would be to use a voltage comparator, either on a PIC or simpler still a stand-alone comparator chip such as a LM311. The LM311 will work of 5Volt and you can feed the reference input through a voltage divider across the regulated supply and the sense input from a voltage divider that is across the battery.
    strontium likes this.
  4. strontium

    strontium Thread Starter New Member

    Joined:
    Apr 6, 2009
    Messages:
    3
    Thanks, ill let you know how it works out. I'll be using a PIC 16F690, which has 2 built in comparators and an operational voltage range from 2-5.5V. Ill be using 3 AAs with an adjustable voltage regulator. To what voltage would you guys recommend me adjusting the regulator? When do you think would be appropriate to issue the battery low warning (i guess it should be somewhere above the regulator's dropout voltage)? Thatoneguy, you mentioned dead for the 9V batteries is around 7V, do you know the dead voltage for the AAs?

    Thanks
  5. spinnaker

    spinnaker Senior Member

    Joined:
    Oct 29, 2009
    Messages:
    3,687
    Location:
    Pittsburgh, PA U.S.A.

    There is no need to regulate the power to the PIC if you are using 3 AAA batteries. As you know, your operating range of the PIC is 2-5.5V.

    Is the regulator being used for something else? If so just put a voltage divider before the regulator and have the PIC read that voltage. That way you can turn on your led well before the regulator drops out.
    strontium likes this.
  6. strontium

    strontium Thread Starter New Member

    Joined:
    Apr 6, 2009
    Messages:
    3
    :eek: Wow, you're totally right! My bad jajaj
  7. Arm_n_Legs

    Arm_n_Legs Active Member

    Joined:
    Mar 7, 2007
    Messages:
    183
    Location:
    Singapore
    Simply use a low voltage detector chip like the STM1061
Similar Threads
Forum Title Date
Embedded Systems and Microcontrollers Using a microcontroller as period counter and speed detector Aug 4, 2014
Embedded Systems and Microcontrollers AVR Zero Cross Detection and AC Light dimmer Jul 8, 2014
Embedded Systems and Microcontrollers PIC- Detect switch rising edge Mar 14, 2014
Embedded Systems and Microcontrollers AC powerline monioring, zerro crossing detection Mar 6, 2014
Embedded Systems and Microcontrollers Simple way to detect when somebody passes by? Jan 20, 2014

Share This Page