Interfacing Xbee with Accelerometer for data logging

triple-axis MMA7260QT accelerometer the X.Y.Z outputs need to be put into Xbee series 1 ADCs and transmitted to my other Xbee series 1 that is interfaced with my laptop via a XBee Explorer. I want to data log these 3 voltages for my first wireless project. However im having tons of problems trying to configure the radios and im unsure of the circuit layout. Ive been through all the usual steps to get help. digi, Xbee manual etc. Was wondering if anyone can add something to this to set me on the right track.

Regards lee

What settings have you tried?

You can export the modem settings to a text file from X-CTU and post them here.

Ive got my Xbees sending data its coming across in the terminal window of X-CTU as ASCII chars e.g

&. Vx1 . . . . . . . = . . . . . = . . . . . = . . . . . = . . . . . ? . . . ~.

&. Vx2 . . . . . . . @ . . . . . > . . . . . = . . . . . ? . . . . . ? . . . ~.

&. Vx6 . . . . . . . A . . . . . 1 . . . . . ( . . . . . ( . . . . . & . . . ~.

is this expected? if so how can i make sense of it to convert it into G ( as im using an accelerometer)

Look at the data in a HEX viewer then compare to the XBee data sheet.

I must assume that you are using XBee’s running 802.15.4 firmware. So look at page 12 of the 90000976 document to decode the data field. Then apply the conversion from the ADC units to the accelerometer voltage to G.

those values would be binary, non-displayable. You need software to handle the data. Simple to do.

waltr yes im running 802.15.4 firmware and have seen page 12 of the 90000976 document but all i can see is the packet make up and cannot understand how to decode it? What is the conversion I apply to the ADC units to the accelerometer voltage to G?

Stevech could you explain more?

thanks guys.

Well the XBee’s ADC value will be (Vin/Vref) * 1024 as in the data sheet. You are supplying a voltage to the Vref pin right?

What is the Accelerometer’s voltage per G? Look in the data sheet. Vacc = V/g

You get a number from the XBee as ADC.

the voltage from the accel is: Vadc = (ADC/1024) * Vref

and the G is: g = Vadc/Vacc

If there is an offset, say 0g = 1.0 Volt then Vadc needs to be subtracted from the offset before calculating g. The result could be positive or negative.

Did you look at your data with a Hex or binary viewer?

im sending 3.3V to Vref. as for V/g i can select either 800mV/g, 600, 300, 200 for sensitivities of 1.5g 2, 4, 6. What would the average g be of a person walking slowly on a treadmill?

I viewed the data in X-CTUs terminal tab. The data streams in, in the form described above but i can also switch to view it in Hex.

What would the average g be of a person walking slowly on a treadmill?

Zero g in the horizontal directions and One g in the vertical direction.

Do view the XBee data in X-CTU in the HEX mode.

My data comes in like this (&. Vx1 . . . . . . . = . . . . . = . . . . . = . . . . . = . . . . . ? . . . ~. ) also the Hex is viewable (see attachment) surely there should be recurring Hex characters to represent the “.”? I dont seem to be ale to find the packet ( as seen on page 12 of the data sheet) in amongst all this data.

First the “.” is showing a value that is not an printable ASCII character.

Second, I seemed to have stated the wrong DIGI doc. My very bad.

For the Series 1 & 802.15.4 use doc #900000982.

Ok, since the start of the data packet is "&. Vx " and can be seen in the left window of X-CTU

(I’m assuming this from your earlier post).

X-CUT doesn’t have the HEX code in the right window aligned with the ASCII in the left window

(learned this the hard way) so by using an ASCII table an ‘&’ is 0x26, a ‘V’ = 0x56, ‘x’ = 0x78.

The first occurrence of these values is on the top line as: 26 83 56 78 2F 00 05 0E 00 01 F1 02

EA 02 43 01 EE 02 EB 02 41 01 F2 02 EA 02 3E 01 F0 02 ED 02 44 01 F3 02 EA 02 43 01 C0 7E 00

Then it repeats.

You can now see that the first ‘.’ has a value of 0x83.

Now for the decoding. This is difficult the first time as the DIGI docs are very sparse on

describing the data format.

On page 13 of the doc is the data packet description.

It says that the first byte is the number of samples, the is 0x26 = 38d (38 decimal).

The next two bytes indicate which channels (pins) that are active (set as inputs).

This is 0x83 & 0x56 in hex but must be converted to binary to decode.

0x83 = 0b1000 0011, 0x56 = 0b0101 0110. This says that pins A0, D8, D6, D4, D2 & D1 are enabled,

this doesn’t make much sense if you do have 3 pins set as analog inputs.

So lets back pedel and reexamine the data. I do see the value 0x7E and know that API packets start

with this value. So an API data frame type 0x83 is mentioned on page 14 as a RX packet with 16bit addressing.

With this information the above data is re-synced to use 0x7F as the beginning and broken down as follows:

7E ; sync byte

00 26 ; number of bytes after this value (38 dec)

83 ; frame type

56 78 2F 00 ; 16bit source address

;; now the remained is the same as the data explained on page 13.

05 ;byte 1- number of samples- 5 samples for each channel

0E 00 ;bytes 2,3- channel indicator

;; A2, A1 & A0 inputs enabled and data for these follows

01 F1 ; first sample data for input A2

02 EA ; A1

02 43 ; A0

01 EE ; second sample of A2

02 EB ; and so on…

02 41

01 F2

02 EA

02 3E

01 F0

02 ED

02 44

01 F3

02 EA

02 43

01 C0

The first sample of channel A2 is 0x1F1 = 497.

The ADC Vref is 3.3V and 10bit, so the volatge on A2 is:

3.3V * 497/1024 = 1.60V

For 800mV/g setting. g = (1.60V *1000)/800 = 2.00g. I’m assuming that you have either some gain (op-amp) and/or a voltage offset so that both positive and negative G’s can be measured.

So to summarize:

Your XBee is sending data to the PC in API = 1 mode.

The Frame starts with 0x7E, followed by 2 bytes of the number of bytes that follow.

The frame type is 0x83.

The data comes from the remote module with the 16 bit address of 5678 2F00.

There are 5 samples from each input.

Only 3 analog inputs are enabled, A2,A1,A0.

The data sequence is: A2,A1,A0,A2,A1,A0…

I wrote out the process I went through to figure this out. I do hope you can follow the logic and the information in the Digi doc now.