Stable ADC readings


Closed Thread
Results 1 to 40 of 91

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    What about reinitialising your Wsum value to 0 @ each 50 samples batch ??? don't you run this loop in another continuous loop ... ??? " par hasard " ...

    BTW " PinProbe " is the alias for which pin ???

    Alain
    Last edited by Acetronics2; - 22nd January 2011 at 18:10.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Jul 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    What about reinitialise your Wsum value to 0 @ each 50 samples batch ??? don't you run this loop in another continuous loop ... ???

    Alain
    Oh I do. I left that part out of the code I pasted, but it is indeed running in an outside continuous loop.

    Code:
    PinProbe VAR PORTA.2
    ...
    myLoop:
    
    WSum = 0
    Pause 100
    
    For i = 0 to 49
    ADCIn PinProbe, W0
    Pause 10
    WSum = WSum + W0
    Next i
    
    W0 = WSum / 50
    ...
    LCDout $fe, 1 'Clear Screen
    Lcdout $fe, $80
    Lcdout "Reading: ", DEC W0
    
    Goto myLoop
    The readings I get with the ADCIN method are in the ballpark but move around too much. With the "manual" ADC method I get a stable value.
    Last edited by dream-; - 22nd January 2011 at 18:15.

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


    Did you find this post helpful? Yes | No

    Default

    ADCIN also polls for the ADCON0.1 bit ...

    sooo .... aheum, how to tell it ...

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    ADCIN also polls for the ADCON0.1 bit ...

    sooo .... aheum, how to tell it ...

    Alain
    Yeah but we already say some odds with ADCIN in the past on some specific PIC, Microchip are good to change the way register are done, and how things work for PIC to PIC model...

    This said, I never use ADCIN myself, but manually write/read ADC registers... it is also a bit less code hungry... down side "may" be when you port your code on another PIC who's not working the same way, or have different register name, bit assignment. big deal
    Steve

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

  5. #5
    Join Date
    Jul 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Well if I understood what the problem was I would not be asking here

    The fact is that the ADCIN code gives me an oscillating reading, and the manual method gives me a stable value.

    I don't know the reason, but I would like to know. This is a 16F688.

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


    Did you find this post helpful? Yes | No

    Default

    For what it is worth I agree with Steve.
    I tried ADCIN a couple of times and did not like it. Others swear by it though. ..

    Keep doing it the way you are.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I would love to see the whole code with ADCIN. Sometime if you play with some ADC registers, and you place them Before or After the DEFINEs, it may end-up with unexpected results.
    Steve

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

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