cancel
Showing results for 
Search instead for 
Did you mean: 

Best Approach Using the LIS3DSH Accelerometer?

Terence D
Senior
Posted on May 27, 2018 at 18:12

Hi, I'm using an LIS3DSH in a case where I want to periodically (say once every 50 milliseconds) get the most recent X,Y,Z position of the accelerometer and perform a calculation.

My current approach is to just set a timer on my MCU to interrupt every 50 milliseconds.  During this interrupt routine I simply query the OUT_X, OUT_Y and OUT_Z registers of the LIS3DSH and then immediately perform my calculations.

I've configured the block data update value (in register CTRL_REG4) on the LIS3DSH to 'continuous' and I'm not using the FIFO feature either (FIFO_CTRL = 'Bypass mode: FIFO turned off').  Additionally, I've configured the output data rate (

in register CTRL_REG4) to 100 Hz.  

Am I correct to believe this will result in the OUT_X, OUT_Y and OUT_Z register values continually being updated with the very latest accelerometer position data every 10 milliseconds?

If so, this would make a worst case scenario of the X, Y, Z position data being 10 milliseconds old when performing my calculation, which is within my requirements.

I'd very much appreciate any feedback on my above approach being incorrect or less than optimal in any way.  Thanks.

-Terence

#lis3dsh
1 ACCEPTED SOLUTION

Accepted Solutions
Miroslav BATEK
ST Employee
Posted on May 29, 2018 at 11:03

Yes, I agree with you.

I'm sorry, I miss that point in your first post, you should set the BDU to 1 in CTRL_REG4 to avoid the discrepancy.

You could also use the DRDY signal so the MCU you receive an interrupt when new data are available, in this case you could read actual data with minimum delay.

View solution in original post

3 REPLIES 3
Miroslav BATEK
ST Employee
Posted on May 28, 2018 at 08:33

Yes, this assumption are absolutely correct.

Posted on May 28, 2018 at 21:22

Miroslav - Thank you for the feedback.  One concern: Since I have

the block data update value (in register CTRL_REG4) of the LIS3DSH set to 'continuous'

 I suppose it's possible when I read the OUT_X_L and OUT_X_H values they could be from two different readings right? 

I read these registers immediately one after another (OUT_X_L first then OUT_H_L) and I'm using I2C 'fast mode' (400 kHz) but it's possible the following could happen in the given order:

  1. I retrieve the value of OUT_X_L (register 0x28)

  2. The LIS3DSH internally updates the OUT_X_L and OUT_H_L registers with new readings

  3. I retrieve the value of OUT_X_H (register 0x29)

So, in other words, for my 16 bit X value (comprised of both OUT_X_L and OUT_X_H), I'm using the high bits from the most recent update and the low bits from the previous update.

Do you agree this is a possibility?

Miroslav BATEK
ST Employee
Posted on May 29, 2018 at 11:03

Yes, I agree with you.

I'm sorry, I miss that point in your first post, you should set the BDU to 1 in CTRL_REG4 to avoid the discrepancy.

You could also use the DRDY signal so the MCU you receive an interrupt when new data are available, in this case you could read actual data with minimum delay.