I try to get the Z-angle rotation of a GY-521 ( MPU 6050 ) but the angle rise static also if i don't move the sensor. Is there a way to "filter" the angle that he is correct for my case ?
Code:
float accel_z = accel_t_gyro.value.z_accel;
float accel_angle_z = 0;
float gyro_angle_z = gyro_z*dt + get_last_z_angle();
float unfiltered_gyro_angle_z = gyro_z*dt + get_last_gyro_z_angle();
float alpha = 0.96;
float angle_z = alpha*gyro_angle_z + (1.0 - alpha)*accel_angle_z;
output when sensor not moved:
x = x-roatation-angle z = z-roatation- angel
x z
8.37 4.24
8.35 4.22
8.33 4.21
8.32 4.19
8.31 4.18
8.29 4.17
8.28 4.15
8.26 4.14
8.25 4.12
8.23 4.12
8.22 4.10
8.21 4.09
8.19 4.07
8.18 4.05