Controlling Quadcopter Altitude using PID-Control System

— This work presents the stabilization of a quadcopter by using PID controllers to regulate its four basic movements: roll, pitch, yaw angles, and altitude. The quadcopter was originally equipped with sensors and software to estimate and control the quadcopter’s orientation, but did not estimate the current position. A GPS module, GPS antenna and a lidar have been added to measure the position in three dimensions. Filters have been implemented and developed to estimate the position, velocity and acceleration. The position controller maintains a constant position, while the trajectory controller maintains a constant velocity while travelling along a straight line. These position and trajectory controllers calculate the reference angles required to direct the thrust necessary to control the quadcopter’s movement. The system also consists of IMU (Inertial Measurement Unit) which consists of accelerometer and gyro sensors to determine the system orientation and speed control of four motors to enable the quadcopter fly. Simulations analysis of quadcopter is carried out using MATLAB Simulink.

INTRODUCTION A quadcopter is the most popular configuration of multirotor unmanned aerial robot, extensively for civilian applications [1,2]. In recent years, significant growth of interest is witnessed towards the academic research of the quadrotor. This is possibly attributed to their certain features, such as simple mechanical structure, hovering, and agile maneuverability. With the increasing requirement of autonomous flight under different conditions, control of the quadrotor is an important challenge.
Complex rotation and translation operations are also commonly encountered in the mathematical model, resulting in complex equations that have to be taken into account when designing control laws. On the other hand, the position control and attitude control of the quadrotor are extremely sensitive to external disturbance, such as wind gusts. Particularly, robustness issues may be critical for the control of quadrotor since they are subjected to the complicated dynamics and external disturbances. Several proper control methodologies for the quadrotor have been reported in the literatures, such as proportion integration differentiation (PID) control [3], backstepping control [4], sliding mode control [5], and model predictive control [6].

II. RELATED WORK
In order to weaken the effect of wind gusts, some authors have proposed complicated control techniques to achieve stability.
In the literatures [7,8] adaptive controllers of different structures were verified by simulations and experiments on test bench. For control of a multirotor aircraft, Salazar et al. [9] proposed a novel mathematical model of the wind gusts and designed a simple nonlinear control law to resist the wind disturbance. The effect of wind disturbance was discussed towards the issue of (unmanned air vehicle) UAV path planning in the literatures [10,11]. From the analysis, compensation control for the aircraft may be an effective method. Dong et al. [12] designed a flight controller with disturbance observer (DOB) to guarantee the highperformance trajectory tracking of a quadrotor. The DOBbased controller is robust to wind gusts without the use of high control gain or extensive computational power.
In the past years there has been increasing interest in Unmanned Aerial Vehicles (UAVs). Among different UAVs, quadrotors are of special interest in control from both theoretical and applied perspectives [13][14][15][16][17][18][19]. The quadrotor dynamics involve challenges such as parametric uncertainties, non-linearity, coupling and external disturbances [16][17][18][19]. A high-performance attitude control is a prerequisite for developing any other high-level control tasks [14,18]. In practical applications, the attitude of an UAV is automatically stabilized via an on-board controller and its position is generally controlled by an operator through a remote-control system [19].
In its motion, quadcopter have three main factors: roll, pitch and yaw. Based on the roll, pitch and yaw, state estimation of quadrotors attitude model is challenging. The rotors are directed upwards and placed in a square formation with equal distance from the center of mass of quadrotor. In the early days of flight, quadrotors were seen as possible solutions to some of the persistent problems in vertical flight. The Euler angle are three angles introduced by Leonhard Euler, which used to describe the orientation of a rigid body. To describe such an orientation in the 3-dimensional Euclidean space, three parameters are required and they can be described in several ways. Using zyx Euler angle we will describe the orientation of a frame of reference relative to another. Euler angle represents a sequence of three elemental rotations, since any movement can be achieved by combining three elemental rotations.

III. QUADROTOR DYNAMICS
The quadcopter's motion is governed by the lift forces, produced by the rotating propeller blades, whereas the translational and rotational motions are achieved by means of difference in the counter rotating blades. Specifically, the forward motion is achieved by the difference in the lift force produced from the front and the rear rotors' velocity, the sideward-motion by the difference in the lift force from the two lateral rotors, whereas the yaw motion is produced by the difference in the counter-torque between the two pairs of rotors front-right and back-left. Finally, motion at the perpendicular axis is produced by the total rotor thrust. The model of the quadcopter utilized in this paper assumes that the structure is rigid and symmetrical, the center of gravity and the body-fixed frame (BFF) origin coincide, the propellers are rigid and the thrust and drag forces are proportional to the square of propeller's speed. The body frame is fixed on the quadcopter. The origin is in the center of mass of the quadcopter, while Z axis ZB is pointing vertically upward and the X axis XB is pointing to rotor1.Based on this frame system, we define the translational position as [X Y Z] T and the angular position as [φ θ ψ] T First let us define the elementary rotations about X, Y and Z axis. (1) For , it means a single rotation of φ radius around X axis. Column 1, 2, 3 refers to the expression of the unit vectors of and in the inertial frame E. Similarly, and can be interpreted in this way. Finally, we can obtain the rotation matrix of the body frame relative to inertial frame: Where = and = . In the case of a quadcopter, there is gyroscopic torque generated by the rotating propellers. However, it is relatively tiny compared to the other terms in the equation. We can nullify this term for a simpler control model in the following design. (5) Divide both side by Icm, we obtain the equation for rotational dynamics.
- (6) Based on (5) and (6), we now have the equations for the state-space model (7) We define the trust and torque values as the control input of state space model PID CONTROLLER PID stands for Proportional, Integral, Derivative, it's part of a flight controller software that reads the data from sensors and calculates how fast the motors should spin in order to retain the desired rotation speed of the quadcopter.
The goal of the PID controller is to correct the "error'', the difference between a measured value (gyro sensor measurement), and a desired set-point (the desired rotation speed). The "error" can be minimized by adjusting the control inputs in every loop, which is the speed of the motors. ➢ "P" looks at present errorthe further it is from the set-point, the harder it pushes ➢ "D" is a prediction of future errors -it looks at how fast you are approaching a set-point and counteracts P when it is getting close to minimize overshoot ➢ "I" is the accumulation of past errors, it looks at forces that happen over time; for example, if a quadrotor constantly drifts away from a set-point due to wind, it will spool up motors to counteract it A quadcopter controller and plant system will be shown in simulink model as shown below  The desired yaw rate is typically taken directly from the following command input In this paper, the working and implementation of pitch, roll and yaw movement of quadcopter based on PID logic controller is presented. Mathematical modeling of quadcopter is done using MATLAB Simulink model. For stabilization of quadcopter, PID logic controller was chosen. PID logic was implemented successfully in MATLAB. A prototype of quadcopter is build using PID logic controller embedded on it. The working and performance of quadcopter is tested and desired outputs were obtained using PID controller. But, Ziegler-Nichols tuning method is more effective controller.