How to detect low battery in battery powered F683 circuit


Closed Thread
Results 1 to 32 of 32
  1. #1
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81

    Default How to detect low battery in battery powered F683 circuit

    I do a lot of battery powered designs with li-po (3.7v) batteries - mostly using 8 pin chips like the F683. I am trying to figure out if there is a way to use an AD input - or comparator configuration to determine if the battery that is powering the chip is running low. A threshold of 3.2 V would be good. A resistor divider connected to the A/D input will not work because it will always read the resistor ratio voltage as a constant value as the battery voltage changes. I have been fooling around with a zener diode/resistor combination with no luck. I don't have any experience using the comparators inside PICs and wonder if there is some way to configure a comparator to detect a low battery threshold. Does anyone have an elegant solution for detecting a low battery condition? In my current design I only have AN0 available for battery sensing on the F683.

    I really need a very low part count/low cost solution! No external comparators or circuits, is this practical?
    Last edited by tekart; - 27th October 2014 at 16:52.
    "Do or do not, there is no try" Yoda

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Hello

    This might give you some ideas

    http://ww1.microchip.com/downloads/e...Doc/41215C.pdf

  3. #3
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Yes, I saw that but the best circuit (on p.8) uses an external comparator. Not sure if that can be implemented with the INTERNAL one?
    "Do or do not, there is no try" Yoda

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Why not? It will work.
    But you can only use R3 and D1 connected to ADC pin.
    Put Vdd as reference, take sample voltage, and, for larger Vdd ADC result will be lower, and for lower Vdd result will bi higher.

  5. #5
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    I don't see how this is any different from putting a resistor divider on the ADC input. The problem is that the divided voltage will track Vdd and the A/D reading will always represent the resistor divider ratio (or resistor/diode drop ratio) and thus will maintain a consistent reading despite changing Vdd. Am I missing something here?
    "Do or do not, there is no try" Yoda

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Hey, where I was mention voltage divider???
    Quote Originally Posted by pedja089
    But you can only use R3 and D1 connected to ADC pin.
    That isn't voltage divider.
    Biased D1 will produce almost constant voltage on ADC input pin. By keeping constant voltage on ADC input, and changing reference voltage(Vdd)
    Quote Originally Posted by pedja089
    for larger Vdd ADC result will be lower, and for lower Vdd result will bi higher.
    At least try to read response when you ask for help. That is all from me...

  7. #7
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Sorry pedja089,
    I am having trouble understanding your very terse sentence. I would appreciate it if you could elaborate what you mean by this
    Quote Originally Posted by pedja089 View Post
    Put Vdd as reference, take sample voltage, and, for larger Vdd ADC result will be lower, and for lower Vdd result will bi higher.
    As I understand it, my A/D reading will always be defined by the voltage drop of the diode forward voltage drop and so will not change. Remember I only have the one A/D input to work with in my very simple circuit.
    "Do or do not, there is no try" Yoda

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by tekart View Post
    Remember I only have the one A/D input to work with in my very simple circuit.
    In that case you need a pic12f1822 or similar with an internal vref. The internal vref will work with the adc or comparator module.

  9. #9
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Connect one end of diode to ground, other to pic input and pull up resistor. Just like in schematic on page 8.
    They suggesting to connect diode to ground thru mosfet to minimize current consumption. When mosfet is turned on, there is about 0,6V on pic input, and that voltage won't change.
    You do not need to use mosfet, you can connect diode to ground permanently, or connect to output pin.

  10. #10
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by mark_s View Post
    In that case you need a pic12f1822 or similar with an internal vref. The internal vref will work with the adc or comparator module.
    OK, now that is helpful. I was not aware of an 8-pin chip with all those features and at a good price too! Now I'll just have to learn how to configure the internal Vref to get the results I need. Another slog through data sheets that can take hours!
    "Do or do not, there is no try" Yoda

  11. #11
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by pedja089 View Post
    Connect one end of diode to ground, other to pic input and pull up resistor. Just like in schematic on page 8.
    They suggesting to connect diode to ground thru mosfet to minimize current consumption. When mosfet is turned on, there is about 0,6V on pic input, and that voltage won't change.
    You do not need to use mosfet, you can connect diode to ground permanently, or connect to output pin.
    Yeah, I get the hardware side now - but how to implement this on the F683 with no Vref and one A/D? Am I missing something?
    "Do or do not, there is no try" Yoda

  12. #12
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    You are missing...
    There is Vref on every pic with ADC.
    http://ww1.microchip.com/downloads/e...oc/41211d_.pdf Page 63 Bit VCFG(bit 6 of ADCON0)

  13. #13
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    OK, I see that now. So how do I select between the IO pin and the Vref source in code? No idea how that is done...
    Still don't see how the resistor - diod junction will provide me with a reading that represents the changing Vbatt...
    Last edited by tekart; - 27th October 2014 at 20:11.
    "Do or do not, there is no try" Yoda

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    I think the confusion between you and pedja089. The first way you need two external pins from the ADC or comparator.
    One of the pins is tied to an external vref source and the other is your analog input. There is no voltage reference in the 683
    VCFG bit or ADCON0.6 either connects the ADC vref(input) to VDD internally or connects it to and external (pin) reference you provide. .
    The second way only one external pin is needed. (pic12F1822) has an internal reference diode which can be configured to be the vref source for the adc or comparator.

  15. #15
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Mark, thank you for clarifying. I thought it was something like that but my inexperience with internal voltage references left me confused. I have ordered some F1822 chips to experiment with.

    So would you mind clarifying for me how I would go about using the single pin to take advantage of the internal reference diode. Do I understand correctly that this diode would replace the external diode we have been discussing, so all I would need is a pull-up resistor on the ADC pin? I still don't see how that would give me a reading that would very since I would still just be reading the voltage drop of the reference diode. Forgive me for being dense about this but I still don't get it.
    "Do or do not, there is no try" Yoda

  16. #16


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Your battery positive will be connected thru a 1K resistor to the adc, you may need a divider if v battery is greater than VDD? Then you take a normal acin reading and determine what number between 0 - 1024
    equals a low battery. If an < x then low_bat. else..

    To start

    Fixed voltage reference FVR page 137

    ADCIN will take care of the ADCON0 register

    FVRCON = %10000001 ' vref enabled 1.024v
    ADCON1 = %11110011 'Right just,FRC,+vref connected to FVR

  17. #17
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Hi;
    The 12f1840 as Internal voltage reference ( Fixed Voltage Reference (FVR) with 1.024V, 2.048V and 4.096V output levels )
    Thanks and Regards;
    Gadelhas

  18. #18
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Thanks guys! Now I completely understand what I need to do and this solution will work extremely well for me. I have ordered some sample chips and will dig into this later in the week. I appreciate your help and patience.
    "Do or do not, there is no try" Yoda

  19. #19


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Hi Tekart,
    Do you have PBP3 ? I believe you will need it to use the 12F1822 or any xxF1xxx part.

  20. #20
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by Dick Ivers View Post
    Hi Tekart,
    Do you have PBP3 ? I believe you will need it to use the 12F1822 or any xxF1xxx part.
    Of course! Been using PIC Basic for over 14 years! Early adopter that came over from Basic Stamps. - thanks for checking though
    "Do or do not, there is no try" Yoda

  21. #21


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Maybe this will help. A while back we needed a low battery warning for a circuit that was already in production so it had to be done in reverse. The PIC was powered by a 6V battery with a diode to drop it to 5.4V. A jumper from an ADC pin was attached to a 3.3V regulator already on another section of the circuit board. Now as the battery voltage drops, the ADC result will rise, since the 255 reference will always be the battery voltage. The lower the battery voltage the higher the 3.3V ADC reading becomes.

  22. #22
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    That is what I was suggested, just to to use diode instead of regulator...

  23. #23
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by mark_s View Post
    FVRCON = %10000001 ' vref enabled 1.024v
    ADCON1 = %11110011 'Right just,FRC,+vref connected to FVR
    Mark, thanks for the very helpful configuration settings. I got a test chip working fine using 8-bit reads and left justified results. I am in a similar position to peterdeco1 in that I have a circuit board designed for production and ready to go into volume assembly. Fortunately I already had two resistors connected to the A/D input creating a voltage divider so I am good to go - except for one minor problem. My test code works on the F683 chip just fine but when I try to implement it on my actual design I find that I do not have proper digital I/O on PortA.5 for some reason. My design uses portA.0 for the analog input and portA.2 for PWM out. I am struggling with what configuration error I have that is preventing portA.5 from operating as a digital output. I have been poring over the datasheet for an hour or so now and can't seem to find a configuration that seems to be setting that into something other than digital I/O. Any help would be appreciated.
    "Do or do not, there is no try" Yoda

  24. #24


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    These "enhanced" pics don't use the GPIO like the old ones. Use porta.5 to read
    and lata.5 to write. See page 13 and page 121 of the data sheet


    Add: See Hecklers code and configs
    http://www.picbasic.co.uk/forum/show...ght=pic12f1822
    Last edited by mark_s; - 30th October 2014 at 20:19.

  25. #25
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Wow. Thanks Mark - I missed that. I just HATE all these whiz bang "features" that force us mere mortal coders to spend *days* learning a new chip! Grrrr. <end rant>
    SO to implement a pin as output only I use:
    GreenLED var lata.1 ' high = light power LED
    and also set:
    ' config
    TRISa = %011001 ' set I/O directions (0 = output, 1 = input)
    LATa = %011001

    - still not getting it to work with above settings. Do I have bit polarity right for LATA?
    "Do or do not, there is no try" Yoda

  26. #26


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    I think you would declare your variable as

    GreenLED var PORTA.1

  27. #27
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Quote Originally Posted by mark_s View Post
    I think you would declare your variable as
    GreenLED var PORTA.1
    Been testing that and the compiler seems to accept either
    GreenLED var PORTA.1
    or
    GreenLED var LATA.1
    "Do or do not, there is no try" Yoda

  28. #28


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    At this point without posting your complete code it's hard to guess what's wrong.

  29. #29
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    Got all the OUTPUTS working fine - no need for LATA configurations apparently. Struggling with some kind of hardware bug - so I'm basically good. No idea how or why I would configure LATA at this point as it all seems to work fine without any direct reference to it.
    "Do or do not, there is no try" Yoda

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


    Did you find this post helpful? Yes | No

    Default MICROCHIP's an1072

    Maybe this application note from MICROCHIP can help ;-)
    Roger

  31. #31


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    I did this a long time ago with a 6V circuit. The pic was running from the battery (with a series diode = 5.4V) but there was a 3.3V regulator elsewhere on the circuit board. I ran a jumper wire from an ADC pin to the 3.3V reference voltage. As the battery voltage begins to drop, the ADC reading will begin to rise. When the ADC reading reached the desired point, the SOUND command alerted you.

  32. #32


    Did you find this post helpful? Yes | No

    Default Re: How to detect low battery in battery powered F683 circuit

    I just realized I posted the above last October.

Similar Threads

  1. How can a battery powered PIC turn itself off?
    By tekart in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th August 2012, 11:44
  2. Replies: 13
    Last Post: - 22nd January 2012, 05:48
  3. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 08:12
  4. 12F683 battery powered remote - energy consumption question
    By silentwol in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th April 2007, 14:23
  5. Battery Powered Need Help!
    By scottl in forum Off Topic
    Replies: 1
    Last Post: - 29th March 2006, 10:52

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