• AVR Freaks

Hot!ADC conversion when the VDD is not fixed

Author
arslan43711
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2020/08/28 12:12:03
  • Location: 0
  • Status: offline
2020/10/29 22:44:26 (permalink)
0

ADC conversion when the VDD is not fixed

Hi, Hopefully you are doing good. 
I am working on a project in which I have to measure the battery voltage(fully charged 5V and discharged voltage are 2.5V), I am using pic16f688. I have connected the battery pin to one of the analog pin. So ADC read 1023 all the time whatever the voltage is. I mean when the VDD is 3.3v it gives 1023 and when it 5v it gives 1023.  I know there is no fixed voltage reference in the pic16f688.
Is there any solution to this? or a way with which I measure the battery voltage while the PIC is connected to the same battery.

Attached Image(s)

#1

5 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6792
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: ADC conversion when the VDD is not fixed 2020/10/30 07:46:40 (permalink)
    0
    Maybe you could provide a voltage reference rather than using VDD.
    Something like https://www.microchip.com/wwwproducts/en/MCP1525
    #2
    BroadwellConsultingInc
    Super Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2020/06/09 06:07:55
    • Location: 0
    • Status: offline
    Re: ADC conversion when the VDD is not fixed 2020/10/30 08:02:50 (permalink)
    +3 (3)
    Or switch to the microchip recommended replacement PIC16F18325.  It has a fixed voltage reference.  By measuring the fixed voltage you can infer Vdd.
     
    Are you building one of these or many?  If this is a one-off hobby project that will be used at a consistent temperature you could also use a resistor and a diode.  Use a GPIO pin to turn on the voltage, measure the voltage across the diode, then turn it back off.  You'll want to use a 5k or less resistor to limit input impedance to the ADC sampling cap.  You can measure the voltage across your diode under different battery conditions to characterize it.
    post edited by BroadwellConsultingInc - 2020/10/30 08:08:09
    #3
    Mysil
    Super Member
    • Total Posts : 3946
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: ADC conversion when the VDD is not fixed 2020/10/30 08:28:56 (permalink)
    +3 (3)
    Hi,
    Or you may make your own comparision using one or two ordinary diodes in series,
    and a pull-up resistor (10 kOhm) to Vdd,
    The diodes connected such that they conduct current in the forward direction to Vss.
    Measure the voltage at top of the diodes at connection to pull-up resistor.
    With ordinary ADC voltage measurement at this point,
    and Vref voltage still at Vdd, ADC measurement will be higher, when battery voltage is falling.
     
    You may do some math, and some calibration to determine  voltage from the battery.
    The result will be influenced by temperature also.
     
        Mysil
     
    #4
    upand_at_them
    Super Member
    • Total Posts : 739
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: online
    Re: ADC conversion when the VDD is not fixed 2020/10/30 13:10:23 (permalink)
    0
    arslan43711I have connected the battery pin to one of the analog pin. So ADC read 1023 all the time whatever the voltage is. I mean when the VDD is 3.3v it gives 1023 and when it 5v it gives 1023.  I know there is no fixed voltage reference in the pic16f688.

     
    So why do you expect anything different?  In order to not give you 1023 it has to be compared to something else, right?  What do you want to compare it to?
     
    Read section 8.1.3 of the datasheet over and over again until it convinces you to buy a different (modern!) PIC.
    post edited by upand_at_them - 2020/10/30 19:52:27
    #5
    arslan43711
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2020/08/28 12:12:03
    • Location: 0
    • Status: offline
    Re: ADC conversion when the VDD is not fixed 2020/10/31 11:08:22 (permalink)
    0 (2)
    I have selected this because this is available in the local market. There is no other reason,  I have selected the other micro-controller before posting this. I have posted this to get the idea of what might be the other options.
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5