Voltage meassure


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Pedro Pinto's Avatar
    Pedro Pinto Guest

    Default Voltage meassure

    Hello

    I try to meassure the voltage of a lithium 3v Batterie with a PIC 18F4520
    on pin PORTA.0, AN0 trough a 100k serie resistor


    ' Define parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    adval var word ' Create adval to store result
    TRISA.0 = 1 'PORTA.0 as input
    ADCON1 = %10001110 ' PORTA.0 analog and right justify result

    ADCIN 0, adval ' read the chanell 0
    Serout2 tx_485,bmode,["Bat Voltage = ",Dec adval,13,10]

    Like the Define ADCON1 the Ref. is the VDD and that is 5.3V
    The adval result value show 56704, that can't be correct, or?

    What make i wrong?

    Thanks for help

    Best regards

    Pedro

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    What make i wrong?
    answer 1) is in the question ...

    AN0 trough a 100k serie resistor
    Look at the datasheet ... ADC section ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Hello Acetronics

    I want use a 100k serial resistor to reduce the possibility of descharge
    the RTC backup Battery trough the PIC pin over the time.

    About the value that i read in the adval variable, i don´t know if it's correct and how to calculate 3.1 V.

    Regards
    Pedro

  4. #4
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    What if I use higher input resistance (> 2.5kOhm) than Microchip recommends in datasheet?

    "The source impedance affects the offset voltage at the analog input (due to pin leakage current). The maximum recommended impedance for analog sources is 2.5 kΩ. After the analog input channel is selected (changed), the channel must be sampled for at least the minimum acquisition time before starting a conversion."
    Internal leakage is ~100nA.

    So, what if:
    Rs = 100kOhm, V_ain = 5V -> I_in = 50uA
    In this case leakage is 1/500 of input current. Should not affect too much.
    By calculating Tc with 100kOhm I got 19.6uS, total time should be over 21uS

    So, is code below OK or not?
    Code:
    <code><font color="#000000"><b>DEFINE </b>ADC_BITS  8      <font color="#000080"><i>' ADCIN resolution  (Bits)
    </i></font><b>DEFINE </b>ADC_CLOCK 2      <font color="#000080"><i>' ADC clock source  (Fosc/32)
    </i></font><b>DEFINE </b>ADC_SAMPLEUS 500 <font color="#000080"><i>' ADC sampling time (uSec)</i></font></code>
    This ADC is bit unclear to me and I would like to understand it better.

    BR,
    -Gusse-

Similar Threads

  1. high voltage high frequency H-Bridge
    By George in forum Off Topic
    Replies: 6
    Last Post: - 27th April 2009, 11:50
  2. Expanded Scale Voltmeter
    By Pic_User in forum Schematics
    Replies: 6
    Last Post: - 8th February 2008, 20:32
  3. make a low voltage output from a PIC pin
    By emptyset in forum General
    Replies: 1
    Last Post: - 8th February 2008, 19:20
  4. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  5. Low Voltage Detection
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th January 2005, 18:29

Members who have read this thread : 0

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