Strange ADC behaviour


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    I still get behaviour no matter what i change...


    except with Mister-e's code that works OK

    Is it just a pbp version issue or is it something else ?

    If it's a version problem...is there a way to get arround it ?

    .

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


    Did you find this post helpful? Yes | No

    Wink Success ...

    Hi, Ruijc

    I just re-wrote your code ... works fine ( I'm only talking of the PIC point of view - do not talk about precision ...)

    Try to write carefully ( and readably) ALL your config sequence ( I know ... ~ 50 lines ! )... and it will work !!!

    Just a tip:

    instead of :

    " temp = (va1*/500)>> 2 "

    try :

    " temp = val*125
    temp = temp.highbyte "

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

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


    Did you find this post helpful? Yes | No

    Default

    Mine did some averaging, not much. Read the sensor couple of time (10-16 times) then calculate the average of it, go to next channel, do the same, show the results.

    I did it the 'bad' way
    Code:
            for loopw = 0 to 15
                ADCIN 0, TEMPW
                VA1=VA1 + (TEMPW>>4)
                NEXT
                
            pause 500
            
            FOR LOOPW=0 TO 15
                ADCIN 1, TEMPW
                VA2=VA2 + (TEMPW>>4)
                NEXT
    lost of precision and so on, now for something better, have a look at Darrel's routine.

    Averaging 16 bit values without using 32 bit math?
    http://www.pbpgroup.com/modules/wfse...hp?articleid=7
    Last edited by mister_e; - 9th December 2007 at 18:29.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by mister_e View Post

    lost of precision and so on, now for something better, have a look at Darrel's routine.
    Hi, Steve

    for precision ... measuring 150 or 200 mV on a 5 v full scale is a nonsense ...
    we already had this discussion here with ruijc ...

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

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


    Did you find this post helpful? Yes | No

    Default

    Yup i agree, an external Vref or op-amp should be used.
    Steve

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

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hi guys

    thanks for all the help.

    Mister-e...you mentioned an external Vref.

    I have a 12v power down to 5v for this circuit.

    Can i use 12v as reference ? How can i do this ?

    I'm a bit confused...can i plug it directly to my 16F88 ?

    .

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


    Did you find this post helpful? Yes | No

    Default

    NO NO NO DON'T DO IT

    Vref have to be lower than Vdd. Let's see you have a sensor who produce you a max of 1 volt. Then you select a Vref of ~1 Volt, then your ADC give you the full 10 bit conversion scale between 0-Vref. This is the use of it.

    But yeah.. check out for the minimum Vref requirement...
    Last edited by mister_e; - 10th December 2007 at 18:51.
    Steve

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

Similar Threads

  1. Strange Behaviour - Simple code+DT_INT+16F676
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2010, 19:53
  2. Strange behaviour of my PBP code.
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th August 2009, 21:20
  3. Strange Serout Behaviour
    By bluesmoke in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th August 2009, 05:12
  4. Strange behaviour from PIC16F877 on TMR0
    By mikebar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 19th August 2006, 02:31
  5. strange int behaviour
    By tom in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2005, 16:41

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