Sunday, June 5, 2011

Getting your hands dirty with I.M.U.

Missed a post yesterday but I am back, and I hope that today's topic will interest a lot of people. In the last post I discussed update rate of an I.M.U, today I will discuss how to convert the raw data from an I.M.U into actual usable format.
As I mentioned earlier MEMS gyro gives you angular velocity, while an accelerometer gives you the acceleration vector at a certain instant. Separately these reading aren't particularly useful. Since we want to stabilize roll, pitch and yaw which are integrals of angular velocities. Now some of you might raise the question that why not just integrate the gyro readings and use them. The answer to this question is that sensors aren't ideal, they give noisy readings, from which noise has to be removed using different techniques. Another problem with observations is that you can't use the normally used IIR or FIR filters with non-zero group delays because any delay or phase change in your observation can render your control system absolutely useless.

The problem with gyro readings is that, it has a high white noise content. Shown above is the FFT of actual gyro readings Integrating it simply results in drift which means that the angles keep on increasing with time even when there is no actual motion. Many algorithms have been developed to counter this problem. They can be classified into two broad categories.
  1. Kalman filter
  2. Complimentary filters
I will discuss both of them in detail in the next few posts. For now it will suffice to say that although they have filter as part of their name, they are actually observers. On a separate note, we used complimentary filter, the reasons of which I will discuss in the future posts.
That's all from my side for the time being. See you 2moro. Chao

Friday, June 3, 2011

Long time no see......I.M.U

Hi there everybody, howz life....
It's been a long time since my last post, like four months or so. But now that our quad rotor has stabilized (yes at last we got the right set of P.I.D. gains), I will be posting a lot more often. Rather I will try to post everyday.
Coming to our topic of quad rotor, specifically where we left off last time, observation of attitude angles of the craft. As I mentioned last time, you will need an inertial measurement unit or an I.M.U. which has an accelerometer, a gyroscope and a magnetometer. All three of them three-axis. Now the selection of an I.M.U depends completely on your budget and how far you want to go.
The best approach is to purchase separate accelerometers, gyros and magnetometers and interface them with your main processing unit, if you have the time. The advantage of this approach is that you can get an update rate of your choosing. Making the update rate greater than the sampling frequency won't be beneficial, but the faster you can read the sensor, faster will be your loop.
Let me elaborate through our example. We had an I.M.U. which gave us an update rate of 70-80 Hz (RS 232 - one line of data in 10 ms approx). Now that data was raw data and we had to process. Plus we had to do the calculations for the control loop as well. So what we had to do is read a line of data and skip the next line, since we had to perform all the calculations. Eventually the control loop update of the motor drive came down to 30-40 Hz. Now all of you out there who have studied feedback systems, will know that faster the rate of your feedback loop, greater are your chances of stabilizing it.
Even if you do stabilize the craft at this update speed, you won't be able to make it dance like a gymnast. Now some of you might be thinking, a greater update rate can only be achieved through a higher sampling rate. You are right but not completely. An observer is the answer to this problem. An observer like Kalman filter can estimate a state for you even it is not available. More on that later.
For now it will suffice to say that even if you don't have a sensor with high sampling rate, you must be able to read it in a very small time. I2C and SPI are very good for that purpose. Smaller is this, easier it will be to stabilize the craft.
As for the availability of these sensors, sparkfun.com is a very good online store. They have a wide assortment of.......everything. That's all from my side for now. Tomorrow I will discuss how to get a usable reading from an I.M.U. If you have any queries write me at: wahabengineer@gmail.com. Thanks everybody. Chao