A/D conversion problem in 18F2520, 2523, 2550 etc.


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    selimkara's Avatar
    selimkara Guest

    Unhappy A/D conversion problem in 18F2520, 2523, 2550 etc.

    Hello again everybody,

    I have successfully studied with PIC18F252 and its easy to use 10-bit A/D conversion. I'm designing some temperature controller stuff to use in our university labs.
    New generation 18F pics (2520, 2523(12-bit), 2550 and 4550 (with USB). I have never achieved to any precise measurement level with these pics. There's always a difference in the results of Keithley multimer and Pic, to the contrary of "lovely" 18F252, in the levels of 10-20 mV. This difference is sometimes linear or non-linear depending on the addition of capacitors and/or RC filters at the voltage and ref. inputs. (I've never needed to use these precautions on 18F252). I've tried to fix the parameters of ADCON registers, tried many combinations of timing, but it's useless. My reference voltage is provided from Maxim's precision ICs (4096 mV or 2048 mV).
    Today, finally I've desperately tried to develop the A/D conversion process of USB demo program written by Mister E and Darrel Taylor (Thanks to them for their great USB comm. example program). I've changed the 8-bit (0-255) resolution of potentiometer voltage to 10-bit (0-1023) by dividing ADREAD variable to low and high bytes, and succesfully combined them in VB6 program to produce the 10-bit result. But the result is still different with this program code.
    I'm using picbasic pro 2.47 and latest version of MPASM. I also tried to write the code in assembler according to the timing diagrams of Microchips manual.
    I never encountered any problem in 18F252 (no capacitor, no filter, a simple reference source from op-amp buffered voltage divider, max. of 1-2 mV error). But I need to use A/D conversion within a USB Pic and/or in a 12-bit Pic (Unfortunately, all of these pics' A/D conversion procedures are differs from 18F252).
    As a summary, can anybody explain where I made mistake(s).
    If you've experienced with that kind of millivolt precision application on these Pics, can you provide me the picbasic code of A/D conversion.
    (sorry about my English)
    Thank You..

    Dr Selim Kara

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by selimkara View Post
    As a summary, can anybody explain where I made mistake(s).
    Nope! Can't see any of your code!

  3. #3
    selimkara's Avatar
    selimkara Guest


    Did you find this post helpful? Yes | No

    Default

    Here is the code (one of many configurations),


    W0 VAR WORD
    W0=0

    define OSC 40
    DEFINE LCD_DREG PORTB
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    define LCD_EREG PORTB
    DEFINE LCD_EBIT 5

    TRISA=%111111
    TRISB=%00000000
    TRISC=%00001111

    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 7
    DEFINE ADC_SAMPLEUS 50

    ADCON0=%00000000 ' CH0 as analog channel
    ADCON1=%00011110
    ADCON2=%10000111

    Start:
    ADCON0.0=1 ' A/D enable
    PAUSE 2

    Conversion:
    ADCON0.1=1 ' Start (Go/Done)

    SubC:
    PAUSEUS 20
    IF ADCON0.1=1 THEN SUBC

    W0.LOWBYTE=ADRESL
    W0.HIGHBYTE=ADRESH

    LCDOut $fe, 1, "Counts ", #W0
    lcdout $fe, $C0, "Result ", #(W0*4) ' 4096 mV ref.

    PAUSE 500

    GOTO Start

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


    Did you find this post helpful? Yes | No

    Question Hardware design fault ???

    Hi,

    While carefully reading your Datasheets ...

    Did you notice the ADC input impedance had slightly changed ??? ... take care to the voltage source impedance !!! ( in your RC filters ... there's a series resistor !!! )

    Your "symptoms" make me think it's a source impedance problem ...

    Also consider the voltage offset of your buffers ... An AOP gives easily 10 mV offset !!! and from a batch to another, it can widely differ.

    Could you show us a scheme of your input circuits ???



    I Use a 2520 for my Honda Lawn tractor ( read air and oil temp - LM335 , plus oil pressure - MPX 5700 , with the inboard ADC) and readings are rock steady ...
    My ref is a 4.096v from a TL431a ... trimmed with a 4.5 digits multimeter ...

    The initial project was built around a 18F452 ... and I didn't notice any change.

    Alain
    Last edited by Acetronics2; - 8th March 2008 at 18:01.
    ************************************************** ***********************
    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
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Also in the datasheet for a 2550/4550...

    The internal AD/RC oscillator is not a good idea on PIC chips if you want extreme accuracy.

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2395&stc=1&d=120499947 4" />

    Try a different AD clock setting ...
    Code:
    ADCON2=%10100110  ; 64 TOSC, 8-TAD sample
    Also, since you're not using ADCIN, the ADC_ DEFINE's don't do anything.
    <br>
    Attached Images Attached Images  
    Last edited by Darrel Taylor; - 8th March 2008 at 20:23. Reason: .
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default Improving ADC repeatability

    High ADC accuracy and repeatability takes dedication at the PCB layout stage. There must be analog ground right beside the analog input and overall copper pour ground planes. Keeping all analog circuitry within its own fenced are of copper usually helps quite a bit.

    Another good technique (thanks Melanie) is to take 16 readings, sort them, throw out the top 4 and the bottom 4 then average the eight values that are left. That technique eliminates the outliers and tames the last one or two counts.

    I have also found several ADC ticks of noise/variability can be eliminated by locking the sampling point to the mains. I bring low voltage AC to an optocoupler and use that to trigger the ADC conversion. Varying the delay after the mains zero crossing will usually show a sweet spot where the fluorescent lights and other electrical loads are fairly quiet. I NEVER attempt 16 bit ADC without mains locking.

    Sloppy techniques that are invisible with 8 bit conversion start showing up with 10 bits and can make the transition to 12 or 16 bit ADC a worthless expedition.

    HTH
    BrianT

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. A/D conversion problem with 18F2455
    By abdy37 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 7th May 2007, 14:53
  3. A/D conversion problem on 18F4431
    By ttease in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th April 2007, 23:03
  4. A/D conversion problem with pic16F88
    By Tapio Linkosalo in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th August 2006, 11:42
  5. A/D converter fails?
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2006, 18:57

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