I work on proffesional PCB, I changed the capacitor, but the same problem. So, nevermind, without 100nF capacitance the AN0 is ok. Anyway is strange whats what happen there.
On AN0 I read the voltage from a linear sensor temperature (TC1047). The temperature slope is fixed at 10 mV/°C and the output voltage at 0°C is 500 mV (according with page4 from datasheet).
My ideea to extract the °C isn't ok because the maximum reading read on the input is 1024 ((1024-500) / 10 = 52.4 degrees) and the number of read bits is read in step 5, so only 256 bits.
The problem with me is that I do not read correctly the milivolts on 10 bit. Any ideea is apreciated, thank you !
Code:
'---------------------PROGRAM------------------------
MAIN:
gosub read_tc 'read analog value
gosub calc_voltage 'calculate the mVolts
gosub conv_temp 'conversion to degrees
lcdout $fe, $80, #tc 'displat TC and mVolt only for info
lcdout $fe, $C0, #mvolt , " Temp= " , #grd
pause 100
goto main
end
'---------------------Read AN0------------------------
read_tc:
z=0
for i = 1 to 100 ' average to 100 reads
ADCON0.1=1
WHILE ADCON0.1 = 1:pause1:WEND 'WAIT FOR CONVERSION
tc.HIGHBYTE = ADRESH
tc.LOWBYTE = ADRESL
z = tc + z
next i
tc = z/100
return
'--------------------Calc Voltage----------------------
calc_voltage:
mvolt = (tc * 5//1024)
return
'-------------------Convert Temp----------------------
conv_temp:
grd = (mvolt - 500)/10 'readed mVolt value - 500 (according with TC1047 datasheet)
lcdout $fe, $C0+4, " Temp= " , #grd
return
'--------------------lcd reset------------------------
lcdrst:
lcdout, $fe, 1
pause 10
return
21498D.pdf
Bookmarks