ADCIN giving inconsistent results


Closed Thread
Results 1 to 14 of 14

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    I would insert a low-pass filter and buffer between the sensor and the PIC. This way, you cut the noise, avoid some spikes (if designed accordingly) and make sure you also have the maximum input impedance on the ADC. (2Kohm if my memory serves me well)

    Side note, if your unit is mounted on a breadboard... you may/will experiment all sort of behaviours, Car noise can be really nasty sometimes.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    It doesn't look like you are clearing V_total every time before you go into your A/D routine.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    True!
    Steve

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

  4. #4
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    I changed the code to reset V_total variable at the start of the V_read routine. I am not able to test until I get home. But i was under the assumption that if I did not reset V_Total it would then the last value would be reused in the next readings average.

    Also when implementing the low-pass filter on the voltage in what values do you think would work for the resistor and capacitor??
    What is a good cut-off frequency??

    Name:  200px-RC_Divider.png
Views: 2827
Size:  3.0 KB

    Thanks again for all the help.
    "Reality is merely an illusion, albeit a very persistent one." , Albert Einstein

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


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    as-is: It really depend of the source....
    assuming you want to use an opamp in between: it's a totally different thing.

    You already use some averaging thing, Try the code modification, I'm pretty confident it will solve the problem.

    You could also use the ADC in 8 bit mode instead of 10...

    Anyways, have a look at this document
    http://ww1.microchip.com/downloads/e...Doc/adn007.pdf
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    My guess is that if you clear V_total, you won't need anything else.

    Consider:

    If the A/D returns a value of 410

    1st time through the loop

    V_Total = 200

    Second time through the loop

    V_Total = 202

    Third time through the loop

    V_Total = 204

    ....

    And it goes through those loops pretty fast. I can see how the results would look inconsistent
    Charles Linquist

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: ADCIN giving inconsistent results

    Quote Originally Posted by triton99 View Post
    What I was wanting to know, is there a better way of reading the voltage using an ADC on the 16F675.
    fwiw I've come to the conclusion that using the picbasic 'ADCIN' command = much badness (unstable ADC readings for me at least)

    Nowadays, if I've a spare CCP module going free, I always use the PIC's special event trigger - it's a very tidy effiicient way of collecting ADC samples in the background - Once it's setup (it's not hard to do this), whenever you want a sample - it's already therefore you ...just go and grab the contents of ADRESH. Job done, eg...

    Code:
    v_in  = ADRESH
    'now go do cool stuff with v_in
    

    The 16f675 has a special event trigger option ...it uses CCP4 for it, so...if you're not intending utilising CCP4, then seriously consider dedicating it to the special event trigger....
    Last edited by HankMcSpank; - 25th September 2011 at 00:50.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts