ADC or ADCIN "bias" problem?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263

    Question ADC or ADCIN "bias" problem?

    PIC16F1827 at 32MHz and PBP.

    My AN channels, specifically AN5 and AN6, are each connected to the wiper of a different pot giving a voltage range of 0-5VDC.

    Based on what I see on the oscilloscope, with 0VDC present on the ANx pin, the ADC for that pin is reading about 60 counts high out of 1023. When I advance the pot, no effect is evident until about 150 counts is reached (i.e., an additional 90).

    It does not appear to be a circuit problem; I have checked the voltage on each pin at the millivolt level and even gone so far as to strap each pin directly to the PIC's ground to verify that the pin is at 0VDC. The "bias" is still there. According to my math, I'd need at least 0.3 VDC to account for it.

    I suspect, from what I'm seeing, that this also may be occurring on signal channels AN0 through AN4.

    Ideas, anyone?
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by RussMartin View Post
    PIC16F1827 at 32MHz and PBP.

    Ideas, anyone?
    Hi, Russ

    3 Ideas ...

    1) Your code ?
    2) your scheme ?
    3) a PCB drawing ?

    +/- 2 counts with a 10 bits adc can be considered Ok ... but here ...

    You certainly missed something ...

    Alain
    Last edited by Acetronics2; - 26th February 2010 at 08:51.
    ************************************************** ***********************
    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
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Well, if you strap the input to any ADC down to 0v, you get a count of zero... so... it looks like your software configuration of the PIC or the ADC is shot...

    1. Make sure your PIC pins are configured for INPUT (TRIS)
    2. Make sure your PIC pins are configured for ADC
    3. Make sure Comparators (if they share the same pins) are Switched OFF
    4. Make sure you have configured VRef+ and VRef-
    5. Make sure that if you have set VRef to EXTERNAL you've connected something to them
    6. Make sure your sampling time is sufficient for capture
    7. Make sure your justification is correct for 8 or 10 Bit mode

    If it's similarly happening on multiple channels, then the chances are your PIC pin is good.

    If you have a scope, the ADC should faithfully follow what it sees on the PICs pin. I say that, because the first and last 20 degrees of travel on many a junk POT doesn't do much as the wiper travels over the end stop.

  4. #4
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Alain, I didn't post code, schematic, or board because all three work just fine with a 16F88. Now, except for controlling the output pins (which Darrel solved in http://www.picbasic.co.uk/forum/showthread.php?t=12739), the only issue is this "bias" (or whatever) on the AN channels.

    Melanie, I've tried to be sure I've turned off the comparators, the CCP modules, and the capacitive sensing module. I don't know if I've missed something, but here's what I did:

    ANSELA= %00011111
    ANSELB= %11000000
    CCP1CON=%00000000
    CCP2CON=%00000000
    CCP3CON=%00000000
    CCP4CON=%00000000
    OSCCON= %11110000
    TRISA = %01111111
    TRISB = %11000001

    ADCON1.7 =1
    CM1CON0.7=0
    CM2CON0.7=0
    CPSCON0 =0

    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 6
    DEFINE ADC_SAMPLEUS 12

    I'll take a look at the Vref matter; maybe that's it. The pots seem okay, with good linear travel and value proportionate to rotation. Remember, I'm seeing the effect with the pins strapped to ground, too.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Have you tried just converting one channel and not multiplexing the ADC? I have had issues before because a previous channel precharged the ADC and would see the same kind of "bias" voltage even though the channel being converted is grounded.
    Tim Barr

  6. #6
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Once again, Melanie, you've saved my bacon!

    It was Vref+ and Vref-. This is what I needed to do:

    ADCON1 = %11101000

    Bit 2 "0" selects Vss (internal) for Vref-
    Bits 1-0 "0" selects Vdd (internal) for Vref+

    No wonder the result was screwy!

    Thanks!

    Tim, thanks for your note, too. I'll remember that as a troubleshooting tip for the future.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

Similar Threads

  1. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  2. ADCIN Problem
    By JavPar in forum General
    Replies: 33
    Last Post: - 20th January 2009, 03:36
  3. ADC problem :(
    By Kaldurenik in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th December 2007, 14:54
  4. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  5. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46

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