Navigation bar
  Start Previous page
 103 of 283 
Next page End 98 99 100 101 102 103 104 105 106 107 108  

94
GetADC (subroutine form)
Type
Subroutine
Invocation
GetADC(pin, val)
Parameter
Method
Type
Description
pin
ByVal
Byte
The pin from which to read an analog voltage.
val
ByRef
Single
The variable in which to return the result.
Discussion
This function performs an analog-to-digital conversion on the signal present on the specified pin which
must be one of the analog port pins (see the table below).  The return value will be a 10-bit digital
approximation of the input voltage with a range from zero to the AVcc reference voltage (usually +5 volts)
scaled to the range 0.0 to 1.0.
You must make the pin an input before calling this routine.
The conversion is performed using the AVcc reference voltage (connected internally to Vcc on the ZX-24,
ZX-24a, ZX-24p, ZX-24n, ZX-24e, ZX-24ae, ZX-128e and ZX-1281e). 
Resource Usage
The ZX processors contain a single analog-to-digital converter thus allowing only one conversion to be
performed at a time.  The conversion process takes approximately 220uS during which time the calling
task will be awaiting conversion completion.
Only analog port pins may be used to perform an analog-to-digital conversion.  The analog port pins vary
depending on the ZX model and some ZX models have more analog input pins available.
Analog Ports and Pins
ZX Models
Port
Pins
Port
Pins
ZX-24, ZX-24a, ZX-24p, ZX-24n
PortA
13-20
-
-
ZX-40, ZX-40a, ZX-40p, ZX-40n
PortA
33-40
-
-
ZX-44, ZX-44a, ZX-44p, ZX-44n
PortA
30-37
-
-
ZX-24e, ZX-24ae
PortA
29-36
-
-
ZX-1281, ZX-1281n
PortF
54-61
-
-
ZX-1280, ZX-1280n
PortF
90-97
PortK
82-89
ZX-24e, ZX-24ae
PortA
29-36
-
-
ZX-128e, ZX-1281e
PortF
29-36
-
-
Compatibility
Although the BasicX manual indicates that that it is not necessary to configure the pin to be an input
before calling, tests indicate that it is, in fact, necessary to do so.  Consequently, the behavior of this
implementation matches the actual behavior of the BasicX platform.
Previous page Top Next page