cancel
Showing results for 
Search instead for 
Did you mean: 

LIS302DHL MEMS Accelerometer

oz
Associate II
Posted on December 30, 2009 at 04:19

LIS302DHL MEMS Accelerometer

3 REPLIES 3
oz
Associate II
Posted on May 17, 2011 at 13:35

i work on LIS302DHL MEMS accelerometer, and i want to know how to use it for calculate accurately angles, maybe someone can give me some tips.

thanks.

hbliek
Associate II
Posted on May 17, 2011 at 13:35

Something like this works. ax,ay&az are the raw readings from the SPI.

Code:

double vect = sqrt((ax * ax) + (ay * ay) + (az * az));

/* Only allow updates during gravity between 0.9 and 1.1G */

if((vect > MIN) && (vect < MAX))

{

// pitch_r = asin((double)ax / vect);

pitch_r = atan2((double)ax / vect, (double)az / vect);

pitch = (int16_t)((180. * pitch_r) / M_PI);

// roll_r = asin((double)ay / vect);

roll_r = atan2((double)ay / vect, (double)az / vect);

roll = (int16_t)((180. * roll_r) / M_PI);

}

oz
Associate II
Posted on May 17, 2011 at 13:35

thanks you, it's very helper me!