# How to filter vibration programatically?

I'm working on a quadcopter. I'm reading the accelerometer and gyro data out from the MPU6050 and using complementary filter to calculate the roll and pitch values. When the quad is on the floor, and the motors are turned on the roll values are:

-4.88675227698
-5.07656137566
7.57363774442
-3.53006785613
4.44833961261
-2.64380479638
-3.70460025582


It is very messy. After minus five there is plus seven. I would like to filter out this too high/low values programmatically but I have no idea how to do it.

EDIT: At this moment I think the solution is the Low-pass filter. I'll let you know if it is successful or not.

• When you say the quad is sitting on the ground, do you mean the motors are off? That data looks way too noisy for the motors off. How does your accelerometer and gyro data look? – ryan0270 Aug 21 '14 at 17:59
• There are several open source projects based on same or similar chips. Why not search and get them and take a look for inspirations? – EEd Aug 21 '14 at 19:56
• @ryan0270: The four motors were turned on when I got these values. The MPU6050 is mounted to the frame. – Alex Aug 21 '14 at 21:41
• @JohnWilliams: I was trying to find something useful, but I haven't found anything. I'll try the Low-pass filter. – Alex Aug 21 '14 at 21:46
• Some software take input from multiple sensor and do data fusion, that is, take best characteristic from different sensor and infer best data. Example is varesano.net/topic/freeimu youtube.com/watch?v=gU9vM0UE3Ug – EEd Aug 22 '14 at 6:25

I faced similar problem ,

My solution was:-

• 1- Record raw data for mpu6050 (6 DOF) , the chip should stay stable with no move
• 2- Apply kalman filter ( one dimensional on each data type , we are not trying to fuse data here .. ok :) )
• 3-Now you have a noiseless raw data that represents that the status with no move or (vibration)
• 4-Calculate the standard deviation for each type of data i.e (standard deviation for X axis, Y axis ... ) , you can also calcualte the standard deviation for multiple trials and finding the mean or average for them
• 5-Say we got 25 as standard deviation for X accelerator axis , you will put a condition
if(current_reading - previous_reading >
standard_devaition)  { accept this data as it doesn't represent
vibration  }


Essentially you are talking about a low-pass filter on your output. Kalman filtering is probably your best option for accuracy, but simply calculating a moving average should go a long way toward quieting the noise in your input.