leemarrow
Full Member level 3
16f876 adcon1
Hi, i need to read negative voltage with a 16f876 on PORT RA1 connected to a LM35CZ (supply + 5 V and -5V).
i have used picbasic but it don't want read negative value:
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 = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' wait .5 second
Lcdout $fe, 1 'Clear screen
loop:
ADCIN 1, adval 'Start Conversion on RA1
pause 5
adval=(adval*10) */ 1250 'quantize
lcdout $fe,2 'cursore a home
lcdout $fe,$80,"Int ", dec2 (adval/100),".", dec1 (adval//100),$DF,"C"
'Display the decimal value on line 1
Pause 200 'Wait .1 second
Goto loop 'Do it forever
End
Hi, i need to read negative voltage with a 16f876 on PORT RA1 connected to a LM35CZ (supply + 5 V and -5V).
i have used picbasic but it don't want read negative value:
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 = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Pause 500 ' wait .5 second
Lcdout $fe, 1 'Clear screen
loop:
ADCIN 1, adval 'Start Conversion on RA1
pause 5
adval=(adval*10) */ 1250 'quantize
lcdout $fe,2 'cursore a home
lcdout $fe,$80,"Int ", dec2 (adval/100),".", dec1 (adval//100),$DF,"C"
'Display the decimal value on line 1
Pause 200 'Wait .1 second
Goto loop 'Do it forever
End