Help to setup ADC for 16F1826


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Help to setup ADC for 16F1826

    Hey Barry!
    Thanks so much!!!
    This did it!

    DEFINE OSC 4
    DEFINE ADC_BITS 10 ' 10 bit A/D Conversion
    DEFINE ADC_CLOCK 4
    DEFINE ADC_SAMPLEUS 50 ' 50 uS A/D sample time

    PORTA = 0
    PORTB = 0
    TRISA = %00101100
    TRISB = %00000000
    ADCON1 =%11000000 'Right justified

    ANSELA =%00000010 ' AN2 on PortA.2 analog
    ANSELB =%00000000 ' Digital inputs
    I actually thought you could tell a 10-bit ADC to work as an 8-bit. But no worries! All is perfect once again!!

  2. #2
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: Help to setup ADC for 16F1826

    Hi SOTATOSA
    10 bit A/D converters do work in 8 bit mode. Just set LEFT justified and the 8 MSBs are held in the ADRESH register and the 2 LSBs are held in the ADRESL register bits 6 and 7 which you ignore. ADRESH register contains the 8 bit result. I think this is how DEFINE ADC_BITS 8 works. Setting 8 bit conversion AND RIGHT justified would cause some confusion. Hope this helps.
    Phil

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Help to setup ADC for 16F1826

    this tutorial helped me understand A/D a little better...

    http://www.microcontrollerboard.com/...converter.html

    and here is another good tutorial...

    http://www.edaboard.com/nextoldesttoentry1570.html
    Last edited by Heckler; - 11th February 2014 at 22:39.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: Help to setup ADC for 16F1826

    Thanks for all the replies. Making some kind of sense now! :-)

Similar Threads

  1. ADC problems with a 16F1826 chip
    By alec in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2012, 22:09
  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. 16F913 setup
    By Andre_Pretorius in forum General
    Replies: 31
    Last Post: - 17th April 2010, 23:45
  4. ADC setup for 16F716
    By droptail in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th November 2009, 02:39
  5. LCD setup
    By ruijc in forum General
    Replies: 11
    Last Post: - 19th November 2007, 09:04

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