How to make adcin stable?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    A capacitor might be needed, what are you reading?
    For example...
    A LM34/35 will be unstable sometime depending on cable and all will need a capacitor from signal to ground (zero rail) to keep it from fluctuating. 22uf works well.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I see you are using an external Vref. Are you certain it is stable? Also, I have had better results using the "real" clock (not R/C) for the ADC clock. At 20Mhz, you can use Fosc/32 (ADCON2 = %10000010) in most chips.
    Make sure the source impedance into the ADC pin is < 2K, and use a .1uF to ground from the ADC Pin.
    If you have the time, take 4 to 16 samples, add them together and divide to get an average.
    Charles Linquist

  3. #3
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    I only need 2 analog inputs, no other configuration without Vref+ unless I enable more analog input pins.

    I'm connecting phototransistor with pull up 350K to +5V, does this mean I need to increase ADC_SAMPLEUS?

    The circuit only have one +5V source, so I connect Vref+ to Vdd pin of PIC directly without any resistor. Is this ok?

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You can connect Vref to Vdd, but it is easier just to set ADCON1 bits 5&4 to "0" which connects Vref to Vdd internally.

    Also, READ YOUR DATASHEET. Here is a cut and paste directly from the A/D section of the 18F8722 datasheet:

    The
    maximum recommended impedance for analog
    sources is 2.5 kΩ.


    Other chips have similar recommendations.

    Your 350K is WAAAAAY too high! If you really need a 350K pull-up, you will
    have to buffer the analog signal with an op-amp to get accurate readings.


    If you just want to sense the presence of an object, you would be better off using a digital input, and connecting the collector of your phototransistor to 5V through a 10K or 22K resistor.
    Charles Linquist

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default

    I would suggest to use an opamp as a unity gain buffer befor feeding the ADC of the PIC.

    As Charles stated 350K is too high for the ADC to work reliable.

    Also to be sure that the PIC is working OK, use a trimmer in the place of the phototransistor and check the results. If they are stable and seem expected then you can be sure that PIC is OK. Of course it would be a very good idea to average the samples. Have a look at Darrels averaging routine at his site:

    http://www.pbpgroup.com/modules/wfse...hp?articleid=7

    Ioannis

  6. #6
    Join Date
    Jan 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Default 10 bit results

    Can anyone tell me why I am getting 16 bit results from this code? I expect at 5 volts in I should see 1023 but I see 65535.I am using a 16f616.



    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    TRISA = 255 ' Set PORTA to all input
    ADCON1 = 2 ' PORTA is analog
    ADCIN 0, A0 ' PORTA.0 PIN 13

  7. #7
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    change your ADCON1 =2 with

    ADCON1=%10000010

Similar Threads

  1. ADCIN and PIC18F4331 Arghhhhh !
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2010, 20:27
  2. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  3. ADCIN problems with PIC16F73
    By passion1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 26th July 2007, 11:38
  4. How come they make electronics hard as poss
    By George in forum Off Topic
    Replies: 9
    Last Post: - 13th July 2007, 23:54
  5. help using adcin
    By harryweb in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st January 2006, 07:46

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