16F819 ADC problems


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    oups, sorry, since a long time i didn't use this built-in ADCIN statement. Still prefer to read/write register myself.

    BTW, what about now if you remove those PBP define and do something like
    Code:
    ADCON0=%11000001
    ADCON1=%10001110
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Thanks both of you. After looking closer at the ADCON registers, which I had done a few dozen times, I noticed I only had seven not eight bits. Steve, thank you for your last post. When I pasted it to my program it was obvious I had left out one bit in each ADCON register. I did have to leave the DEFINE for number of bits and sample time to get it to work. The code is now working and returns 1024 for 5V.

    Regards,
    Mark


    DEFINE OSC 20

    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ADCON0 = %11000001
    ADCON1 = %10000100 ' AN4-AN0 D,A,D,A,A right justify
    TRISA.0 = 1
    TRISA.1 = 1

    adval1 var word
    adval2 var word

    clear
    High PORTB.5 ' turn on run LED
    low PORTB.4 ' low voltage LED
    loop:
    ADCIN 0, adval1 ' Read AN0
    adcin 1, adval2 ' Read AN1

    if adval1 < 512 then
    high PORTB.4
    else
    low PORTB.4
    endif

    serout2 PORTB.3,16572,["ADVAL_1 = ",dec adval1," ADVAL_2 = ",dec adval2,13,10]
    pause 100
    goto loop
    End

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    MUC,

    Great to know it's working now.

    Have fun!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Problems with ADC
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2009, 17:34
  2. PIC18f2423 two 12bit adc input problems
    By Brandon in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2007, 09:47
  3. 16F819 ADC 8bit=127, Not 255?Help!
    By Accelerator in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th June 2006, 17:34
  4. Need help with 16f819 10 bit ADC
    By bannrikae in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th September 2005, 15:20
  5. Newby with ADC problems.
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th March 2005, 20:09

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