Choosing correct filter parameters for IMU sensor datas I have a IMU sensor breakoutboard using ITG3701, LSM303D LinkProduct. This involves accelerometer, gyroscope and magnetometer. I have connected the sensors to a Arduino and sending the datas to another computer over Xbee. My sensor is placed on a wheel along its radius. The controller sends data at every 100 ms delay. 



The frequency parameters for sensors , i have chosen to be

// Specify sensor full scale
uint8_t OSR = ADC_8192;  // set pressure amd temperature oversample rate
uint8_t Gscale = GFS_4000DPS; // gyro full scale
uint8_t Godr = GODR_190Hz;  // gyro data sample rate
uint8_t Gbw = GBW_low;  // gyro data bandwidth
uint8_t Ascale = AFS_16G; // accel full scale
uint8_t Aodr = AODR_200Hz;  // accel data sample rate
uint8_t Abw = ABW_50Hz;  // accel data bandwidth
uint8_t Mscale = MFS_2G; // mag full scale
uint8_t Modr = MODR_25Hz; // mag data sample rate
uint8_t Mres = MRES_HighResolution; // magnetometer operation mode


It can be changed to several other allowable limits given here

I want to process the sensor datas through two filters, first HPF (to remove DC components noise) and then LPF (to remove high frequency noise)

I want to do the following

Accelerometer_Raw ->  /HPF/  -> Accelerometer_HPF_datas -> /LPF/ -> Accelerometer_LPF_datas

Similarly 

Gyroscope_Raw ->  /HPF/  -> Gyroscope_HPF_datas -> /LPF/ -> Gyroscope_LPF_datas

On the receiver side, i did the following on the sensor datas

   FSa=200; % accelerometer sampling
        FSg=190; %gyroscope sampling



d = fdesign.highpass('N,F3dB',2,3/(FSa/2));
            H_a1 = design(d,'butter');
            H_a1.PersistentMemory=true;
            H_a2 = design(d,'butter');
            H_a2.PersistentMemory=true;
            H_a3 = design(d,'butter');
            H_a3.PersistentMemory=true;
            d = fdesign.lowpass('N,F3dB',2,30/(FSa/2));
            L_a1 = design(d,'butter');
            L_a1.PersistentMemory=true;
            L_a2 = design(d,'butter');
            L_a2.PersistentMemory=true;
            L_a3 = design(d,'butter');
            L_a3.PersistentMemory=true;
            d = fdesign.highpass('N,F3dB',2,3/(FSg/2));
            H_g1 = design(d,'butter');
            H_g1.PersistentMemory=true;
            H_g2 = design(d,'butter');
            H_g2.PersistentMemory=true;
            H_g3 = design(d,'butter');
            H_g3.PersistentMemory=true;
            d = fdesign.lowpass('N,F3dB',2,30/(FSg/2));
            L_g1 = design(d,'butter');
            L_g1.PersistentMemory=true;
            L_g2 = design(d,'butter');
            L_g2.PersistentMemory=true;
            L_g3 = design(d,'butter');
            L_g3.PersistentMemory=true;


Gyroscope_Z axis in degrees per second 



Accelerometer_X axis in g



I chosed the cutoff frequncy to be HPF to be 3Hz and for LPF to be 30 Hz. I found there is a very big difference with the gyroscope datas after filtering when the wheel rotates. The output datas are significantly reduced for gyroscope.There are also difference at the peaks of accelerometer datas measured. Hence, when i input this to Kalman, I am getting  lower velocty and the lower angle rotated. I have also verified that the output is wrong, as rotating a complete rotation gives me less than 2Pi radians after using filtering. 

My questions 


If my method is correct for filtering and choosing the sampling rate, cutoff frequency, order of filter etc. 
If not, what filter parameters should I chose instead to get better results? 
If HPF for gyroscope is necessary?


Additional:

After suggested the lower frequency limit should be much lower: I did the following High pass filtering at 0.05 Hz, The accelerometer datas are good, however i am somehow filtering out the content from Gyroscope datas





The lowpass filter at 3 HZ gave me much better result. 





PS: I found the these 3 and 0.05 HZ from the FFT analysis
1) HPF I would say you probably can't have one.
The  accelerometer has similiar considerations.

The gyroscope stream is in terms of xxx output=yyy angular velocity.  Any HPF analog or digital would sag to zero when you attach it to the hub of bicycle wheel or hub of a motor. 

The alternative to a HPF is "sample and hold" a value when the unit is at rest.  There are three alternatives.

1-a) During manufacturing take a string of readings at rest and store the value as an offset.

1-b) During power on do the same thing and tell the operator not to disturb it until a ready signal/light comes on.

1-c) Just live with the error of about 1/2 deg/sec ; or 1 rpm after 12 minutes.   That's as I read the error from your data.

If you are willing to live with the sag then I can do the calculations; but I keep thinking of the motor, or bicyclist, going faster and faster trying to keep up to the "speed".

An "alternative" is to differentiate the input and then integrate but that usually doesn't work out very well due to errors introduced during differentiation.

2) LPF

I got good results with a cutoff frequency .34 hertz and a fourth order bessel filter.  My octave 4 (a matlab like program) program and data are at:

https://www.dropbox.com/sh/av5w0qi4myc2tbm/AACxJllMNDsxT2x9nOvjFjMPa?dl=0
Here are the graphs for the first column of gyros.

)2-a Overlay of filtered output versus raw.


)2-b  Filtered signal

)2-c  Normal probability plot pplot()  Straight lines indicate that the errors are gaussian in distribution.  The lapse in the center is a deadband due to resolution


There are other tests but these exemplify the process.  I always check fittings with pplot (or relatives) to see if the fitting leaves gaussian in distribution.  The "staightness" fits into our visual system and is easy.  If not I want to know why; if so I want to know why :) The point is that for some (most?) process trying to dig into gaussian residues is a thankless task.  The truth is I would also look at the autocorrelation as well; but I doubt if you are interested.  One other thing is that one can also plot expected bounds on "straightness" if you want.  In fact this graph indicates that perhaps the filtering is excessive.