18f4620 & ADC confusion


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2005
    Posts
    14

    Question 18f4620 & ADC confusion

    I've been working with the 16F877A and haven't had any ADC problems. Now with the 18F4620 I can't seem to read any ADC voltages. I'm trying to monitor certain voltages including the voltage at the devices battery with and without external power supplied.

    Here is my set up:

    Assume only reading value on an 8.4 V LI-Poly battery.
    Battery voltage is being sensed at the middle of a voltage divider
    << --- 10K --T -- 3.3K---Vss
    Reading at the center of the above divider I would expect the max input voltage sensed (without damage to the PIC) is 20 Volts which would be sensed across the divider as as 1/4 of the input or 5VDC. My input may be 10 Volts max so I should expect to read about 2.5 VDC at the input to the ADC.

    I'm using AN7 (RE2) as my analog input pin being connected to the center of the divider.

    Here is the PBP code being used:
    DEFINES-----------------------------------------------------------
    define ADC_BITS 10
    define ADC_CLOCK 3
    define ADC_SAMPLESUS 50
    define OSC 40

    ROUTINE-----------------------------------------------------------
    Chk_Volts:
    TRISe.2 = 1
    ADCON0 = %00011101
    ADCON1 = %00000111
    ADCON2 = %10111111
    PAUSE 10
    adcin 7, volts_10
    pause 200
    SEROUT LCD, LCD_Mode,[12, "Volts_10: ",#volts10," "]
    ----------------------------------------------------------------------

    I have 7 new boards with the PIC18F4620 installed as described above. All functions work well except for ADC input. Never had problems doing almost the same thing with the 16F877A.

    Any ideas out there as to what I am doing wrong?

    John P, Virginia Beach, VA USA

  2. #2
    Join Date
    Dec 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Additional info....

    Re-reading my post I left out the following:

    Variable: Volts10 VAR Word

    I am assuming to get an ADC result ranging from 0 to 1023 () VDC to 20 VDC)

    The SEROUT command displays the Volts10 result on a Seetron 4x20 LCD and that part works just fine when similarly used for all other routines Whoops...

    Just found the problem while re-reading this post (DUH!!!) I've been using the variable Volts_10 as the ADC result and displaying the Variable Volts10 to the LCD. othink I've been shooting this problem for about a week!!

    With a 10.6 VDC input, the ADC result in Volts_10 is 495.

    Thanks guys - I am embarassed.

    John P

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default



    Don't worry... it happen to everybody.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Dec 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Wink It happens to...

    Steve,
    It supposed to happen to everybody


    ELSE!!

    John P

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    bah... where would be the fun?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. 10 bit ADC display on LCD using 16f873
    By pr2don in forum mel PIC BASIC
    Replies: 3
    Last Post: - 6th March 2010, 18:29
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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