Hi everyone, I've downloaded a program that measures voltages from http://microengineeringlabs.com/resources/samples.htm (vmeterx.bas), to measure 0-5VDC with 10-bit ADC and display the voltage with 2 decimal places. Is this only applicable for ADC using 10-Bit because I am using only 8-bits. See code:
' Define ADCIN parameters
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
adval VAR WORD
TRISA = %11111111
ADCON1 = %10000010
Pause 500
loop: ADCIN 0, adval ' Read channel 0 to adval (0-1023)
adval = (adval */ 500)>>2 ' equates to: (adval * 500)/1024
LCDOut $fe, 1 ' Clear LCD
LCDOut "DC Volts= ", DEC (adval/100),".", DEC2 adval ' Display the decimal value
Pause 100 ' Wait .1 second
GoTo loop ' Do it forever
End
Can someone help me, I want to measure that input voltage 0-5V using only 8-bits, the above code is only for 10-bits I guess, Is the code above applicable only for 10-bit? how do I measure voltage of inputs using 8-bits?
Bookmarks