16f88 - pin RA4 as analog input


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor

    If you go with 2 decimals, you may want to use 10-bit values from the A/D for better accuracy.
    In which case you would Right Justify, and the math changes to...<pre>1023 * 5 / 1023 = 5 ; Single digit<br>1023 * 50 / 1023 = 50 ; 1 decimal place<br>1023 * 500 / 1023 = 500 ; 2 decimals</pre>But you'll need to use DIV32 for those.
    I want to use 10-bit values.
    But i can use the DIV32 command to show the result on LCD.

    Now for 8 bit i have this code:

    Code:
        ADCIN 0, adval	                       ' Read channel 0 to adval
        value = adval*50/255                  ' 1 decimal place (5.0)
        
        LCDOUT $FE,1,"VOLT : ",DEC value/10, ".",DEC value//10, " V"
    Last edited by savnik; - 15th December 2006 at 09:42.

  2. #2
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default solved

    i use this:
    ADCIN 0, adval ' Read channel 0 to adval
    dummy = adval * 5 * 100 ' Multiply to load internal registers with 32-bit value
    value = Div32 1023 ' Divide 32-bit value by word and store in word
    Lcdout $fe,1, "VOLT : ", DEC value/10,".", DEC value//10, " V"

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Why not use:

    adcin 0, adval
    adval = adval * 196 / 100
    lcdout $fe,1, "VOLTS: ", DEC1 adval/100,".", DEC2 adval//100, " V"

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  4. 16F88 reading Analog Input
    By thunderstrike44 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2004, 22:41
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

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