LIS2DW12 axis orientation (sign)
Hi,
I have a very simple (read: stupid) question in regards to the LIS2DW12 asix alignment (sign).
I have implemented my own driver, but it is heavily based on this code:
I basically does something like this:
data->x = static_cast<int16_t>(read_reg(REG_OUT_X_L));
data->x |= (static_cast<int16_t>(read_reg(REG_OUT_X_H)) << 8);
data->y = static_cast<int16_t>(read_reg(REG_OUT_Y_L));
data->y |= (static_cast<int16_t>(read_reg(REG_OUT_Y_H)) << 8);
data->z = static_cast<int16_t>(read_reg(REG_OUT_Z_L));
data->z |= (static_cast<int16_t>(read_reg(REG_OUT_Z_H)) << 8);When I read the x, y and z data I get the following output in the terminal:
measurement: x = -116, y = -744, z = 17068
measurement: x = -180, y = -812, z = 17156
measurement: x = -252, y = -712, z = 16800
measurement: x = -204, y = -864, z = 17480
measurement: x = -172, y = -772, z = 17000
measurement: x = -160, y = -844, z = 17276
measurement: x = -136, y = -800, z = 17200
measurement: x = -212, y = -756, z = 16884
measurement: x = -208, y = -792, z = 17076
measurement: x = -188, y = -744, z = 17136
measurement: x = -208, y = -700, z = 16948The chip is placed on the table with the sensor pointing upwards.
When I look in the datasheet I get the understanding that any positive force applied on the z-axis goes up - and since it is placed on the table only gravity is acting, meaning I should read a negative value. The full-scale value is +/-2g which seems to match well with 17000 (which is half of the 2g scale, considering that we have a int16 representation of -32,768 to 32,767... so I see 1g instead of -1g).
This is what I don't get from the datasheet:
And I actually see the same behavior on x and y axis (so signs are flipped on all axis).
Hopefully someone can pin-point the clear error I'm doing.
BR,
Carsten
