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.

orientation of model

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


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_a2 = design(d,'butter');
            H_a3 = design(d,'butter');
            d = fdesign.lowpass('N,F3dB',2,30/(FSa/2));
            L_a1 = design(d,'butter');
            L_a2 = design(d,'butter');
            L_a3 = design(d,'butter');
            d = fdesign.highpass('N,F3dB',2,3/(FSg/2));
            H_g1 = design(d,'butter');
            H_g2 = design(d,'butter');
            H_g3 = design(d,'butter');
            d = fdesign.lowpass('N,F3dB',2,30/(FSg/2));
            L_g1 = design(d,'butter');
            L_g2 = design(d,'butter');
            L_g3 = design(d,'butter');

Gyroscope_Z axis in degrees per second

enter image description here

Accelerometer_X axis in g

enter image description here

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

  1. If my method is correct for filtering and choosing the sampling rate, cutoff frequency, order of filter etc.

  2. If not, what filter parameters should I chose instead to get better results?

  3. If HPF for gyroscope is necessary?


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

enter image description here

enter image description here

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

enter image description here

enter image description here

PS: I found the these 3 and 0.05 HZ from the FFT analysis

enter image description here

  • $\begingroup$ Starting at the beginning: you should set up a program model that "looks like" the DUT; and then examine what is happening. Having said that: I am not familiar with this type of sensor but it seems to me that your HPF filtering is totally off. Your signal signature is on the order of 1-2 minutes but you are cutting out anything below .3 seconds; these numbers are just qualitative :) If you are trying to capture waveforms of minutes your lower frequency limit should be much lower. You have to specify what signals and accuracy you need at the start; now will do :) $\endgroup$
    – rrogers
    Apr 6, 2016 at 15:20
  • $\begingroup$ I have added the filtering at lower frequency. However, i am still not able to understand the response of gyroscope to the High pass filerting. Even at 0.05 Hz, it seems some datas are being filtered out. What can be done for HPF of gyroscope datas? $\endgroup$
    – bsnayak
    Apr 7, 2016 at 21:49
  • $\begingroup$ "The lowpass filter at 3 HZ gave me much better result."? Did you mean highpass? Let's back up a little: can you state requirements; or are you just investigating? For instance rise time/slope of the stimulus and expected error after filtering? Incidentally a Bessel filter is a filter that sacrifices some cutoff for excellent wave form reproduction. I have used it and it is really impressive; it is customizable: en.wikipedia.org/wiki/Bessel_filter It does have a time delay built in. Can I get you to relabel the graphs a little so that I know exactly what conditions hold? $\endgroup$
    – rrogers
    Apr 8, 2016 at 14:22
  • $\begingroup$ What "data is being filtered out"? I think this discussion should be moved out of the comments; but I don't know if the "hall monitors" like development work in the answers. If you are doing investigations towards the usability of this sensor (which I quite like) then: could you start posting links to data sets? Or start a "blog" where we can go into detail? The actual design process for this type of filtering requires details but is quite straightforward. And there is an alternative design technique that might be applicable. $\endgroup$
    – rrogers
    Apr 8, 2016 at 14:26
  • $\begingroup$ I am sorry for late reply, here are the datas. I also found that the frequency gets changed at higer speeds of rotation, in compared to lower speed. can you kindly suggest, which kind of filter and of which cut off frequency should be used from the folliwng datas of accelerometer? Thank you. link $\endgroup$
    – bsnayak
    Apr 19, 2016 at 12:37

1 Answer 1


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. Overlay

)2-b Filtered signal Filtered )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 pplot

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.

  • $\begingroup$ Thank you very much. It will help me a lot. Thank you very much for the PDF, i was looking for this kind of reference. $\endgroup$
    – bsnayak
    May 2, 2016 at 13:18
  • $\begingroup$ @bsnayak Here is a reference that I came upon: analog.com/en/analog-dialogue/raqs/raq-issue-139.html It doesn't directly address your problem but the author could probably answer any questions. I have found that the sales engineers from: Analog Devices, TI, and Linear Technology to be competent and very eager to help (they want a big order in their portfolio :) ) even in exceptional/small instances. $\endgroup$
    – rrogers
    Mar 7, 2017 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.