cancel
Showing results for 
Search instead for 
Did you mean: 

First value in LIS3DSH is incorrect.

Hjoma.1
Associate

Hi,

i'm using the LIS3DSH to read data in different sampling rates (from 25 up to 1600), but in some cases i notice the first data in Z axe is not correct (some times it's too low or too high, for example, first data is -0.7g (or -1.5) and the rest are around -1g) and this happen with a random sampling rate, somethings happen when i use 100 hz and sometimes when i use 400 or 800. i even changed the anti-aliasing but i had no luck, the only think i can do is to wait until the value is updated in the sensor so i can get the next value at the start.

this is a snap of my code to about the state machine configuration

this is the initialization section:

AccelTxCmd(0x01, LIS3DSH_CTRL_REG3_ADDR); /* registers reset */
AccelTxCmd(0x00, LIS3DSH_CTRL_REG4_ADDR); /* make sure LIS3DSH is off */
AccelTxCmd(0x00, LIS3DSH_CTRL_REG3_ADDR); /* make sure IRQs disabled */
AccelTxCmd(0,LIS3DSH_CS_X_ADDR); /* constant shift for x axis*/
AccelTxCmd(0,LIS3DSH_CS_Y_ADDR);/* constant shift for y axis*/
AccelTxCmd(0,LIS3DSH_CS_Z_ADDR);/* constant shift for z axis*/
AccelTxCmd(0x4<< 3, LIS3DSH_CTRL_REG5_ADDR);
AccelTxCmd(<ThresholdValueHere>, LIS3DSH_THRS1_2_ADDR);
AccelTxCmd(0x19, LIS3DSH_SETT2_ADDR); /*diff data for State Machine 2 ,constant shift enabled */
AccelTxCmd(0xfc, LIS3DSH_MASK2_B_ADDR);
AccelTxCmd(0xfc, LIS3DSH_MASK2_A_ADDR);
AccelTxCmd(0x32, LIS3DSH_ST2_1_ADDR); /* state machine 2 first step : activate constant shift */
AccelTxCmd(0x05, LIS3DSH_ST2_2_ADDR); /* state machine 2 second step : any axis greater than threshold1_2 */
AccelTxCmd(0x11, LIS3DSH_ST2_3_ADDR);/* state machine 2 third step : restart state machine from beginning */
AccelTxCmd(0x9<< 4 | 0x7, LIS3DSH_CTRL_REG4_ADDR); /* Sampling rate + Axis Bitmap */

and i call this section every time i start the streaming:

AccelTxCmd(0x9<< 4 | 0x7, LIS3DSH_CTRL_REG4_ADDR); /* Sampling rate + Axis Bitmap */
AccelTxCmd(0x4<< 3, LIS3DSH_CTRL_REG5_ADDR);

after that i just keep reading data from sensor.

I'm not sure if the sensor need time to apply the configuration and the anti-aliasing and i need to wait for a delay before i start collecting the data, or i'm just skipping the first value by apply the delay since i'm using the continuous update option or i'm doing something wrong. and i hope someone can point them out for me.

Best regards,

Habib

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @Hjoma.1​ ,

A good general practice when you start collecting the data from a sensor after you have configured it, is to drop the first acquisition.

This is important especially when the (raw) data are then used to feed functions or algorithm involving integration steps, such as the calculation of the speed and the displacement from the acceleration.

The reason is that the internal logic of the sensor begins processing the signal when activated, and it the computation it might enter a value that is coming from the assessment phase of the MEMS, thus affecting the .

For example, if you have a look to a common accelerometer application note, such as the LIS2DW12 one, when the self-test procedure is described (p.45) it is suggested to discard the first converted sample, to avoid artifacts in the measure.

0693W00000DlR12QAF.png 

The suggestion is then to wait the Boot time after the startup phase (typ 5/10ms), configure the register and the start the acquisition discarding the first sample.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster. 

-Eleon

View solution in original post

3 REPLIES 3
Eleon BORLINI
ST Employee

Hi @Hjoma.1​ ,

A good general practice when you start collecting the data from a sensor after you have configured it, is to drop the first acquisition.

This is important especially when the (raw) data are then used to feed functions or algorithm involving integration steps, such as the calculation of the speed and the displacement from the acceleration.

The reason is that the internal logic of the sensor begins processing the signal when activated, and it the computation it might enter a value that is coming from the assessment phase of the MEMS, thus affecting the .

For example, if you have a look to a common accelerometer application note, such as the LIS2DW12 one, when the self-test procedure is described (p.45) it is suggested to discard the first converted sample, to avoid artifacts in the measure.

0693W00000DlR12QAF.png 

The suggestion is then to wait the Boot time after the startup phase (typ 5/10ms), configure the register and the start the acquisition discarding the first sample.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster. 

-Eleon

Hjoma.1
Associate

Hi @Eleon BORLINI​ 

Your answer was correct, i had to do few tests and i found out it's not only the first value, but the couple first values are wrong.

Thank you for your help

Glad to hear it @Hjoma.1​ ! You are welcome :)