Readadc on a 28x2?

rmtucker

Member
Why will the picaxe not allow a Symbol for the channel number ie-

Allows readadc 18,b1

will not allow

Symbol Adc_input = 18
readadc Adc_input,b1
 
There are only 12 ADC channels on that chip - readadc 18, b0 does not work either

Code:
readadc 12, b0
and

Code:
symbol adc_input = 12
 readadc adc_input
will both work.

Hope that helps :)
 

rmtucker

Member
The manual does state in the text that only the 40x2 has adcsetup2 but how else would you access the rest of the adc setup on a 28x2?
This code simulates ok but i still have the initial problem with the readadc instruction.

Code:
#picaxe 28x2

let adcsetup2 = 2

Symbol Headlamp_Output = b.1
Symbol Headlamp_Error_Flag = b11
Symbol Headlamp_Threshold = 80
Symbol Headlamp_Sense = b1
Symbol Headlamp_Switch = pinA.0

Main:

Headlamps:
		if Headlamp_Switch = 1 and Headlamp_Error_Flag = 0 then
			High Headlamp_Output
			else
			low Headlamp_Output
		endif
		Readadc 18,Headlamp_Sense
		If Headlamp_Sense > Headlamp_Threshold then
			Headlamp_Error_Flag = 1
			low Headlamp_Output
		Endif


goto Main
 

rmtucker

Member
Thank you i thought madness had set in.
But the manual states that adcsetup should be used to disconnect the digital buffers.
But then goes on to say that adcsetup2 is only available on the 40x2.
Can you try replacing the adc channel number with a symbol,Do you get a syntax error?
 

eclectic

Moderator
Thank you i thought madness had set in.
But the manual states that adcsetup should be used to disconnect the digital buffers.
But then goes on to say that adcsetup2 is only available on the 40x2.
Can you try replacing the adc channel number with a symbol,Do you get a syntax error?
Yes.

Code:
#picaxe 28X2
; version 18F25K22
; Firmware B.3
; PE version 5.3.4

symbol Sausage =19
main:
readadc 19, b1  ;passes Syntax

; readadc Sausage , b1  FAILS

sertxd (#b1,cr,lf)
pause 1000
goto main
 

Technical

Technical Support
Staff member
With the latest compilers you can currently use the ADC number or the port.pin e.g.

readadc 19,b1
readadc C.7,b1

we will look into why symbols don't work.
 

Technical

Technical Support
Staff member
See adcsetup in part 2 of the BASIC manual (make sure you are using the latest manual) - you do not need to use "let adcsetup(2) = " in the new style X2 parts as it is automatic.
ADCsetup is a word variable, so supports ADC0-15, whilst adcsetup2 does the rest.
It is a misprint to say it is for the 40X2 only, we will correct this.
 
Last edited:
Top