ADC sampling time


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default ADC sampling time

    Hello,

    I was wondering why the time I measure(1) for one ADC sampling channel is that much greater than the one stated on the datasheet?

    The oscillo sais around 113µs.
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2433&stc=1&d=120619236 8">

    My PIC has a 4MHz XTal and Fosc is set to 16. Shouldn't I get something like 4µs (green zone)?
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2434&stc=1&d=120619166 4">

    (1): my oscillo triggers a port that is being set before and cleared after the ADC process. Is it not a valid measurement?
    Attached Images Attached Images   
    Roger

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


    Did you find this post helpful? Yes | No

    Talking

    Hi, Lazy Roger

    Go on your datasheet reading to $ 9.1.5 ...

    Hé, oui ... faut TOUT lire ...

    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
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    From datasheet 9.1.4...

    "The time to complete one bit conversion is defined as
    TAD. One full 10-bit conversion requires 11 TAD periods
    as shown in Figure 9-2."

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default getting complicated...

    Not always lazy: most of the time, I'm hungry... of knowledge

    Okay, looking at tables "17-18" and "17-16" and if my (too) modestly developped brain understands what seems to be so obvious, I would calculate the aquisition time like this:

    - aquisition time (param. 132) is 11,5µs;
    - converstion time (param. 131) is 11Tad (param. 130) @ 3µs each(full range), makes 33µs.

    All in all the total calculated time gives 11,5µs + 33µs = 44,5µs.

    I'm still missing something, or at least 113µs - 44,5µs = 68,5µs.

    Is my PIC getting as rest???
    Roger

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Is my PIC getting as rest???
    Your code is probably setting a few bank select registers, doing some gosub'ing and return'ing during all of this. But that would still only account for a handful of the 'missing' cycles.
    Post the code that's running this. Maybe those missing cycles are laying around in there...

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default code

    Here it is:
    Code:
    ' PIC 16F690 Fuses
    @ DEVICE FCMEN_OFF
    @ DEVICE IESO_OFF
    @ DEVICE BOD_ON
    @ DEVICE CPD_OFF
    @ DEVICE PROTECT_OFF
    @ DEVICE MCLR_OFF
    @ DEVICE PWRT_OFF
    @ DEVICE WDT_OFF
    @ DEVICE HS_OSC
    
    '-------------------------------------------------------------------------------
    ' Registers   76543210
    OPTION_REG = %10000101 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
    ANSEL      = %00000001 'Select analog inputs Channels 0 to 7
    ANSELH     = %00000000 'Select analog inputs Channels 8 to 11
    ADCON0     = %10000010 'A/D Module is ON (Bit5:2 select channels 0:11)
    ADCON1     = %00010000 'A/D control register
    CM1CON0    = %00000000 'Comparator1 Module is OFF
    CM2CON0    = %00000000 'Comparator2 Module is OFF
    INTCON     = %00000000 'INTerrupts CONtrol (TMR0 ON)
    TRISA      = %00000001 'Set Input/Output (0 to 5)
    PORTA      = %00000000 'Ports High/Low (0 to 5)
    TRISB      = %00000000 'Set Input/Output (4 to 7)
    PORTB      = %00000000 'Ports High/Low (4 to 7)
    TRISC      = %00000000 'Set Input/Output (0 to 7)
    PORTC      = %00000000 'Ports High/Low (0 to 7)
    
    '-------------------------------------------------------------------------------
    ' Defines
    DEFINE ADC_BITS 10     'Number of bits in ADCIN result
    
    '-------------------------------------------------------------------------------
    ' Variables
    Volt    var word
    Check   var PORTB.6 'I use this one to measure the ADC start/end
    
    '-------------------------------------------------------------------------------
    ' Program
    MAIN:
        check = 1
        adcin 0, volt
        check = 0
        goto MAIN
    end
    NB: is there a way to make the code appear with the same text formatting as I have in MCS?
    Roger

Similar Threads

  1. Hello, long time no post (ADC sample rate)
    By Jhong2 in forum General
    Replies: 0
    Last Post: - 14th April 2009, 04:13
  2. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  3. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24
  4. reducing the ADC time, pic877a with 20 MHZ osc
    By toalan in forum Off Topic
    Replies: 0
    Last Post: - 23rd February 2005, 17:58
  5. A/D sampling time and ...
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th April 2004, 08:16

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