Converting A to D value to 0 to 5VDC


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    36

    Default Converting A to D value to 0 to 5VDC

    I wanted to take a reading off of a 10K pot using A to D on a PIC16F687 using 10 bits. I wanted to convert the A to D value of 0 to 1023 to a voltage 0 to 5V. I thought this might be helpful. Tech support helped me figure this out.

    To have precision to two decimal points use.
    ADCIN 3, AD_AN3_VALUE ' read channel 3 to AD_AN3_VALUE
    AD_AN3_Volt = (AD_AN3_VALUE */ 500) >> 2
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT "A to D Value"
    LCDOUT $FE, $C0, DEC (AD_AN3_volt/100) ,".",DEC2 AD_AN3_VOLT ,"VDC"
    PAUSE 100

    TO have precision to three decimal points use:
    AD_AN3_Volt = (AD_AN3_VALUE */ 5000) >> 2
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT "A to D Value"
    LCDOUT $FE, $C0, DEC (AD_AN3_volt/1000) ,".",DEC3 AD_AN3_VOLT ,"VDC"

  2. #2
    minmin's Avatar
    minmin Guest


    Did you find this post helpful? Yes | No

    Smile 0-5 ADC, PIC18F458, results show on LCD

    'Here is another sample of AD convert
    'the result shows on LCD
    'load cell output feed to portA.3
    ' Sep 25, 2006
    '*****************************

    DEFINE OSC 4

    W1 VAR WORD

    include "modedefs.bas"

    PAUSE 1000 'LCD takes a second to start

    TRISA = 255 'PORTA all inputs
    ADCON1 = 0 'PORTA Analog I/O
    ADCON0.7 = 1 'Right justified.


    ' Initialize USART
    TRISC = %10111111 'Set TX (PortC.6) to out, rest in
    TXSTA = %00100000 'Enable transmit and asynchronous mode

    SEROUT PORTC.6,N9600,["Citrus Counter ",254,2]
    PAUSE 1000

    SEROUT PORTC.6,N9600,[254,1] ' Clear screen

    LOOP1:
    ADCIN 3, W1
    SEROUT PORTC.6,N9600,[#W1,13]
    GOTO LOOP1
    END
    '************************************************* ******

  3. #3
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default Thanks!

    I was just working on a little project, and had a little problem getting exactly what I needed from the A/D, and I noticed your post. Perfect. I only needed to make two minor changes and it now works great.
    Thanks,

    Jerry.

Similar Threads

  1. Help converting DS1993 to DS2433+
    By isaac in forum General
    Replies: 0
    Last Post: - 29th August 2008, 14:34
  2. Replies: 5
    Last Post: - 26th March 2006, 19:26
  3. Converting Stamp code
    By paul.mcallister in forum General
    Replies: 1
    Last Post: - 8th February 2005, 11:48
  4. converting long integer
    By jra in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th September 2004, 17:02
  5. Need help converting to PB Pro from Mbasic Pro
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 11th February 2004, 07:43

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