2009-12-29 07:19 PM
LIS302DHL MEMS Accelerometer
2011-05-17 04:35 AM
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.2011-05-17 04:35 AM
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); }2011-05-17 04:35 AM
thanks you, it's very helper me!