PDA

View Full Version : adcin problem



peterdeco1
- 13th February 2005, 11:25
Hello Everyone. Up to today, I thought I had a handle on the adcin command using a 12F675. Instead of posting my entire program, I'll just show you the relevant lines:

X VAR BYTE

ADCIN 1,X 'read pot
PAUSE X
GOTO PLAY

It takes up to 255 ms to get to play. It works perfect.

Now, I did this:

DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
X VAR WORD

ADCIN 1,X
PAUSE X
GOTO PLAY

I believe it should take up to 1024 ms to get to play, but it takes a little over 60,000 (1 minute). I understand a word variable can be a number up to 65,545 but a 10 bit adc reading isn't supposed to be over 1,024. Any ideas? Thank you. - Peter

Bruce
- 13th February 2005, 17:47
Right justify to get the correct value/PAUSE time for 10-bit.


DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
X VAR WORD
ADCON0.7=1 ' Right justification for 10-bit A/D

ADCIN 1,X
PAUSE X
GOTO PLAY