2016-09-28 03:35 AM
Hi,
LIS3DH, I don't move it. Sampling rate 400 Hz, CTRL_REG2=0.+-2g full scale : (0g;0g;1g) out value+-4g full scale : (0g;0g;1g) out value+-8g full scale : (0g;0g;1g) out value+-16g full scale : (0g;0g;0,67g) out valueWhat is going wrong?
2016-10-04 02:16 AM
Can you please share you code how do you convert the raw data from sensor to g values?
Best regardsMiroslav2017-01-18 02:20 AM
Hi Miroslav,
I also experienced the same problem
.Are there any mistakes in this code?
// power-on
: // 2G-100Hz delay_100ms(); // delay 100ms i2c_write(CTRL_REG1, 0x57); i2c_write(CTRL_REG4, 0x00); // 2g delay_100ms(); // delay 100ms x = i2c_read(OUT_X_H)<<8 | i2c_read(OUT_X_L); y = i2c_read(OUT_Y_H)<<8 | i2c_read(OUT_Y_L); z = i2c_read(OUT_Z_H)<<8 | i2c_read(OUT_Z_L); printf('x:%d y:%d: z:%d\r\n', x, y, z); --> 'x:0 y:0 z:16448' ==> 1.004g // 4G-100Hz delay_100ms(); // delay 100ms i2c_write(CTRL_REG1, 0x57); i2c_write(CTRL_REG4, 0x10); delay_100ms(); // delay 100ms x = i2c_read(OUT_X_H)<<8 | i2c_read(OUT_X_L); y = i2c_read(OUT_Y_H)<<8 | i2c_read(OUT_Y_L); z = i2c_read(OUT_Z_H)<<8 | i2c_read(OUT_Z_L); printf('x:%d y:%d: z:%d\r\n', x, y, z); --> 'x:0 y:0 z:8064' ==> 0.984g // 8G-100Hz delay_100ms(); // delay 100ms i2c_write(CTRL_REG1, 0x57); i2c_write(CTRL_REG4, 0x20); delay_100ms(); // delay 100ms x = i2c_read(OUT_X_H)<<8 | i2c_read(OUT_X_L); y = i2c_read(OUT_Y_H)<<8 | i2c_read(OUT_Y_L); z = i2c_read(OUT_Z_H)<<8 | i2c_read(OUT_Z_L); printf('x:%d y:%d: z:%d\r\n', x, y, z); --> 'x:0 y:0 z:3968' ==> 0.969g // 16G-100Hz delay_100ms(); // delay 100ms i2c_write(CTRL_REG1, 0x57); i2c_write(CTRL_REG4, 0x30); delay_100ms(); // delay 100ms x = i2c_read(OUT_X_H)<<8 | i2c_read(OUT_X_L); y = i2c_read(OUT_Y_H)<<8 | i2c_read(OUT_Y_L); z = i2c_read(OUT_Z_H)<<8 | i2c_read(OUT_Z_L); printf('x:%d y:%d: z:%d\r\n', x, y, z); --> x:0 y:0 z:1216 ==> 0.593g2017-01-18 03:27 AM
Hello,
unfortunately in your code is not seen how do you convert the raw value to acceleration in g unit. I will try to explain it.
It seems you are using High Resolution mode. In this mode the output is 12-bit left-justified (in 2 x 8bit = 16 bit output register). So you have to divide the value by 16 (or shift right by 4 digits) and them multiplied by proper sensor sensitivity. The sensitivity is in datasheet in Table 4.Examples for you cases:
FS=2g: raw value 16448 ... 16448 / 16 = 1028, 1028 * 1mg/digit = 1028mg = 1.028g
FS=4g:
raw value 8064 ... 8064 / 16 = 504, 504 * 2
mg/digit= 1008mg = 1.008g
FS=8g: raw value 3968 ... 3968 / 16 = 248, 248 * 4mg/digit = 992mg = 0.992g
FS=16g: raw value 1216 ... 1216 / 16 = 76, 76 * 12mg/digit = 912mg = 0.912g
2017-01-18 05:37 PM
Hi Miroslav,
Thank you
,I understand.
I thought that FS (Full Scale) would be represented by 16 bits.
FS:16graw 32767(0x7fff) --> 16g * 32767/32768 = 16graw 1216 --> 16g * 1216/32768 = 0.593g2017-06-06 03:55 AM
Thank you for your answer. If I set the output as 8 bit resolution do I have to divide it by 16 then ? When the resolution is 8 bit, only the high registers in the axis output registers have value, the low registers are always zero. How do I calculate the g in this case ?
Please help.
2017-06-06 06:03 AM
If you use the low-power mode (8-bit output) you can simply multiply the high byte by the sensitivity.
FS=2g: 16mg/digit
FS=4g:
32
mg/digitFS=8g: 64mg/digit
FS=16g: 192mg/digit
2018-05-03 08:02 AM
Hello,
I face the same issue and i just use this methode:for(i=0; i<3; i++) { valueinfloat = ((buffer[(i<<1) + 1] << 8) + buffer[i<<1]) * sensitivity; pData[i] = (int16_t)valueinfloat; }where the sensitivity is given by the datasheet /* 0.06 mg/digit*/ for the 2G FS /* 0.12 mg/digit*/ for the 4G FS /* 0.18 mg/digit*/ for the 6G FS /* 0.24 mg/digit*/ for the 8G FS/* 0.73 mg/digit*/ for the 16G FSthe data with 16G FS can exceed the 20G with is wrong as i expect and i do not think i did a shock of 20G.2018-05-06 07:28 AM
ahmed.benamara
please specify the issue it is not clear. I explained how to convert raw values into g unit value in my previous posts.2018-05-06 09:06 AM
Sorry , the ic was LIS3DSH, in the lis3dsh i used the function below to convert raw values however when i was testing i give some shocks to the lis3dsh and read the values i saw the values exceed 16g and reach 20g i do not think my shock exceed 8g because when i tested with 8g full scale the values do not exceed 8g. could you please check if i had done a fault in converting raw data?