Picbasic and ADC set_up


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default Picbasic and ADC set_up

    Good day to all of you in the forum,
    I am going to implemant an AD conversion using the Pic18f252 at 40 MHz clock speed and 10 bit resolution.
    I still have problem in understanding how to set up the following parameters to get the most possible AD speed in a close loop :

    Define ADC_CLOCK ??
    Define ADC_SAMPLEUS ??

    There is also a PAUSEUS ?? value to be put in the loop to comply with the settling or acquisistion time restriction: Where to put it ? and what is the minimum time ?

    I thank you in advance for any help on the matter.

    Regards,
    Ambrogio

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Fastest A/D readings (within specs)

    This first thing to do is look in the 18F252 datasheet for the minimum TAD.
    Go to the "Electrical Characteristics" section, then search for TAD, you should see this ...



    1.6 uS is the minimum TAD.

    Simply multiply the main oscillator frequency (in your case 40,000,000) times the minimum TAD (0.0000016).

    40,000,000 * 0.0000016 = 64

    Always round UP.
    If FOSC = 16,000,000 then (16,000,000 * 0.0000016 = 25.6), so you have to round that UP to the closest prescaler (32).

    Now go to the "COMPATIBLE 10-BIT ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE" section and look at the ADCON0 and ADCON1 registers.
    The ADCS bits select the A/D clock. There are 2 bits in ADCON0 and 1 bit in ADCON1. Together, they make up a 3-bit binary number.
    Look that number up in the table for the ADCON0 register ...
    For FOSC/64, it's 110



    Convert it to decimal and use ...
    Code:
    DEFINE ADC_CLOCK 6   ; FOSC/64, 1.6uS @ 40Mhz
    Different chips have different minimum TAD requirements, and the ADCS bits will change too. Always look them up.

    NOTE: If you were using a 16F1 part, the DEFINE ADC_CLOCK has no affect and the ADCONx registers must be set manually.
    _____________ ________________________ _____________________

    You do not need a PAUSEUS statement for acquisition time.
    That's what the DEFINE ADC_SAMPLEUS does.

    Exactly how much acquisition time is required is a complicated question that depends on circuit impedance, whether or not you are reading more than one channel and again ... the chip you are using.
    mister-e's PicMultiCalc is useful for the impedance part.
    If you are only reading 1 channel, you don't need any acquisition time at all.

    The Trial and error method usually works well enough though.
    Reduce the ADC_SAMPLEUS time until you get bad readings or cross-talk between channels, then double it.
    Last edited by Darrel Taylor; - 13th January 2013 at 19:45.
    DT

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Fastest A/D readings (within specs)

    Derrel,
    thanks very much for your clear and accurate explanation.
    It is great.
    Best regards
    Ambrogio
    IW2FVO
    North Italy

Similar Threads

  1. New software filter for adc reading
    By aratti in forum Code Examples
    Replies: 29
    Last Post: - 6th August 2024, 21:35
  2. ADC and SEEPROM on 16F877A
    By Digitaldood in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 8th January 2013, 17:49
  3. Help with multiple ADC inputs
    By wdmagic in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th January 2013, 00:27
  4. MPXA4115A ADC vref set_up
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th August 2009, 19:04
  5. Proton PICBASIC vs MeLabs PICBASIC
    By Fredrick in forum General
    Replies: 22
    Last Post: - 11th January 2008, 21:51

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