Problems about acceleration values via "av" shell command and "i2c" API

Hello everyone!
I am trying to write an user program with “i2c” API to get acceleration value from tag unit. I set my network with 1 initiator anchor and 1 tag. I found 2 problems about these acc values.

  1. When I use “av” shell command in Tara Term via USB connection, I can receive acc vlaues. However, I can’t understand these values. When the tag stay still, It seems that X has a mean value as 16400 while Y is 0 and Z is 100 or so. I have some data at below.

acc: x = 16448, y = 0, z = 208
acc: x = 16192, y = 48, z = 192
acc: x = 16416, y = 0, z = 48
acc: x = 16080, y = -80, z = 240

I dont understand why the X axis has such a big value. Does this X value include gravitational acceleration?
And What does these 3 axis mean? In what direction?Is the X axis straight down?

  1. I tried to code with “dwm_i2c_read” API to get acc value. This is my code:

                     **uint8_t data[6];**

** dwm_i2c_read(0x33 >> 1, &data, 6);**
** printf(“acc data=%d, %d, %d, %d, %d, %d\n”, data[0], data[1], data[2], data[3], data[4], data[5]);**

As u can see, I try to read acc vlaues from acclermeter, whose ID is 0x33. I want to keep these value in pointer data[]. Every two bytes of data represents the acc value of an axis.

Sometimes, I can get 6 bytes data like: acc data=64, 64, 0, 192, 0, 32
With base conversion it equals to 16448,192,32. which is approximately equal to what I receive with “av” Shell Command.

However, I would receive data out of order more often, like following:
acc data=254, 112, 64, 128, 0, 144 equals to 65136,16512,144
acc data=96, 64, 64, 0, 128, 254 equals to 24128,16384,33022
acc data=64, 48, 0, 144, 254, 32
acc data=0, 0, 96, 254, 32, 64

There is only few line with correct order (at least 64 is the first byte I think). Is there anyone can help me with this “dwm_i2c_read” API usage? Can u find any clue in my code or anyone can show me his code?

Thank you very much!

Well for the first problem, I read the following post

as it said, 16400/2^6*0.004 ~= 1.025g ~=10.045m/s^2
I guess this means the local gravitational acceleration at my position. Seems make sense.

Any idea? :smiley:
Thanks all

*same problem. Following. I think the major issue is that the documentation of dwm_i2c_read/dwm_i2c_write is unclear so that we don’t know how many bits to read and what are the associated behaviors after reading/writing.