10bit ADC with offset on 16F88


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198

    Default 10bit ADC with offset on 16F88

    Some days ago I posted for help with this, but I think it was overlooked in a post with 2 issues to address. Below is my best effort at configuring a 16F88 ADC (AN0) to operate 10bit with an offset +Vref on AN3. Some unexpected results with a standard ADC setup (a 10K pot gives expected results, but the sensor does not) have me wondering if the sensor (LM34CZ) is damaged. My intent is as here: http://www.rentron.com/PicBasic/LM34.htm, but of course the ADC setup is different for the ’88.

    Will someone who knows this chip verify/ correct my configuration?

    Thank you.




    ‘----------------------configure P16F88 fuses
    #CONFIG
    __config _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF
    __config _CONFIG2, _FCMEN_OFF & _IESO_OFF
    #ENDCONFIG
    ‘----------------------configure oscillator for 8M internal
    DEFINE OSC 8
    OSCCON = %01110000

    ‘----------------------configure ADC for +Vref on AN3, ADC on AN0
    ANSEL= %00001001 'ANALOG OFF, EXCEPT +Vref (AN3) AND AN0
    TRISA = %00001001 'PORTA TO MATCH ANSEL
    TRISB = %00000000 'PORTB DIGITAL
    ADCON1.7 = 0 : ADCON1.6 = 0 : ADCON1.5 = 1 : ADCON1.4 = 0 'LEFT JUSTIFIED : ADCS2 DISABLED : VCFG Vref+ AVSS
    ADCON0 = %01011001 'Fosc/8 : AN3 ACTIVE : ADC ON

  2. #2
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC with offset on 16F88

    Amoque,
    Looking at the data sheet it looks like you have your setup right. Might be in the code that you have for reading, converting, etc. LM34 should be easy to check if it is working correctly. Apply power and check to see if the output matches what your thermometer says.
    Chris.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC with offset on 16F88

    Quote Originally Posted by Amoque View Post
    ADCON1.7 = 0
    ADCON1.6 = 0
    ADCON1.5 = 1
    ADCON1.4 = 0 'LEFT JUSTIFIED
    ADCS2 DISABLED : VCFG Vref+ AVSS
    Double check all this in the data sheet. Asfaik you need to right justify for ten bit results. 1.4 is not the justify bit

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC with offset on 16F88

    amoque, Here ia a bit of code I wrote some time ago for a boost gage used to read the boost pressure for a car using a 16F88 and displaying the results on a 7 segment display. It should have everyting you need.... PLease give credit where credit is due....
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC with offset on 16F88

    Thank you all for the responses!

    There is significant there to digest Dave, but be assured I will give proper credit now, and as I study the other concepts you demonstrate, in the future as well--including the "COWS_COME_HOME" reference!

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