+ Reply to Thread
Results 1 to 10 of 10

Thread: 18F66K80 adc

  1. #1

    Default 18F66K80 adc

    OK i'm confused by the 12 bit adc register settings.. I've got the pic adc working but is it optimal?
    I'm trying to avoid using defines but am using adcin...

    Processor is running at 64mhz

    My current ADC config..

    ADCON0 = %00000001 'SETUP ADC & ENABLE ADC MODULE on AN0
    ADCON1 = %00010000 'SETUP ADC SET REFV to the 2.5V VREF+ & VSS
    ADCON2 = %10011110 'SETUP ADC FOSC/64 RIGHT JUSTIFY TAD 6 (12 Bit)

    My input has a 4.7k series resistor and 0.1uf cap (Higher impedance than spec but should work with a suitable TAD)

    So with fosc 64 have I got TAD correct? What do you make it?
    Maths isn't my strong point so the example calculations in the datasheet are

    18F66K80 Datasheet link for info..

    http://ww1.microchip.com/downloads/e...doc/39977c.pdf

    There is also some info in the Errata datasheet for the part concerning the 12bit adc.

    How will that effect me? Comments welcome?

    http://ww1.microchip.com/downloads/e...-80000519P.pdf

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,236

    Default Re: 18F66K80 adc

    1. If you are using ADCIN, then as much as I know, default "default" defines will be referred even if you do not define anything. Needs confirmation.
    2. Have you heard of Mister E?
    2a. For 64Mhz, TAD = 0, Clock Source = Frc, Min Acquisition Time = 11 uS
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3

    Default Re: 18F66K80 adc

    I don't really want to use defines but i might have too.

  4. #4

    Default Re: 18F66K80 adc

    Whats wrong with defines?
    George

  5. #5

    Default Re: 18F66K80 adc

    I want too understand how to set the registers directly.
    The PBPRO manual does state that the ADC defines can't cater for all chip types or scenarios etc and that some pics resist them..

    Some PIC MCU defy PBP's attempts to translate the ADC_CLOCK define to a
    register setting. If you are having trouble with your ADCIN performance, try setting
    the ADC clock source with a direct register setting in addition to the DEFINE.

  6. #6
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    311

    Default Re: 18F66K80 adc

    DEFINEs let PBP know what you put in the SFRs. For example, if you wish to use 12-bit ADC but don't DEFINE it, PBP uses the Default 8-bit. You may manually set the Sample, but if you don't DEFINE it, PBP uses the default "3" (FCR). All that does is get your "ADCIN" to deliver inaccurate results. You MUST set the SFRs. If you use a DEFINE, PBP acts as if you set the SFR to that setting, but doesn't actually affect the Register for you.

    USE BOTH!
    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.

  7. #7
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,236

    Default Re: 18F66K80 adc

    ...or forget about ADCIN, and use ADC registers directly.
    No need defines.

    Use the magic of your fingers.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #8

    Default Re: 18F66K80 adc

    Quote Originally Posted by sayzer View Post
    ...or forget about ADCIN, and use ADC registers directly.
    No need defines.

    Use the magic of your fingers.
    That's what i'm trying to do but am stuck with the adc register settings..

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,199

    Default Re: 18F66K80 adc

    Here ia an excerpt from a program running on 18F26k22:

    ADCON0 = %00000000 'GO/DONE,ADOFF
    ADCON1 = %00000000 'TRIGGER CCP5,+VREF=VDD,-VREF=VSS, ANALOG
    ADCON2 = %10000110 'RIGHT JUSTIFIED,0 TAD,FOSC/64


    '************************************************* ********************
    READAD: 'READ SYSTEM A/D VOLTAGES (AVERAGE 16 READINGS)
    '************************************************* ********************
    ADCON0 = $01 | (CHANNEL << 2) ' Set A/D to Channel X, On
    PAUSEUS 40 'PAUSE FOR TAD
    VOLTS(CHANNEL) = 0 'CLEAR A/D READINGS
    ADCON0.1 = ON_ ' START CONVERSION
    JUNK = NREADS 'TAKE 16 READINGS
    NXTAD:
    IF ADCON0.1 = ON_ THEN NXTAD 'WAIT FOR A/D TO FINISH
    VOLTS(CHANNEL) = VOLTS(CHANNEL) + (((ADRESH & $3) << 8) + ADRESL) 'BUILD SENSOR WORD (RIGHT JUSTIFIED)
    JUNK = JUNK - 1
    IF JUNK < 255 THEN NXTAD
    VOLTS(CHANNEL) = VOLTS(CHANNEL) >> 4 'DIVIDE BY 16 TO GENERATE 0-1023
    RETURN
    Dave Purola,
    N8NTA
    EN82fn

  10. #10

    Default Re: 18F66K80 adc

    Sorry retepsnikrep, I thought you meant defines per se rather than the built-in defines.
    George

Similar Threads

  1. ADC values above 4095 for 12 bit ADC
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st February 2015, 22:24
  2. ADC problem on 18F46K22 device using all 28 ADC pins
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:22
  3. adc
    By kamran in forum mel PIC BASIC
    Replies: 0
    Last Post: - 15th April 2011, 13:07
  4. Little ADC Help PLease !!!
    By Francisco M in forum USB
    Replies: 1
    Last Post: - 9th March 2009, 14:59
  5. need help with adc
    By houa in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 27th September 2005, 02:51

Members who have read this thread : 15

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