#### Introduction to PID Controllers : Using Quadcopter Hover

**PID controllers** are a great way to regulate an application to smoothly follow a value or a path. PID controllers are used whenever a system needs to tune an output based on some input value, **PID** techniques offer a neat starting point to implement a solution.

In this article, We shall cover the workings of a basic quadcopter altitude controlling unit based on the principles of PID controllers.

**Defining the problem:**

Say, we are starting at a point where we have zero knowledge about PID controllers and don’t know how to proceed. We just have a simple problem ahead of us. We are given a **quadcopter** and told that we “desire” to have it fly to an altitude of 100m from the ground and hover at the location.

Let us model this problem with this information. Our system is Quadcopter and the actuators are the motors powering the rotating blades. These together are termed as a “Plant”. This plant should now take a signal that should control the actuator and should give out some response to this input given. This response should be equal to the desired value (100m). Given below is our initial schematic diagram for this problem.

Since we want the values of the plant output or the controlled variable to be the same as that of the desired value we will need to find a way to compare them. A simple way is to calculate the difference between the two values and call it the error. Our goal then becomes to design a PID controller that takes in this error value and produces an actuating signal that will lead to the desired response thus, making the error zero.

Let us use a PID controller to solve our problem.

**P of PID stands for Proportional unit:**

The proportional unit will calculate the response by taking a direct proportional of the given input. In our case, the given input is the error difference. The proportionality constant is called the KP and this is one of the parameters that we tune to obtain the desired result.

However, what happens when the quadcopter reaches the 100m mark and the error becomes zero? Wouldn’t it just stop working for the instance and fall?

There is a certain rotation speed of the blades at which the quadcopter would hover. Say it is equal to 100rpm and the proportional unit has a gain of 4. Then at a height of 75m, the response would be 4*(100-75)rpm which is equal to 100rpm. But with this method, we will never be able to reach the exact 100m mark for this rpm. Even with a gain of 100, the copter will hover at 99m mark from the ground. This 1m difference in such a case is what we call a steady-state error.

How can we get rid of this steady-state error then??

**I of PID stands for Integral Unit:**

What if we can use past information to generate a part of our response. We can use past information by integrating the past values of our input to the given time. This way we can have a memory unit in our controller. Now say the quadcopter reaches a steady value below our desired mark. The error value is non-zero and when a non-zero value is integrated, we get an increasing total sum value (as X + x’ > X for positive x’). Therefore the increased response of the integral unit will force the quadcopter to rise above the undesired steady-state value and approach the desired mark of 100m.

At the 100m mark, the proportional unit will stop working but the integral unit will take care of the hover.

Since the integral unit is dependent on past information the path it takes to reach the 100m mark is of importance. What happens if the path is such that the summed error causes a speed greater than 100rpm and our copter overshoots the 100m? We need to counter this situation.

**D of PID stands for Derivative Unit:**

We need a unit in our controller which regulates its working as we approach the desired mark. we need a future predictor to tell our response to slow down to not overshoot. This is where a derivative unit comes into the picture. It will produce a rate of change of the error. The use of this will allow controlling the speed as it approaches the desired mark and gives us the required results.

**Conclusion:**

Viola, We have our PID Controller. We have understood the fundamentals behind a PID Controller control unit. You may now have a look at a model of this problem simulated in MATLAB. The model was autotuned to produce the results in the embedded report.

You may also refer to the video at the URL. It has great content for this topic. Hope you all enjoyed it. Any feedback would be greatly appreciated.

Want to publish your first robotic blog ?

Read the community guidelines and starting writing today !!!

TR Community Guidelines