Inconsistant A2D readings


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86

    Default Inconsistant A2D readings

    I am having trouble getting consistent A2D readings across a voltage divider. I have two microchips, both PIC18F45k22 attached to PORTA.5 (AN4). I only really need one of them to read the analog value. I should be getting a reading around 33. When I tested a few months ago with a single chip my results varied from 29-34 which was fine. I may have had two chips attached on my proto, or just one, I'm not 100% positive. Now I get an initial value around 20 (not consistant) when I power up, but as I continue to monitor it fluctuates wildly by several hundred. The second microchip has A.5 set as an input and I have tried making it digital and analog, though I'm not sure if that has any affect on the first chip.


    +5---/\/ 30k \/\---PORTA.5---/\/ 1k \/\---GND

    Here is the code I'm using to poll
    Code:
    check_A2D:
    
        ADCON1 =0
        ADCON2 = %10000110
        ADCON0 = %00010001      '   Set ADC channel to AN4 and enable ADC
        pauseus 5
    
        ADCON0.1 = 1    'start AC process    
       
        while adcon0.1 = 1
        wend
        
        Reg_value.byte0 = ADRESL
        Reg_value.byte1 = ADRESH
    return
    I then display the results of Reg_value on some 7 segment LEDs. I checked my power supply and the voltage seems nice and steady. I'm kind of new to the analog world, so I very easily could not have some settings done correctly, but have tried a wide variety of register settings. I have some DT interrupts going on for a timer and one serial port, but I tried disabling them with the same results.
    Thanks
    David

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Inconsistant A2D readings

    Hi,
    The recommended source impedance for the ADC on the 45K22 is 3k, you have 30k - that might play a role in your results (see table 27-22 in the datasheet).

    Since you have the acquisition time set to manual and such large source impedance perhaps you could try increasing the Pause 5 and see if that helps (or try reducing your source impedance to meet the recommended value of 3k). I'd probably also disconnect the signal from the second PIC until you get stable readings on the firts one.

    /Henrik.

  3. #3
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default Re: Inconsistant A2D readings

    I tried cutting the trace to the second pic and it didn't seem to have any effect. I adjusted the pause to Pauseus 10, pauseus 50 and pause 5. None seemed to help any. The resistors are surface mount, but I think I will try putting a 1k in parallel with the 30k and see if it at least stabilizes

    Thanks

  4. #4
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default Re: Inconsistant A2D readings

    I found the problem. I had two similar net names "Display Type" and "DisplayType" which should have been connected and weren't, so the microchip pin was effectively floating. I found it will playing with resistor values, so thanks Henrik for the help.

Similar Threads

  1. Inconsistant time using interupts
    By Mark J in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th November 2010, 21:10
  2. A2D question
    By dbodenheimer in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th July 2010, 07:03
  3. A2D issues on PIC16F876A
    By earltyso in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 31st July 2008, 14:06
  4. A2D on PIC 16F685
    By Forkosh in forum General
    Replies: 7
    Last Post: - 16th October 2007, 15:33
  5. Pic12f683, Trisio, High Z, A2d
    By jmbanales21485 in forum Schematics
    Replies: 9
    Last Post: - 5th July 2007, 19:34

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