hi!
ive been trying to get my adc working with my LM35CZ on a 16f677A and got a ref voltage of 2.55V on porta.3
heres the code
' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
'
' Connect analog input to channel-0 (RA0)
' Define LCD registers and bits
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
' Define ADCIN parameters
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
adval VAR WORD ' Create adval to store result
x VAR BYTE
temp VAR WORD
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000011 ' Set PORTA analog and right justify result
Low PORTE.2 ' LCD R/W line low (W)
Pause 500 ' Wait .5 second
loop:
adval = 0
For x = 1 TO 100
ADCIN 0, temp ' Read channel 0 to adval
adval = adval + temp
Next x
adval = adval/100
LCDOut $fe, 1 ' Clear LCD
LCDOut "Value: ", DEC adval ' Display the decimal value
Pause 100 ' Wait .1 second
GoTo loop ' Do it forever
End
dibt worry about any gramatical mistakes because it does work, but every time the temp sensor goes through a sundden change or i put my hand near any wires the lcd outputs a load of black squares. sometimes it corrects itself and other times it doesnt.
sonetimes to get it working again i need to reset the power.
any ideas?????
cheers,
phil
Bookmarks