Strange A/D conversion...


Closed Thread
Results 1 to 5 of 5
  1. #1
    Christos_K's Avatar
    Christos_K Guest

    Default Strange A/D conversion...

    Hi all! Have been trying to do a 10bit A/D conversion using a PIC16f876 but something strange happens...I have a working circuit and send the result through RS232 to my pc...I use a potentiometer with the two ends connected at Vdd and GND and the other end is connected to PORTA.0...Look at some measurements i did..The first values are from my digital multimeter and the second values are the decimal value of the a/d conversion variable...

    5V --> 1023 (5v)
    4V --> 785 (3.8v)
    3V --> 552 (2.7v)
    2V --> 300 (1.47v)
    1v --> 65 (0.3v)
    0v --> 0 (0v)

    As you can see the A/D conversion can show the max and minimum values but it is lost in between..
    Here is my code(reference votlage is set to Vdd = 5V):

    DEFINE HSER_RCSTA 90h '
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 129
    DEFINE HSER_CLROERR 1

    DEFINE OSC 20

    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 2 (tried 3 but didn;t work)
    DEFINE ADC_SAMPLEUS 50 (tried increasing but didn;t work)

    adcdata var WORD
    trisa = %11111111

    ADCON1 = %10000010

    main:

    ADCIN 0, ADCDATA

    hserout [dec ADCDATA ,13]

    pause 1000

    goto main


    What can be wrong?? I 've also tried a version where you manual set the conversion to start and checking the bit2 of adcon0 etc etc but same results...
    Also tried with 3.3V reference voltage at PortA but still no luck...
    Last edited by Christos_K; - 31st May 2005 at 02:21.

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


    Did you find this post helpful? Yes | No

    Default

    could be some noise on the pot wiper. Have you place a capacitor between PIC input and gnd? What is the impedance of your POT. Should be less than 10K if my memory is good for that PIC.

    Also, make sure your supply line is neat.
    Steve

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

  3. #3
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    I suspect a wiring problem since your conversion is dead straight(see ADcurve.gif) with an offset of about 0,75v. That's close to a normal voltage drop over a diode or transistor.
    Attached Images Attached Images  

  4. #4
    Christos_K's Avatar
    Christos_K Guest


    Did you find this post helpful? Yes | No

    Default

    Problem solved! Indeed it was wirring problem! Another question now, What do the values for Define ADC_CLOCK repesent and how are they different?

    I know that you can have ADC_CLOCK 0,1,2 or 3...What does its number correspond to?

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The value selects the source of the ADC conversion clock. For a detailed answer to this, look at "Selecting the ADC Conversion Clock" sub-section, in the ADC section of your chosen PICs Datasheet. Some newer PICs have a wider selection range than provided by the DEFINE, in those cases it's best to select by presetting the Registers yourself. If you are unsure what source to use, the RC option (which is an internal ADC option and nothing whatsoever to do with the PICs main Oscillator) is always a safe bet.

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. Fast / low resolution A/D conversion
    By AndrewC in forum General
    Replies: 7
    Last Post: - 7th April 2009, 12:18
  3. A/D conversion problem in 18F2520, 2523, 2550 etc.
    By selimkara in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 10th March 2008, 16:26
  4. A/D conversion problem on 18F4431
    By ttease in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th April 2007, 23:03
  5. A/D converter fails?
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2006, 18:57

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