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"
Bookmarks