Battery monitoring - ever tried AN1072?


Closed Thread
Results 1 to 40 of 57

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default Battery monitoring - ever tried AN1072?

    Hi,

    As some other threads around the forum about battery monitoring, I want to setup a battery monitoring system based on MICROCHIP's AN1072 "Measuring VDD Using the 0.6V Reference".

    In short, it says:
    "To measure VDD, VDD should be selected as the reference to the ADC via VCFG, and the 0.6V reference selected as the input using the channel select bits, CHS<3:0>. A measurement of the 0.6V input is taken with the ADC, and the result represents 0.6 Volts as a percentage of VDD. As VDD increases, the resulting number will decrease and vice versa. This yields a direct “1/x” relationship between V DD and the produced digital value as seen in Equation 1. In short, given a specific VDD, the digital value is always the same. Working backwards, if the digital value is known, VDD may be calculated."

    Name:  2015-09-19 08_51_49-MICROCHIP_AN1072 Measuring VDD using Vref.pdf - [01072A.book] - SumatraPDF.png
Views: 1549
Size:  50.5 KB

    It tells you what you have to do and even how. Now guess: I can't make it work

    I have a circuit using a 16F690 (great! same one as used in the AN!). For the test, the circuit is connected to my variable power-supply so I can simulate a low battery condition (i.e. from 6VDC, I go down to 5,5VDC*).

    According to the AN1072, the ADCON0 register has been set to %10110101.

    Now when I vary the voltage on the power-supply, I get always the same ADC reading (no value change at all).

    What am I doing wrong?

    NB*: Yes, I'm using a LDO voltage regulator so I could use another way to check the battery's condition (i.e. comparator or resistor-divider)...but I want to have a go with the AN1072
    Roger

  2. #2
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Battery monitoring - ever tried AN1072?

    That's the ADCON0 register:
    Name:  2015-09-19 10_18_44-PIC16F690_datasheet.pdf - [41262D.book] - SumatraPDF.png
Views: 1396
Size:  69.7 KB
    Roger

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,390


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    I might have the wrong end of the stick here , but if you have a ldo reg suppling vdd won't you always read the regulated voltage. to read the battery voltage that way requires the battery be connected to vdd directly.

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    Sorry Richard, I don't get what you mean.
    Roger

  5. #5
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    You need to make sure you measure on the input side of the LDO, not the output side. It's job it to keep the voltage constant. You will need a resistor divider to reduce the battery sense voltage to within the range of the PIC. Post the schematic of how you connected the PIC.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    The point is that the AN1072 method measures Vdd as supplied to the 16F690 - it is purely internal. If you want to measure some other voltage, like the battery side of the LDO you need to use a potential divider (for example) and an ADC inputs that accepts an external input.

    George

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    So I'll have to go for this one?

    Name:  2015-09-19 14_40.png
Views: 1235
Size:  19.4 KB
    Roger

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    Thank you George.

    I did unfortunately not understand the AN the way you explain.

    Let's go for a divider then
    Roger

  9. #9
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    better off using higher value resistors to reduce the over all current draw of the voltage divider , but if you have too higher values the current will not be enough for accruate reading but after you do testing you will find the avg voltage range with the resistors used and you can apply that offset to the reading.

    also use the inbuild voltage ref for the ad readings so that when you transfer between various input voltage on differnat pics , the same code and voltage tables can be used for either 10 bit or 12 bit ad cpus

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    the same code and voltage tables....
    Just in case anyone should be put of by mention of tables, the math is real simple - VDD = 6144/Ad_Result (0.6 * 1024 = 614.4 - 10bit - result in 0.1V).

    It will come as no surprise to here that Daryl posted this info.

    George

  11. #11
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    This is how I made it for now

    Vbatt is 6VDC (4x AAA batteries) and VREG is 5VDC (hence, VREG is the reference voltage).

    To measure the batteries, I draw 10mA; this seems to be okay to me - if not okay, please suggest another current I should have.

    Name:  CookTimer_R-Divider-control.png
Views: 1197
Size:  7.1 KB
    Last edited by flotulopex; - 22nd September 2015 at 22:16.
    Roger

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    Roger, as I stated earlier, when the FET is OFF you supply +6 to the PIC pin. This is dangerous!

    Ioannis

  13. #13
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    Wow! I missed that!

    What's the solution then? Shall I go with P-channel MOSFET?
    Last edited by flotulopex; - 23rd September 2015 at 17:44.
    Roger

  14. #14
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    also consider that the voltage drop from a 6v incoming source to your LDR output at 5v /pic is going to give you much margin (.5v at best ) before your looking to have to replace the batteries, no cos they are that low just cos your voltage usage margin is small

    consider running the app at 3.3v , take a closer look at thge items that require the 5v externally to the PIC to look at using devices at 3.3v as this will give a larger usage margin for the batteries and device

    just a thought

  15. #15
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default 3,3VDC or 5VDC?

    After my first tests, I changed my circuit from 3,3VDC to 5VDC hence accepting the "margin" reduction.

    The project I'm working on now is a cooking timer and I have a piezo-sounder that sounds best (= loudest) at pseudo* 10VAC (*I use a full bridge inverter for higher volume).

    BTW, I use a LP2950ACZ5.0 and it's dropout voltage is around 0,2V @ 10mA. 0,8V leave me far enough accuracy to determine when it is time to change the batteries
    Roger

  16. #16
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default ADCIN - how do I select the 0,6V Reference channel?

    I still would like to know how to "read" the 0,6V (VP6) channel. This voltage reference is provided by the PIC itself.

    If I set the ADSCON0 register to (i.e.) %10110100 (right just., VDD, 0,6V Reference, ADC is ON), what is the PICBASIC command to read that channel? If it is ADCIN, then ADCIN what?

    Name:  2015-09-26 18_34_25-Clipboard.png
Views: 975
Size:  49.7 KB

    I tried with:
    Code:
    ADCIN 13, myvar
    because I see channels from 0 to 11 in the DS, maybe "0,6 V ref" would be the 13th...and PBP accepts the compilation but the ADCIN result shows always 0
    Roger

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default Re: ADCIN - how do I select the 0,6V Reference channel?

    ADCIN x, myvar

    where x is the AD channel where you connected the voltage divider we were talking before.

    If it is on pin 18, channel 1 then x=1 and so on.

    Ioannis

  18. #18
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Battery monitoring - ever tried AN1072?

    I'm sorry, but I still don't understand

    Looking at the ADC bloc diagram I've attached in post#1, I understand there is a "0,6V Reference" channel that I have to select to get an ADCIN result of 122 @ 5VDC or 186 @ 3,3VDC.

    This channel doesn't seem to be linked to any pin of the PIC - this is confusing me at most.

    Does this "0,6V Reference" channel really exist?

    ----

    Hum...just found I have to ENABLE the 0,6Voltage Reference in VRCON register, bit 4 "VP6EN". I'll have a try in a moment...
    Last edited by flotulopex; - 26th September 2015 at 20:38.
    Roger

Similar Threads

  1. Battery voltage monitoring for use on 16F1825
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 23rd April 2013, 14:57
  2. Replies: 13
    Last Post: - 22nd January 2012, 04:48
  3. ADCIN car battery monitoring
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th June 2008, 08:04
  4. 12v car battery monitoring
    By oldcarguy85 in forum Schematics
    Replies: 2
    Last Post: - 10th December 2007, 00:26
  5. Using the A/D for Monitoring a Solor Cell and Battery
    By chuck.sieveking in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th July 2004, 19:27

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts