Using ADC to measure battery voltage

Discussion in 'Embedded Systems and Microcontrollers' started by Chacabucogod, Jul 13, 2015.

  1. Chacabucogod

    Thread Starter New Member

    Nov 16, 2013
    26
    1
    Hi,

    I'm developing a gadget with a PIC18 and I would like to have the amount of charge that is left on the battery(LI-ion) that is charging it. My initial thought was to use the ADC to measure the battery's voltage, but since the ADC uses that same voltage as reference it wouldn't work at all. How is charge measured in a battery normally?

    Thank you
     
  2. be80be

    Senior Member

    Jul 5, 2008
    431
    57
    There are pic18 that can do what you want with just the ADC they use a regulated programmable voltage for the ADC.
    You set this for say 2.5 volts. have to check the data sheet I'm using 2.5 as example.
    So the ADC can only read 0 to 2.5 you use a voltage divider to let the ADC read the battery voltage and your ADC will read it.

    This can also be done with a zener diode to feed the ADC reference on chips too both work as long as the voltage is higher then the reference.
     
    Chacabucogod likes this.
  3. Chacabucogod

    Thread Starter New Member

    Nov 16, 2013
    26
    1
    I don't really get it. Let's say I have a zener diode connected to the ADC's port. What if the battery's voltage go below 5.0 volts, which is the desired voltage I'd like to keep?The zener diode wouldn't mantain it, as far as I understand. Do you know if the PIC18F4550 supports that regulated programmable ADC you are talking about?I checked thet datasheet, and it doesn't mention it at all. Do you have a name or number of pic that does have it?

    Thank you
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    All you need is a reference voltage well below the normal battery voltage so the ref is still active as the battery is dead.

    Any PIC that can use an external reference for the A2D can do this.

    Many PICs have an internal reference for the A2D and can also do this by itself.
     
    Chacabucogod likes this.
  5. be80be

    Senior Member

    Jul 5, 2008
    431
    57
    Use a 3 volt zener on AN3 and set that to be used as reference then use voltage divider on AN0 to scale 0 to 3 to AN0 and what your highest battery reading could be you cant input higher then the reference voltage so you scale it down to the 3 volt and with a little math you output the battery reading.
     
    Chacabucogod likes this.
  6. Chacabucogod

    Thread Starter New Member

    Nov 16, 2013
    26
    1
    All right I get it. Thank you all.
     
    be80be likes this.
  7. MachineHum

    Member

    Nov 3, 2014
    70
    4
    Keep in mind charge vs. voltage for Li-ion battery isn't linear

    [​IMG]
     
Loading...