ADCIN Problem


Closed Thread
Results 1 to 34 of 34

Thread: ADCIN Problem

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    21

    Default ADCIN Problem

    Hello everyone,

    I am using a PIC18F4620 to read voltages but I am having aproblem where if I read anything in between 0 or 5 volts, the voltages readings are erratic or oscillate. I have tried using resistors or capacitors on the ADCIN pin but nothing seems to work. I have been trying to solve these for weeks now I have done a lot of research but can't find anything that gives light to what the problem is. I am powering my project with a USB port.

    I also noticed that if I disconnect the cable that goes to the ADCIN pin, I still get erratic numbers instead of reading 0. I have tried with code to get an average reading but this makes the code run slow.

    Any help on this will be highly appreciated.

    Following is an exctract of my code that am using separately to solve the problem with the ADCIN:

    DEFINE LOADER_USED 1 'Bootloader Used
    @ __CONFIG _CONFIG1H, _OSC_HS_1H
    DEFINE OSC 8
    ' OSCCON=%01110000
    Define ADC_BITS 10
    Define ADC_CLOCK 3
    Define ADC_SAMPLEUS 50
    adval var word
    TRISA = %11111111
    ADCON1 = %00000010
    ADCON2.7 = 1
    'ADCON0 = %11000001
    Pause 500
    Serout2 PORTD.0,16468,[$1b, $2a, $ff]
    loop:
    ADCIN 1, adval
    pause 50
    Serout2 PORTB.7,16468,[dec adval] ' to PC
    Serout2 PORTD.0,16468,[$fe, 1]
    Serout2 PORTD.0,16468,[dec adval] ' to LCD
    Goto loop
    End

    Javier.

  2. #2
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile Do you have any references?

    Hi Javier,

    Quote Originally Posted by JavPar View Post
    Hello everyone,

    I am using a PIC18F4620 to read voltages but I am having a problem where if I read anything in between 0 or 5 volts, the voltages readings are erratic or oscillate. I have tried using resistors or capacitors on the ADCIN pin but nothing seems to work. I have been trying to solve these for weeks now I have done a lot of research but can't find anything that gives light to what the problem is. I am powering my project with a USB port.

    I also noticed that if I disconnect the cable that goes to the ADCIN pin, I still get erratic numbers instead of reading 0. I have tried with code to get an average reading but this makes the code run slow.

    Any help on this will be highly appreciated. ....

    Javier.
    Don’t forget that the A/D module relies on an accurate, known, reference voltage, to compare to an unknown voltage. If your reference is your supply voltage then your supply voltage has to be rock solid. If you are switching loads attached to the supply / reference then the supply has to switch these loads without changing voltage.

    You still can use A/D input filters but if the reference voltage is not stable your readings will reflect the variations.

    Edited to add: Be sure your DEFINES are in Upper Case
    -Adam-
    Last edited by Pic_User; - 16th December 2008 at 17:14. Reason: Added: Be sure your DEFINES are in Upper Case
    Ohm it's not just a good idea... it's the LAW !

  3. #3
    Join Date
    Dec 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Hey Adam,

    Thank you for your help. I am scratching my head over the reference voltage. From all the ADCIN samples I have seen, I haven't seen one that says anything about a reference voltage. Is this done by setting a register?
    I am reading the datasheet right now to see if I find something about that. My defines are in capital letter in my program.

    Javier.

  4. #4
    Join Date
    Dec 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    From the datasheet, I am using:

    ADCON1 = %00001101

    which specifyes that I am using the project's voltage internally from VDD and VSS for voltage reference. I also tried using external voltage for reference but I get the exact same results.

    I tried putting a .1uF cap at the voltage in pin but no change.

    I am going to tried with another sorce of 5v and not use the USB to see what happens.

    Any suggestions will be appreciated.

    Javier.

  5. #5
    Join Date
    Dec 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    I tried using a 5V power supply, but I still get the erratic voltage readings.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    WHAT are you measuring and how have you got it connected?

    Have you tried using a plain old meter?

    What is this 5v power supply you speak of? A wall-plug type supply? Benchtop supply?

    How much other stuff do you have connected to your '4620?

    How about posting a bit of a schematic...

Similar Threads

  1. ADC or ADCIN "bias" problem?
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2010, 19:39
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. electrical problem adcin
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th March 2007, 22:52
  4. adcin problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th February 2005, 17:47
  5. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 01:08

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