ADC on PIC12F510


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: ADC on PIC12F510

    Interesting. OK, making headway. So, I am looking at Table 4-1 on page 19.
    For ADCON0 bit 0 turns the ADON? So if I put ADCON0.0=1 that I would expect ADON to enable?
    Does this turn on all the ADC inputs? I see in the table ANS1, ANS0, ADCS1, ADCS0, CHS1, CHS0, GO/DONE, and finally ADON.
    What troubles me is what do all those mean? Is all I need to configure the ADON in order to turn ON the ADC?

    Thanks Henrik...making progress here.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: ADC on PIC12F510

    Hi,
    It depends if you're using ADCIN or manually "driving" the ADC module.

    * You need to set the appropriate pins to analog which on the 12F510 is done thru bits 6 and 7 of ADCON0.

    * Bits 4 and 5 selects from where the ADC gets it clock. When using ADCIN you can DEFINE ADC_CLOCK 3 which basically sets those two bits to 11, selecting INTOSC/4.

    * Bits 2 and 3 selects WHICH of the analog channels that actually gets connected to the ADC. There's only ONE converter, each channel is multiplexed to that single converter by selecting it thru these bits. If using ADCIN it handles these bits for you based on the channel number you specify in the command. Ie ADCIN 1, ADVal will set these bits to 01 selecting channel 1.

    * After selecting a channel you should wait a certain amount of time for the capacitor in the sample and hold circuit to charge. When using ADCIN this time can be specified thru DEFINE ADC_SAMPLEUS

    * Bit 1 is the "start button" for the conversion. You set it to start a conversion and the ADC clears it again when the conversion is complete and result is available. When using ADCIN it handles this for you.

    * ADCON0.0 is the "mains switch" for the ADC module. It needs to be set in order for the ADC to work but simply setting it does NOT actually perform a conversion. The actual conversion is initiated thru bit 1.

    Read the complete ADC section in the datasheet - don't just look at the register. It explains it pretty well and this ADC is basically as simple as they get in a PIC so it's a great start for learning. It does not, however, tell you what the PBP ADCIN command handles for you and what it doesn't but understanding how it works makes it a lot easier to debug when it doesn't work...

    /Henrik.

    PS. On the 12F510 the ADC is 8 bits so your DEFINE ADC_BITS 10 won't work properly.

  3. #3
    Join Date
    Jan 2009
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: ADC on PIC12F510

    Thank-you!!! That makes a whole-lotta-sense now Henrik!
    It is finally "registering" with me. (pun intended)
    I can see how PBP commands do much of the grunt work in getting the ADC paramteres to funtion correctly.
    Yes, once I changed to 8-bit ADC, my code is now working flawlessly. I can now code to a deeper degree with this understanding.
    Again...THANKS!!!!

Members who have read this thread : 1

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