Hello everyone,

I am using a PIC18F4620 to read voltages but I am having aproblem where if I read anything in between 0 or 5 volts, the voltages readings are erratic or oscillate. I have tried using resistors or capacitors on the ADCIN pin but nothing seems to work. I have been trying to solve these for weeks now I have done a lot of research but can't find anything that gives light to what the problem is. I am powering my project with a USB port.

I also noticed that if I disconnect the cable that goes to the ADCIN pin, I still get erratic numbers instead of reading 0. I have tried with code to get an average reading but this makes the code run slow.

Any help on this will be highly appreciated.

Following is an exctract of my code that am using separately to solve the problem with the ADCIN:

DEFINE LOADER_USED 1 'Bootloader Used
@ __CONFIG _CONFIG1H, _OSC_HS_1H
DEFINE OSC 8
' OSCCON=%01110000
Define ADC_BITS 10
Define ADC_CLOCK 3
Define ADC_SAMPLEUS 50
adval var word
TRISA = %11111111
ADCON1 = %00000010
ADCON2.7 = 1
'ADCON0 = %11000001
Pause 500
Serout2 PORTD.0,16468,[$1b, $2a, $ff]
loop:
ADCIN 1, adval
pause 50
Serout2 PORTB.7,16468,[dec adval] ' to PC
Serout2 PORTD.0,16468,[$fe, 1]
Serout2 PORTD.0,16468,[dec adval] ' to LCD
Goto loop
End

Javier.