어... 단순하게 arctan으로 하면 땡~이 아니었던게야?!?!?!
void calc_xy_angles(void){ // Using x y and z from accelerometer, calculate x and y angles float x_val, y_val, z_val, result; unsigned short long x2, y2, z2; //24 bit // Lets get the deviations from our baseline x_val = (float)accel_value_x-(float)accel_center_x; y_val = (float)accel_value_y-(float)accel_center_y; z_val = (float)accel_value_z-(float)accel_center_z; // Work out the squares x2 = (unsigned short long)(x_val*x_val); y2 = (unsigned short long)(y_val*y_val); z2 = (unsigned short long)(z_val*z_val); //X Axis result=sqrt(y2+z2); result=x_val/result; accel_angle_x = atan(result); //Y Axis result=sqrt(x2+z2); result=y_val/result; accel_angle_y = atan(result); } |
[링크 : http://www.hobbytronics.co.uk/accelerometer-info]
[링크 : https://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf]
[링크 : http://www.st.com/web/en/resource/technical/document/application_note/CD00268887.pdf]
[링크 : http://www.analog.com/media/en/technical-documentation/application-notes/AN-1057.pdf]