**RESOLVED** ADC module, only getting a max count of 511

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

**RESOLVED** ADC module, only getting a max count of 511

Post by rmteo » Thu Feb 04, 2010 11:29 pm

First time using the ADC module with a PIC18F4620 to measure 0-5V. Works fine to 2.50V, beyond that, the result stays constant. I checked ADResult and it shows 511 counts from 2.50-5.00V. Any ideas what I'm doing wrong?
Last edited by rmteo on Sun Feb 07, 2010 5:28 pm, edited 1 time in total.

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Fri Feb 05, 2010 2:46 am

Are you sure you have your AD registers set correctly?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Fri Feb 05, 2010 3:19 am

I'm using the default from the sample ADIn.bas, what should they be?

Code: Select all

TRISA.0 = 1        // configure AN0 as an input 
ADCON1.7 = 1       // set analogue input on PORTA.0 

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Post by Jon Chandler » Fri Feb 05, 2010 3:27 am

Try changing the conversion time....I was having this same problem too, reading exactly half scale as maximum.

From the documentation:

sub SetConvTime(pValue as byte)
• pValue - ADC conversion time. Valid arguments are FOSC_2, FOSC_4,
FOSC_8, FOSC_16, FOSC_32, FOSC_64 and FRC. You should refer to your
particular device datasheet for further information.
Set the ADC conversion time

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Fri Feb 05, 2010 4:06 am

That did it. Thanks, Jon.

Post Reply