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



Tuesday, February 22, 2011

Ready.......Set.......Go!!!

Hi everybody, howz everyone doing.
With the mathematical and mechanical(simulations) ground work complete we are ready to actually build a Quad rotor of our own with the design specs. from the PRO Engineer/Solid Works model, and actually if I may say even controlling the Quad rotor. Now you might think I must be crazy. Well I just jumped a few steps or you may say a month's preparatory work to give you the good news. For any control technique that you may employ you will need the observation of variables being controlled. That observation will come from the various sensors that you will use. Even if you can't sense all the parameters of the aircraft you will at least need some of them and the rest can be estimated. In my experience if you have 3 angular velocities, 3  accelerations and 3 positions(x, y and z) you can estimate the remaining 6 parameter i.e. 3 angular positions and 3 linear velocities.
Now the problem of sensors is not straightforward. 9 DoF IMUs with on board gyro, accelerometer and magnetometers are available. The output of the IMU consists of acceleration in 3 axes, angular velocity about 3 axes and magnetic field intensity in the three axes. You might think, like we did at first "what the hell, double integrate the accelerometer and integrate the gyro readings and we have all the parameters that we want". It might be true in an ideal world, free of motor vibrations and white noise but not on our beloved planet Earth. Gyros and accelerometers have biases in their output and which compound on integration and with time the results diverge. Although with sensor fusion we can find attitude of the craft i.e. roll pitch and yaw but the same is not true for position estimation. I will be discussing these topics in detail in the next few posts.
Now to the controls portion. Once you have interfaced the sensors with the micro controller that you are using, you can use a simple PID controller and adjust the gains by hit and trial. Although it is a crude approach and one that I am not in favor of but still it works. But before all that fairytale begins you will have to select the motors, the drives, the sensors and estimate the states from them. So stay tuned as there is lots more to come.
Due to the lack of interest in  the documents I uploaded along with the last two posts, i am not going to be posting any documents from now on unless required by the post itself. Cheers.

Sunday, February 20, 2011

PRO Engineer and Solid Works.

Today was a day of frustration. But whatever s#!t happens.Some days just aren't "your days" Let us come to our topic for today i.e. PRO Engineer and/or Solid Works model of Quad Rotor. It's need and what should it accomplish.For those of you who have downloaded the paper with the mathematical model of quad rotor, might have observed that there are some constants that you cannot find through ordinary mathematical or any other simple method. These include mass(you can't find until you have the actual quad rotor body, by then it might be too late to change it), angular mass or moment of inertia and length. Basically the you need the PRO Engineer or Solid Works model to decide which motors you are going to select, which material are you going to use too build the craft and are they compatible with each other or not i.e. the total thrust of the motors should be greater (at least two times) than the weight of the craft. Plus you can't find moment of inertia by any simple method, so a simulation is the only way out. We used PRO Engineer and by changing the material you can find the mass and which one suits. You might want to check out the available propeller sizes before deciding on the length of quad rotor arms and the distance between the motors. I will try to post something about the prop. sizes in the near future. You might also wanna check out the available motors in the market or where ever to intend to buy them from. We bought the motors, the drives and the LIPOS from Hobbyking.
Some of you might have no idea about how to use PRO Engineer or Solid Works. The thing is that it was the same for us. Info. about just the basics of the software and a hard working group member might come in very handy to do the job.
Thats all for today. The paper that i uploaded yesterday didn't attract a lot of interest. Still I am going to upload something today, plus I will give you an intro to what is it all about.
Today I am uploading a project report from Lund university. Project reports are different from research papers in that they cover every aspect of the project. So fro beginners they are a very helpful tool. The author discusses each and every aspect of a quad rotor and the steps taken to reach the final result.
Link: http://www.megaupload.com/?d=3ER3WKJ8

Few Photos !





Saturday, February 19, 2011

What is this model............????

Today I will try to explain the strange (to some of you out there it might like look intimidating at first even like it did to us at first) mathematical model to which I gave a link yesterday. I am trying to explain everything from ground up, so some people who are familiar with these facts might have to wait some days before the interesting stuff like complimentary filter and sensor interfacing begins. I will also be mentioning which sensors we are using and why. Plus the all important motor drives and motors. But you will have to be patient for that. Not a lot just a lil.
Coming to today's topic of mathematical model, we have a total of 6 equations. All of these are second order differential equations. In the three differential equations governing the position of the system there are sine cosine terms of roll, pitch and yaw. These sine cosine terms come from the rotation matrix. To explain this we will have to consider two frames of reference i.e. the Earth frame of reference in which we eventually want to control the system while the other one being the quad rotor frame of reference. Now we know that the thrust forces are acting in downward direction in the quad rotor frame of reference. But these thrust forces might not be acting exactly downward when we are considering the Earth frame of reference. So in order to transform the forces from the quad rotor frame of reference to the Earth frame of reference, we use the z column (3rd column) entries of the rotation matrix.
BTW the rotation matrix changes form depending upon the type of Euler angles you are using. But there are many properties that hold for all rotation matrices that are available in the literature. That's all the explaining I am going to do for today. Tomorrow I will moving onto simulations in  PRO Engineer or Solid Works and the reason to do it.
Due to the interest that everybody has shown in ICRA2002 research paper, I am going to be uploading a research paper, project report or some other helpful material every day. These papers and reports were a great source of information for us when we started. You need not read each and every bit but at least it will give you an idea on how to proceed and how other people have gone about the task.
And for those of you out there wondering what was our inspiration..... The answer to that is STARMAC (http://hybrid.eecs.berkeley.edu/starmac/).
That's all I have to say for today. Hopefully see you tomorrow. Chao
Today's research paper : http://www.megaupload.com/?d=TGI49014
Feel free to ask me any questions at : wahabengineer@gmail.com

Friday, February 18, 2011

The start

Its been about 15 days since the last post. From here on I will be explaining our progress step by step.
As in every control system project the first step is to have a mathematical model of the system that is to be controlled. For those of you who have a strong background in Statics and Dynamics, it might not be very difficult to make a model yourself. For others, many people have proposed their models and published their results. One of the easiest mathematical is given in the research paper the link to which is given below.
The model contains 6 differential equations. Therefore in all there are 12 states that are to be controlled (6 velocities and 6 positions).
The model contains two terms that some of you might not have heard i.e. Euler angles and rotation matrix. The two are connected to each other. A lot of literature is available on the subject but the easiest is to watch a lecture delivered on the topic. I am giving a link to one(actually there are two of them) of those at the end of the post.
Thats all from me for the time being. I will be explaining the model and our selection of components in the future posts. Chao
Mathematical Model: http://www.megaupload.com/?d=R4K79DF5
Lectures : http://see.stanford.edu/see/lecturelist.aspx?coll=86cc8662-f6e4-43c3-a1be-b30d1d179743 (lectures 3 and 4)

Wednesday, February 2, 2011

My first post


This is my first post as a blogger so pardon my style.
This blog will be following the stabilization and development of a quad rotor at NUST College of EME, Pakistan. We have been working on the project for the last year now. To date we have made the following progress
  • Simulated the model of the aircraft in Matlab
  • Implemented Complimentary filter and tested it using actual readings from an IMU
  • Had a controlled flight of sort, the video of which is posted below.
We will be updating the blog periodically about the development right from the beginning. Here is just a touch of where we are now