I am trying to measure a voltage between 2.90V and 4.12V (from a RTD via a differential amplifier[MCP602]), and display this as a number between 0 and 1023.
My circuit has this voltage on AN0, and 2.9V on -Vref(AN2) and 4.12V on +Vref(AN3)
The programme is:
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 1
DEFINE ADC_SAMPLEUS 100
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
ADCON1=%10001000 '+Vref, -Vref, right justified
TRISA=255 'PortA analogue input
PT100 var porta.0
avg var word
temp var word
temp1 var byte
sign var byte
cnt var byte
cnt=0
avg=0
PAUSE 500
LCDout $FE,1 'clear LCD
LCDout "Temperature ="
main: ADCin PT100,temp
avg=avg+temp
cnt=cnt+1
pause 100
if cnt>3 then main
cnt=0
temp=avg/3
avg=0
LCDout $FE,$C0,DEC temp," "
goto main
Doesn't seem to work though, ADC reads 0! Looked though 16F870 datasheet, but can't see what I'm missing?
Bookmarks