I am using a pic16f886's ADC to convert an analog output from a weigh scales load cell. The sense wire from the scale is amplified x100 though a LM741 difference amp. Then the output of the amp is piped though a LM741 line follower. The output ranges from 0-5v when the ADC is not connected to it. However when the ADC is connected to the output of the line follower the voltage output gets capped off at around 600mv to 1v.
The adc converts the voltages from 0 to 1v although it stops converting after it capps off. I have an LCD module hooked up to display the values of the ADRESH to me. The value of this byte never reaches 11111111 but when the voltage maxes out at 1v the value of the register is about 000110010.
The adc is left to left justify and is set to use Vdd and Vss as reference also i have made sure to set the appropriate TRIS and ANSEL bits also i have correctly set ANSEL in ADCON0.
I am assuming that since I have the voltage ref to Vdd(5v) that it should not be capping at 1v. I have no idea why it is not accepting a full 5v input and any help or insight you guys could provide would be of great help and i would really appreciate it.
A sample of my adc code is below:
banksel TRISA ;Set the lcd data pins to output
movwf b'00100000' ;Set RA5 as input
movwf TRISA
banksel ANSEL ;Set RA5(AN4) to be analog input
movlw b'00010000'
movwf ANSEL
movlw b'00000000'
movwf ANSELH
;Set up the ADC-----------------------------
BANKSEL ADCON1 ;
movlw b'00000000' ;left justify and use Vdd and Vss as ref.
movwf ADCON1
movlw b'11010001' ;set frc clock, selecr AN4 to be the channel
banksel ADCON0
movwf ADCON0
RUNADC
banksel ADCON0
call SAMPLETIME
BSF ADCON0,GO ;Start conversion
BTFSC ADCON0,GO ;Is conversion done?
GOTO $-1 ;No, test again
banksel ADRESH ;
movf ADRESH,W ;Read upper 8 bits
banksel adBits
movwf adBits ;store in adbits
return
The adc converts the voltages from 0 to 1v although it stops converting after it capps off. I have an LCD module hooked up to display the values of the ADRESH to me. The value of this byte never reaches 11111111 but when the voltage maxes out at 1v the value of the register is about 000110010.
The adc is left to left justify and is set to use Vdd and Vss as reference also i have made sure to set the appropriate TRIS and ANSEL bits also i have correctly set ANSEL in ADCON0.
I am assuming that since I have the voltage ref to Vdd(5v) that it should not be capping at 1v. I have no idea why it is not accepting a full 5v input and any help or insight you guys could provide would be of great help and i would really appreciate it.
A sample of my adc code is below:
banksel TRISA ;Set the lcd data pins to output
movwf b'00100000' ;Set RA5 as input
movwf TRISA
banksel ANSEL ;Set RA5(AN4) to be analog input
movlw b'00010000'
movwf ANSEL
movlw b'00000000'
movwf ANSELH
;Set up the ADC-----------------------------
BANKSEL ADCON1 ;
movlw b'00000000' ;left justify and use Vdd and Vss as ref.
movwf ADCON1
movlw b'11010001' ;set frc clock, selecr AN4 to be the channel
banksel ADCON0
movwf ADCON0
RUNADC
banksel ADCON0
call SAMPLETIME
BSF ADCON0,GO ;Start conversion
BTFSC ADCON0,GO ;Is conversion done?
GOTO $-1 ;No, test again
banksel ADRESH ;
movf ADRESH,W ;Read upper 8 bits
banksel adBits
movwf adBits ;store in adbits
return