Problem using MPU6050

Hi, I am using MPU6050 for self balancing unicycle. I am using single axis of sensor. I am getting my tilt angle from following code.

double accXangle=(atan2(AcY,AcZ)+PI)RAD_TO_DEG; // Convert gyro raw vlues to degrees! double gyroXrate=(double)GyX/131.0; // Complementary Filter! double compAngleX = (0.97 * (compAngleX + (gyroXrate * dt))) + (0.03 * accXangle); //Serial.println("AcX = "); float a=31.142(compAngleX-5.35); float ang=a-90; return ang;

But the problem is that due to sudden movements of sensor, it gives random values which have nothing to do with sensor movement. For example when sensor is suddenly moved in positive direction of angle measurement, it gives -ve values for angle which then effect on pwm and thus direction of motor.

Can any one tell me where i am going wrong or why this is happening.

Do not double post.

Sorry for that. I must have done it by accident. But can you please help me with the problem.