Pedro Pinto
- 20th November 2009, 14:07
Hello
I try to meassure the voltage of a lithium 3v Batterie with a PIC 18F4520
on pin PORTA.0, AN0 trough a 100k serie resistor
' Define parameters
Define ADC_BITS 10 ' 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
TRISA.0 = 1 'PORTA.0 as input
ADCON1 = %10001110 ' PORTA.0 analog and right justify result
ADCIN 0, adval ' read the chanell 0
Serout2 tx_485,bmode,["Bat Voltage = ",Dec adval,13,10]
Like the Define ADCON1 the Ref. is the VDD and that is 5.3V
The adval result value show 56704, that can't be correct, or?
What make i wrong?
Thanks for help
Best regards
Pedro
I try to meassure the voltage of a lithium 3v Batterie with a PIC 18F4520
on pin PORTA.0, AN0 trough a 100k serie resistor
' Define parameters
Define ADC_BITS 10 ' 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
TRISA.0 = 1 'PORTA.0 as input
ADCON1 = %10001110 ' PORTA.0 analog and right justify result
ADCIN 0, adval ' read the chanell 0
Serout2 tx_485,bmode,["Bat Voltage = ",Dec adval,13,10]
Like the Define ADCON1 the Ref. is the VDD and that is 5.3V
The adval result value show 56704, that can't be correct, or?
What make i wrong?
Thanks for help
Best regards
Pedro