readadc10 input1 OR readadc10 1

greencardigan

Senior Member
I have a 5K POT connected to input1 of an 18X and when running the following code any values less than about 370 were coming in as 1023.

Code:
symbol getval = input1

do
readadc10 getval,w0
sertxd (#w0,13,10)
pause 250
loop
When I changed the first line to
Code:
symbol getval = 1
then it works as expected.

Am I doing something obviously wrong??
 

westaust55

Moderator
Your second example, that is: symbol getval = 1, is the correct way.

The format is;
READADC channel, variable -- for READADC10 variable must be a word which you have done correctly.

channel is automatically one of the possible analogue inputs on your PICAXE.

So READADC 1, variable will look at ADC input 1.


For some clarification:
On an 08M, there are 3 possible analogue channels being 1, 2 and 4 that are shared inputs.
On an 18X, there are 3 possible analogue channels being 0, 1 and 2 that are shared inputs.
On the 40X1 these is by default a dedicated port of 7 physically pins assigned as ADC input channels.
 
Last edited:

greencardigan

Senior Member
The funny thing is, symbol getval = input1 works for most but not all of the POTs range.

Hold on... I think I just found my mistake. :D Is this what is happening???

The value of input1 changes as I turn the POT. At a certain point (about 1/3 of supply voltage) it changes from 1 to 0. After it changes, my code starts reading from channel 0. :eek:
 

inglewoodpete

Senior Member
Spot on GC. You're addressing the input the wrong way. You are inadvertantly using indirect addressing. Input1 is a variable that returns the logical value on pin 1. The ReadADC then uses that logical value as a pointer to pin 0 or 1.
 
Top