Thursday, September 11, 2014

IO sampling Using XBEE API ADC operation

IMG_2522In this tutorial I will show the ADC operation of xbee. Two xbee one is configured as coordinator API and another is router API. One analog pin of router xbee (ad0 pin, pin no.20) is enabled analog input.A variable resistor(pot) is used vary the analog input,you can use any sensor here. So the analog value will be sampled and convert it into a digital data then send it to the coordinator  using a frame called IO Data Sample RX Indicator.

XBee Analog and Digital IO Lines

XBee ZB firmware supports a number of analog and digital IO pins that are configured through software commands.
Analog and digital IO lines can be set or queried. The following table lists the configurable IO pins and the corresponding configuration commands.
image

Periodic IO Sampling

Periodic sampling allows an XBee/XBee-PRO module to take an IO sample and transmit it to a remote device at a periodic rate. The periodic sample rate is set by the IR command. If IR is set to 0, periodic sampling is disabled. For all other values of IR, data will be sampled after IR milliseconds have elapsed and transmitted to a remote device. The DH and DL commands determine the destination address of the IO samples. DH and DL can
be set to 0 to transmit to the coordinator, or to the 64-bit address of the remotedevice (SH and SL).
Only devices running API firmware can send IO data samples out their UART. Devices running AT firmware will discard received IO data samples.
First configure your coordinator xbee as ZigBee Coordinator API mode.
Then configure your router xbee as ZigBee Router API mode.
XCTU


Since router xbee collects the adc sample from ad0 pin so we have set the ad0 pin as analog pin.We also need a periodic sampling rate at which analog pin is sampled and send it to coordinator xbee. Suppose you want to get sample every 100 milliseconds then set IO sample rate as 64(64 is hex value of 100).

XCTU

Now the router xbee will sample the ad0 pin analog value every 100 milliseconds and send it to coordinator.
To ensure that it will send to coordinator I set destination address with my coordinator serial number.You can set to any xbee serial no. to send data to specific that xbee.

XCTU

Now write the configuration to the xbee module.
Okay, now give the connections.Since the adc pins of xbee are 1.2v tolerant so make voltage divider to fed it to ad0 pin.


image

Now give power in both xbee.To see the received sample connect the coordinator xbee with pc using XCTU.Open the terminal.If everything is ok then you will see a series of data frames is coming every 100milliseconds.

XCTU

If you vary the pot then you will see the frame data also changes.
That,s it! You can use this frames to get the sample data in microcontroller or pc.I already interface my xbee with my PIC18F4550 and send these data to a software using usb which plots the values.

IMG_2515

If have any confusion , you are most welcome to contact with me,put comments or mail me.Dont forget to share.

No comments:

Post a Comment