I/O support
Queried sampling
XBee Wi-Fi RF Module User Guide
73
Analog samples are 10 bit values and aligned on a 16 bit boundary. The analog reading is scaled such
that 0x0000 represents 0 V, and 0x3FF = VREF. VREF may be either 1.25 V or 2.5 V based on the setting
of
, where 2.5 V is the default. The analog inputs on the device are
capped at 0x3FF. Analog samples are returned in order starting with AD0 and finishing with AD3. Only
enabled analog input channels return data as shown in the example below.
To convert the A/D reading to mV, do the following:
AD (mV) = (A/D reading (converted to decimal) * VREF) / 1023 where VREF may be 1250 or 2500
Assuming that AV is set to the default value, the reading in the sample frame represents voltage
inputs of 2385.14 mV (0x3D0) and 713.59 mV (0x124) for AD0 and AD1 respectively.
Queried sampling
can be sent to a device locally, or to a remote device using the API remote
command frame. When the
IS
command is sent and at least one I/O line is enabled as an input or an
output, the receiving device samples all enabled digital I/O and analog input channels and returns an
I/O sample. When no I/O line is enabled,
IS
returns an error. If
IS
is sent locally, the I/O sample is sent
out the UART or SPI port. If the
IS
command was received as a remote command, the I/O sample is
sent over-the-air to the device that sent the
IS
command.
If the
IS
command is issued in Command mode, the device returns a carriage return-delimited list
containing the above-listed fields. If the
IS
command is issued in API mode, the device returns an API
command response packet with the I/O data included in the command data portion of the response
frame.
The following table shows an example of the fields in an
IS
response.
Example
Sample AT response
0x01
[1 sample set]
0x0C0C
[Digital Inputs: DIO 2, 3, 10, 11 selected]
0x03
[Analog Inputs; A/D 0,1]
0x0408
[Digital input states: DIO 3,10 high, DIO 2,11 low]
0x03D0
[Analog input ADIO 0=0x3D0]
0x0124
[Analog input ADIO 1=0x120]
Periodic I/O sampling
Periodic sampling allows the XBee Wi-Fi RF Module to take an I/O sample and transmit it to a remote
device at a periodic rate. The periodic sample rate is set by
. If
IR
is set to 0 or
there are no active I/O lines, periodic sampling is disabled. For all other values of
IR
, data is sampled
after
IR
milliseconds have elapsed and transmitted to a remote device. However, the device cannot
keep up with transmitting an I/O sample more often than every three milliseconds. Therefore, when
IR
is set to 1 or 2, many samples are lost.
When Remote Manager is enabled (see
), samples are sent as a data stream. See
to learn how to view the data streams. When
DO
bits 0 and 3 are both set
(0x09), I/O samples are sent to the Remote Manager and to
DL
.
When Remote Manager is not enabled, the I/O sample is sent to the address specified by
. When
DL
points to another device, that device must have API mode enabled.
Otherwise, the data is dropped by the receiving device and is not sent out the serial port.