Thursday, September 25, 2008

Real time accelerometer reading via xbee pro

I am working on a project transferring two axis accelerometer data as fast as possible to a pc via xbee pro. Here is what I have discovered:

  • At high speed the xbee picks up noise from the surrounding 50Hz, 220V.
  • I am able to use 5V for VCC, VREF as well as ADC input.
  • The highest transfer rates can be achieved by setting samples before TX (ATIT) to the maximum of 22 (0x16) and sample rate (ATIR) to 1 (ms). You should in theory be able to send data at 1kHz
  • The interface data is critical to be fast in able to read data fast. Xbee transfers data at 250kbps via RF, but the baud rate can only be set up to 115200 at standard data rates.
  • For non-standard data rates you could only set them via a terminal by using the command ATBD and then the speed. I nearly lost contact with one xbee when setting the data rate to 230400. The data sheet says that xbee should handle data rates up to this speed, but I could not talk to the xbee after setting this. I luckily discovered by trial and error that I could interface the device at 240000 baud, and that the true setting was really 250000 bauds (0x3D090).
  • With everything set to maximum I am able to transfer data at approximately 760kHz.

The xbee pack contains the following:
byte 1: 0x7E, the start byte
byte 2-3: packet size
byte 4: API identifier value
byte 5-6: Sender's address
byte 7: RSSI, Received Signal Strength indicator
byte 8: Broadcast options
byte 9: Number of samples to follow
byte 10-11: Active channels indicator
byte 12-N-1: 10-bit ADC values, sent like this: ADC1-MSB, ADC1-LSB, ADC2-MSB, ADC2-LSB and so on
byte N: Checksum of the values sent: see xbee data sheet

N=12+2*ADCs*ATIT, example: 2 channel accelerometer, ATIT=22 => N=12+2*2*22=100