PIC16f1829 ADC question...


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default PIC16f1829 ADC question...

    I am not fully understanding the setup for the ADC, and therefor, I am missing something. With the following code I get my readout on the LCD, but I get 0 99.9% of the pot travel, and 255 @ POT WOT. Anyone see my problem?

    Code:
    #CONFIG
        __config _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF    
        __config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_OFF
    #ENDCONFIG
    
    
    DEFINE OSC 20
    Define  ADC_BITS     8 
    Define  ADC_CLOCK    3 
    Define  ADC_SAMPLEUS 50
    
    
    Define  LCD_DREG  PORTC
    Define  LCD_DBIT  0
    Define  LCD_RSREG PORTB
    Define  LCD_RSBIT 4
    Define  LCD_EREG  PORTC
    Define  LCD_EBIT  6
    
    
    TRISA = %11111111
    ADCON1 = %00000100
    adval1 var word
    adval2 var word
    ADCON0 = 0
    ANSELA = 1
    ANSELB = 0
    ANSELC = 0
    
    
    adval1 = 0
    
    
    Temp:
        adcin 0, adval1
        Lcdout $fe, 1
        Lcdout "Value: ", DEC adval1  ' Display the decimal value 
        Pause 100 
    goto temp

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: PIC16f1829 ADC question...

    I think you have the adc turned off.

    Try adcon0 = %00000001 or adcon0.0 = 1

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: PIC16f1829 ADC question...

    ADCON1 = %00000100 will set adc reference to external , is that what you want ? have you provided an ext reference ?

    I assume you have the pot connected to an0 of course

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: PIC16f1829 ADC question...

    Thanks for the input! Yea it was the VREF- set external... I was reading the bits left to right... in other words, I had my head solidly in brown town....

Similar Threads

  1. ADC Question
    By Art in forum General
    Replies: 0
    Last Post: - 24th January 2012, 02:35
  2. ADC question again
    By Bobbo_ZA in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 7th May 2010, 13:02
  3. ADC question
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 8th June 2007, 09:52
  4. A question about ADC (using Pic16f876)
    By mimmmis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd April 2007, 16:26
  5. ADC question
    By schu4647 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th May 2006, 14:15

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