When I was a student in my engineering school, we decided to build a drone. The project was abandonned after about one year, more or less because members of the robotic team didn't succeed to stabilize the drone. So with my bored engineer friend , we decided to give a second chance to this project. We took what the students made, which basically looks like this:

After a few tries, it turned out that the power of the 4 motors wasn't enough for the drone to fly. So, we decided to make another frame, using light materials: carbon tubes and balsa (it's a very light wood used by modelists for their aircrafts). The verdict was straightforward : old frame's weight : 350g, new one : 70g. Only half of the power was enough to make it fly.

We had here a nice frame to start our experiments. The first version came with an accelerometer and a gyroscope that we decided to keep. We also decided to use an Arduino because it's really easy to use, and there is out there a massive list of existing libraries. Implementing a PID controller, and gathering the commands of a 4 channels radio-emmiter, we were able to make it slighly steady. So this is how it worked. The 2 sensors (accel and gyro) are constantly read by the Arduino, which compute the angle of the 3 orientations of the drone. Why using a combination of a accelerometer and a gyroscope ? Because the accelerometer is nice for a static use of the drone (i.e. it flies at a constant speed), but as soon as it start to move, the accelerometer can't be used. The gyroscope gives us an angular velocity, which means that we have to integrate the value to retrieve the angle. The wrong part is that, due to the integration, the obtained angle will slowly drift. We compensate with a negative term in our equations, which is found experimentaly.

Basically :

Where, if the ADXL gives us a value between 0 and 1g:

And if the gyroscope gives us a value in ° per second, and the drift value.

Then, we use a PID to control each of the drone axis :

Now come the hardest part of that chemistry : find out , and ; which can bring the drone to destruction (actually, it did).

But still, there is a lot of work there before this drone can fly on its own. We are currently working on a frame v2, which will be the object of a soon-coming article.

Hi Ben,

I have a good experience in PID controller design, but I know that a PID controller takes the error or the difference between the actual measured value and the set value as an input to it. It was a little strange to me as why you used the angle measured straight away in your final PID equation! Shouldn't it be the error in the angle not the angle itself? I also know that a PID controller is used to reduce the error to almost zero in a short time; hence achieving the goal of making the controlled variable equal to the set point.

Would you explain to me the use of angle in the PID equation?

Thank you so much

Hi Moayad,

The PID formula is use with error , but since your desire angle is 0 degrees the angle and the error are the same.

Thank you dear. I appreciate your help.

You replied to my comment two years after I posted it. I am now replying to your reply more than one year after you posted it.

It's good we are still alive hahaha.

Hi,

Would you guys mind discussing how you tuned the PID controller for the quad? I've been trying to find adequate gain constants for my own Arduino quad but nothing has worked quite yet.

Thanks so much, I'm a big fan of guys' work!!!

After looking at the code of some other Arduino quads, I notice that they use two different PID controllers per axis, one to control the rate (dominated by the gyro readings) and one to control the position (which uses the output of the rate PID loop). Is this the approach that your quad used as well?

Hi, and thanks for your comment!

No we only used a single PID, which turned out to be satisfying in most cases. If you want a different flying behavior (such as needed for acrobatics, then you need this type of double PIDs)

Could you talk about how you guys tested the quad to find the PID gains? That would be really helpful to me; otherwise, great work guys!

Hi Harrison,

We first started by increasing slowly the P gain until the quad would try to correct the angle, then we increased the D gain to stabilize it. It is actually pretty simple to get something stabilizing itself, but it's much harder to get the perfect tuning ! 😀

Good luck 😉