20x2 C.3 ADC input?

smeagol

Member
Hi,

I'm puzzled (nothing new there!)

20x2 rev c.3


Simple ADC input read.
10K resistor from pin to Gnd
1K resistor from source to pin
Voltage measured at pin C.3 is variable from 0 to supply (as expected)

Running this code:
Code:
[color=Blue]symbol [/color][color=Black]ButtonRead [/color][color=DarkCyan]= [/color][color=Blue]c.3

Let [/color][color=Purple]DirsC [/color][color=DarkCyan]= [/color][color=Navy]%10110100[/color]
[color=Blue]let [/color][color=Purple]adcsetup [/color][color=DarkCyan]= [/color][color=Navy]%0000001010000000[/color]

[color=Blue]symbol [/color][color=Black]ButtonValue [/color][color=DarkCyan]= [/color][color=Purple]b1[/color]
[color=Blue]symbol [/color][color=Black]Hundreds [/color][color=DarkCyan]= [/color][color=Purple]b15[/color]
[color=Blue]symbol [/color][color=Black]Tens [/color][color=DarkCyan]= [/color][color=Purple]b16[/color]
[color=Blue]symbol [/color][color=Black]Units [/color][color=DarkCyan]= [/color][color=Purple]b17[/color]

[color=Blue]ReadADC[/color][color=Black]:[/color]
[color=Blue]readadc [/color][color=Black]ButtonRead,buttonvalue[/color]
[color=Blue]bintoascii [/color][color=Black]buttonvalue,hundreds,tens,units[/color]
[color=Blue]serout [/color][color=Black]lcdserial, baudlcd, [/color][color=Blue]([/color][color=Red]"TT"[/color][color=Black],[/color][color=Red]"Val = "[/color][color=Black],hundreds,tens,units,[/color][color=Navy]0[/color][color=Blue])
pause [/color][color=Navy]500[/color]
[color=Blue]goto readadc[/color]
Just returns 0 all the time, as I see the voltage at pin c.3 vary.
If I change the input to c.1, i.e change the ButtonRead symbol to C.1 it works as expected.
I've tried another 20x2 and got the same result
I've double checked the circuit but can't see any errors, and I'm getting the expected voltages at the pin.

Searching the forum there was a post about silicon error on the base pic but I can't decypher the datasheet to confirm this.

Is my ADC setup wrong, I've checked and double checked but could be going blind.

Help
 

hippy

Technical Support
Staff member
This sounds like it might be an X2 ADC Channel Number issue. What happens if you use ...

READADC C.3, buttonvalue

I suspect that 'ButtonRead=C.3' is reading ADC channel 11 (B.6/ADC11), and needs to be 'ButtonRead=7' (C.3/ADC7).

It works for C.1 (C.1/ADC9) because C.1 has value 9.

The X2's can only auto-magically convert Pin Names to ADC Channel Numbers when used in a READADC command, not when specified through a SYMBOL command.
 

smeagol

Member
Cheers Hippy,

Using C.3 instead of the symbol works as expected. That's most of the day scratching my head trying to discover where I had made the mistake, trying to fault find my code and hardware instead of looking in the correct place:cool:

Can you specify the ADC channel as a symbol, if so how? As for maintenance of the code, and plans to revise the hardware in the future, I would like to have a symbol as it can easily be modified (and remembered).

Is this a limitation of the silicon or the interpreter?
 

pxgator

Senior Member
I think hippy has already answered your question. Did you try "symbol ButtonRead = 7" ??
 
Last edited:
Top