Sei sulla pagina 1di 63

Declaration

We, the below named students of nal semester Electronics and Communications Department, B. V. Bhoomaraddi College of Engineering and Technology, Hubli-31 declare that the work entitled Control System of an Autonomous Quadrotor Unmanned Aerial Vehicle has been successfully carried out under the guidance of Dr. Uma Mudenagudi, Professor, Department of Electronics and Communications, BVBCET, Hubli. This dissertation has not been submitted for the award of any other degree or diploma.

Sagar Medikeri

USN 2BV06EC060

Shravan Kemtur

USN 2BV06EC070

Reshma Desai

USN 2BV06EC055

Vikas Vaddin

USN 2BV06EC080

Acknowledgement
We are and shall always be deeply obliged the uninching support and guidance of our beloved project guide Dr. Uma. K. Mudenagudi, Professor in Department of Electronics and Communications, whose excellence in this eld and constant inspiration has kept us motivated. We sincerely express our thanks for the help in providing all the required facilities and encouraging us throughout. We owe a special sense of gratitude to Dr. R. M. Banakar, our respected and beloved HOD for her valuable advices and encouragement. We also are grateful to Prof.B.L.Desai for his constant inspiration and encouragement. Our special thanks go to Prof. Arun C. Giriyapur of BVB Robotics Club who helped us immensely and provided us with all the facilities and equipments needed for the project. We are also grateful to our beloved principal, Dr. Ashok S. Shettar whose dynamism and single-handed eorts has inspired us to do something in time to come. We also extend our earnest gratitude to KLE society for having provided all the facilities. Last but not the least, we owe our gratitude to the teaching and nonteaching sta of Department of Electronics and Communication Engineering and our beloved parents and friends who have appreciated, encouraged and assisted us in our endeavours.

Project Associates

Control System of an Autonomous Unmanned Aerial Vehicle (UAV)


Sagar Medikeri Shravan Kemtur Reshma Desai Vikas Vaddin Department of Electronics and Communications, BVBCET, Hubli, India.
under the guidance of

Dr.Uma Mudenagudi June 12, 2010

Abstract In this project, we present the design details for the control system of an Autonomous Unmanned Aerial Vehicle (UAV) built around a quadrotor conguration. Quadrotor UAVs are being increasingly deployed in military warcraft and of late, they have also found varied applications in the eld of law enforcement, trac analysis and swarm intelligence. UAVs require sophisticated control system which are very challenging to build. Our focus in this project, is on the electronic control of the UAV rather than the mechanical aspects of its design. We propose a control system consisting of two stages - the Inertial Measurement Unit (IMU) and the UAV Flight Control. We demonstrate a low cost realization of IMU by fusing the output of MEMS sensors (accelerometer and gyroscope) using the Kalman Filter. The Kalman Filter takes input from both the accelerometer and gyroscope and returns an accurate estimate of the position of the UAV. We also describe the associated state modeling and optimization of the Kalman lter. We then demonstrate the superior performance of the Kalman Filter compared to raw sensor data. The attitude of the craft is synthetically generated in 3D using Processing software to provide a clear picture of the IMUs working. In ight control part, we achieve the ight of the UAV by dierentially controlling the speed of each of the four motors. A possible implementation of the motor driver and dierential speed control with PWM signals is shown. We implement the Proportional Integral Derivative(PID) controller to obtain error parameters for yaw, roll and pitch. These error parameters are then used to generate appropriate PWM signal for each of the four motors. We then present the tuning of PID controller for this application.

Contents
1 Introduction 1.1 Motivation . . . . . . 1.2 Problem Statement . . 1.3 Methodology . . . . . 1.3.1 IMU . . . . . . 1.3.2 Flight Control 1.4 Literature Review . . 1.5 Applications . . . . . . 1.6 Organization . . . . . 1 1 2 2 3 4 4 5 5 6 6 6 8 8 10 14 14 16 18 18 22 22 25 25 27 28 34

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

2 Inertial Measurement Unit (IMU) 2.1 Introduction to IMU . . . . . . . . . . . . . . . . . . . . . 2.2 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Sensor Mounting . . . . . . . . . . . . . . . . . . . 2.2.2 Reading the sensors . . . . . . . . . . . . . . . . . 2.2.3 Calculation of Euler Angles . . . . . . . . . . . . . 2.3 The Kalman Filter . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Introduction to The Kalman Filter . . . . . . . . . 2.3.2 Implementation . . . . . . . . . . . . . . . . . . . . 2.3.3 Kalman frequency . . . . . . . . . . . . . . . . . . 2.3.4 Tuning the Kalman Filter Covariance Parameters . 3 Flight Control 3.1 Quadrotor Flight Control with Dierential 3.2 Motor Control . . . . . . . . . . . . . . . 3.2.1 PID Controller . . . . . . . . . . . 3.2.2 PWM Generator . . . . . . . . . . 3.2.3 Motor Driver . . . . . . . . . . . . 3.3 Testbench . . . . . . . . . . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

Speed Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . .

. . . . . .

4 Results 36 4.1 Performance of the Kalman Filter . . . . . . . . . . . . . . . 36 4.2 3D emulation of IMU in Processing software . . . . . . . . . . 36

5 Conclusion and Future Work 42 5.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 A Circuit Diagram B I2C B.1 B.2 B.3 B.4 B.5 B.6 46 48 48 49 49 50 50 50 52 54 55

Data Transfer and Frame Format . Address Packet Format . . . . . . Data Packet Format . . . . . . . . Transmission modes . . . . . . . . Data Transfer from master to slave Data transfer from slave to master

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

C USART D List of Components E Chassis Specications

ii

List of Figures
1.1 1.2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 4.1 4.2 4.3 4.4 4.5 The airframe of the UAV . . . . . . . . . . . . . . . . . . . . Block diagram of UAV . . . . . . . . . . . . . . . . . . . . . . Block Diagram of IMU . . . . . . . . . . . . . . . . . . . . . The 6 Degrees Of Freedom . . . . . . . . . . . . . . . . . . Axes of accelerometer with respect to the UAV . . . . . . . Sensor module . . . . . . . . . . . . . . . . . . . . . . . . . Data format of Wii MotionPlus . . . . . . . . . . . . . . . . Data format of Wii Nunchuk . . . . . . . . . . . . . . . . . Euler angle calculation from Accelerometer . . . . . . . . . MATLAB plot of gyroscope values when UAV is stationary Kalman Filter Equations . . . . . . . . . . . . . . . . . . . . Kalman Filter performance when motors are on . . . . . . . Kalman Filter performance when motors are o . . . . . . . Quadrotor Flight Dynamics . . . . . Thrusts generated by a Quadrotor . PID Controller Block Diagram . . . RPM vs PWM . . . . . . . . . . . . Motor Driver Circuit . . . . . . . . . IRF540 . . . . . . . . . . . . . . . . IRF540 Transfer characteristic . . . IRF540 Output characteristic . . . . ILQ74 . . . . . . . . . . . . . . . . . ILQ74 Response . . . . . . . . . . . Motor Circuit of one channel . . . . Various PWM signals . . . . . . . . Testbench developed for PID tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3 7 7 8 9 10 11 11 13 16 19 21 23 24 26 28 29 30 31 31 32 32 33 34 35 37 38 39 40 41

Kalman Filter response when motors are o . . . . . . . . Kalman Filter response when motors are on . . . . . . . . Kalman Filter response when UAV is stationary . . . . . UAV attitude as seen in Processing . . . . . . . . . . . . . UAV attitude along with PWM values used for debugging

iii

A.1 Complete Circuit Diagram of the UAV . . . . . . . . . . . . . B.1 Data transfer from master to slave . . . . . . . . . . . . . . . B.2 Data transfer from slave to master . . . . . . . . . . . . . . .

47 50 51

iv

Control System of an Autonomous Quadrotor UAV

Chapter 1

Introduction
In this project, we propose to design the control system of an Autonomous Quadrotor UAV. UAVs are aerial vehicles capable of ight without an onboard pilot. While there are various congurations of UAVs in existence like airplanes and helicopters, the Quadrotor conguration is the most popular because of its mechanical simplicity and maneuverability. In a Quadrotor helicopter, lift is generated by four propellers mounted in a + conguration. We implement the control system in two stages - the Inertial Measurement Unit (IMU) and the Flight Control. The IMU reads the motion sensors and obtains the best estimate of the position of the UAV by Kalman Filtering the raw sensor data. The Flight Control module comprises of several subsystems which work in harmony to stabilize the ight of the UAV. We design a motor driver circuit to drive the motors. We generate appropriate PWM signals to achieve dierential speed control of motors. We implement a PID controller to improve the dynamic response of the UAV.

1.1

Motivation

The design of control system for a manually controlled UAV is a very challenging task. Making the vehicle autonomous increases this complexity manifold. The challenge arises from the fact that the UAV, being a ying robot requires accurate position sensing and fast dynamics. Accurate position sensing requires sophisticated sensor fusion techniques. Fast dynamics requires software optimizations and ecient control loop mechanisms. One of the driving forces behind the choice of quad-rotors is the mechanical simplicity as compared to the conventional helicopter conguration which, due to the swash plate mechanism is very complex. The varied applications of the UAVs are also a motivating factor. UAVs have traditionally been used by the military for reconnaissance operations and drone attacks. But, of late UAVs have found several new areas of appli-

Control System of an Autonomous Quadrotor UAV

Figure 1.1: The airframe of the UAV

cation like, search and rescue operations, law enforcement, remote sensing functions, aerial photography, etc.

1.2

Problem Statement

We propose to implement a control system for a quadrotor UAV in the following two stages: 1. To design an IMU for the UAV using MEMS accelerometers and gyroscopes and to implement the Kalman Filter for sensor fusion to get an accurate estimate of the position of the UAV in three-dimensional space. 2. To model the UAV ight dynamics and to design the electronics for accurate motor speed control and implement an ecient PID controller to improve the stability and real-time response of the UAV.

1.3

Methodology

The focus of this project is the electronic control of the UAV. Hence we procured a quadrotor chassis which is shown in Fig. 1.1. We follow a structured approach to implement the control system of a quad rotor UAV. The system is divided into two stages - the Inertial Measurement Unit (IMU) and the ight control. The IMU includes the Kalman Filter for sensor fusion and the Flight Control unit involves software and hardware implementation of the motor controller. Fig. 1.2 shows the system block diagram. Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

Figure 1.2: Block diagram of UAV

1.3.1

IMU

We design an IMU that measures the motion of the UAV along six degree of freedom (6DOF) - three translation axes namely X-, Y-, Z- axes and three rotation axes namely Yaw, Roll and Pitch. These parameters dene the orientation of the UAV in three-dimensional space and are collectively referred to as attitude of the UAV. For motion sensing, we use MEMS accelerometers and gyroscopes for their small size and easy interfacing. To keep our costs low, we hack the sensors from Wii game controllers, Nunchuk and Motionplus. The sensors are read by a microcontroller (Atmega32) using I2C interface. An ecient sensor fusion technique is required to make the gyroscope readings follow that of the accelerometer since accelerometers suer from noise and gyroscopes suer from drift. For this, we implement the Kalman Filter for its ability to combine noisy sensor readings and get clean, accurate estimates. First, we model the dynamics of the system in accordance with the framework of the Kalman lter and then, we implement the Kalman Filter equations using the matrices generated from the model. We then tune the Kalman Filter for optimum response by plotting the response of the lter against raw sensor readings in MATLAB. Tuning involves adjusting the Kalman lter parameters till an acceptable response is obtained.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

1.3.2

Flight Control

We achieve UAV ight by dierential speed control of motors. For ight control, we begin by modeling the ight dynamics in terms of thrust generated by the motors. The Flight Control stage consists of following subsystems: 1. Autopilot: This is the block responsible for autonomous ight. The path is pre-fed into the autopilot and the autopilot generates the present state (attitude/orientation)/ight mode required for the UAV. The autopilot ensures the UAV follows the path and constantly updates the state. 2. PID controller: The PID controller takes inputs from the IMU and the Autopilot and generates the dierential corrective signals. This is the error control block of the control system. The dierence between the required state (generated by the autopilot) and the current state (generated by IMU) gives the error signal. PID equations are used to generate error correction signals. 3. PWM generator: This block takes input from the PID controller and generates corresponding PWM waveforms proportional to the corrective signals using built-in timers in the microcontroller. 4. Motor controller: This is the motor driver circuit which takes PWM input and drives the motor.

1.4

Literature Review

There is a fair amount of published research with regards to quadrotor aircraft. Various researchers have used the quad-rotor platform for studies in control. The quad-rotor is an under-actuated system and therefore requires outside observer style sensors for full attitude and position control. The sensor systems on quad-rotor UAVs typically include an inertial measurement unit either commercially purchased or built by the research team for attitude estimation. The sensor fusion problem is usually solved by implementing the Kalman Filter [3], Extended Kalman Filter [1] or the Complementary Filter. In recent times, there has also been growing use of Direction Cosine Matrix (DCM) and quaternions for sensor fusion. The Quadrotor conguration being an under-actuated system has spawned a lot of research in innovative control methods. Sliding mode control, basic PID, and LQ control are just a few of the control methods that have been applied to the quad-rotor platform [12], [5], [8], [2], [10], [13]. In [11], an analysis is made between two popular control techniques used for UAV ight control namely the Proportional Integral Derivative (PID) Controller, which is a classical approach and a modern technique Linear Quadratic (LQ) approach, which is based on a more complete model. Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

Researchers have begun studying quadrotors for multi-agent cooperative missions called Swarm intelligence missions, their system dynamics and stability, and assisted manual control for tele-operation [4], [6], [10], [9]. SLAM (Simultaneous Localization And Mapping) has become a popular approach for this [7]. Since last few years, Radio-controlled UAVs are available commercially. Examples include the Silverlit X-UFO, the Draganyer X4 and the Mikrokopter. All three of these products use four rotors in conjunction with a control system that consists of gyroscopes for feedback. The Draganyer X4 additionally has an onboard camera for reconnaissance purposes. However, as these crafts are designed as high-end hobbyist crafts, they also come with a fairly steep price tag, as the Draganyer products are upwards of USD 1500 or more.

1.5

Applications

UAVs have traditionally been used by the military for reconnaissance operations and drone attacks. But, of late UAVs have found several new areas of application like, 1. Search and Rescue operations in calamity-hit regions 2. Aerial photography and environment assessment 3. By the government for law enforcement, trac congestion analysis 4. Aerial archaeology 5. Remote sensing functions which include electromagnetic spectrum sensors, biological sensors, and chemical sensors 6. Scientic research 7. For use in situations where it is hazardous to send humans.

1.6

Organization

In chapter 2, we describe the details of implementation of IMU. In chapter 3, we provide an insight into the ight control mechanism. It covers the motor control algorithm that we implemented and the various tests we conducted. In chapter 4, we compile the various results that were achieved. Finally, in chapter 5, we conclude the report and discuss about the future work in this direction.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

Chapter 2

Inertial Measurement Unit (IMU)


In this chapter we present the detailed description of the IMU. We begin with a brief introduction to IMU which covers the functions and composition of an IMU. In the next section we explore the sensors used to build the IMU. We also describe the procedure to read data from the sensors and calculation of the Euler angles. A detailed introduction to the Kalman Filter for Sensor Fusion follows. A mathematical description of implementation of the Kalman Filter is given. Finally we present the procedure to tune the Kalman Filter for optimum response.

2.1

Introduction to IMU

An inertial measurement unit, or IMU, is an electronic device that measures and reports on a crafts velocity and orientation using a combination of accelerometers and gyroscopes. IMUs are used to maneuver aircraft, including UAVs , spacecraft, shuttles, satellites, missiles and many more systems where there is a need to know the orientation, alignment of the vehicle at all times. The IMU is the main component of a control system of an UAV, hence it needs to be very precise and error free. If the IMU suers a failure the whole control system fails. The IMU provides several vital data which are essential to control the UAV. The IMU comprises of sensors and a lter to fuse the sensor data. Fig. 2.1 shows the block diagram of IMU.

2.2

Sensors

We implement the IMU using two sensors - accelerometers and gyroscopes. These sensors help the UAV to estimate its position along all six Degrees Of Freedom (6-DOF). All the six degrees of freedom are shown in Fig. 2.2.

Control System of an Autonomous Quadrotor UAV

Figure 2.1: Block Diagram of IMU

Figure 2.2: The 6 Degrees Of Freedom

The sensors used must not add signicantly to the weight of the UAV since weight is a critical component in UAV applications. Accordingly we use MEMS (Micro-Electro-Mechanical Systems) versions of accelerometers and gyroscopes. The IMU needs to be capable of detecting the slightest change in orientation and also rapid movements which the UAV will be subjected to, hence the sensors need to be highly sensitive and also have fast response. Subjected to these requirements and considering the cost factor, we use the sensors present in Nintendos Wii game controllers. The Wii nunchuck controller has a 3-axis accelerometer and the Wii motion+ has a 3-axis gyroscope. These sensors are ideally suited for the IMU since they are fabricated for a real time system with similar demands of precision and sensitivity. We interface the sensors using serial fast I2C protocol. The

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

Figure 2.3: Axes of accelerometer with respect to the UAV

sensors are given below: 1. Accelerometer (LIS3L02 - 3 axis, 2g, I2C output) 2. Gyroscopes (IDG600 - 2-axis, 500deg/s resolution, I2C output, X3500W - yaw gyro, crystal based, I2C output)

2.2.1

Sensor Mounting

It is crucial to make sure that the sensors are mounted in the proper way. We place the sensors such that the accelerometers axes coincide with the UAVs axes as shown in Fig. 2.3. The gyroscope is placed on the axes of UAVs centre of gravity. Fig. 2.4 is the actual picture of the sensor module.

2.2.2

Reading the sensors

The Wii sensors communicate using fast I2C. The Wii motion+ (WM+) has 2 ports, one to connect to the console and another pass-thru port to connect other controllers. We connect the nunchuck controller to the pass-thru port of the WM+ and the other port to Atmega32 microcontroller. Algorithm to read the sensors The algorithm for obtaining the data from the sensors is given below. 1. Send start signal Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

Figure 2.4: Sensor module

2. Send SLA+W with slave address as 0xA4 3. Send register address 0xFE 4. Activate the WM+ in pass-thru mode by sending 0x05 (writes to register location 0xFE) 5. Send restart signal 6. Send SLA+W signal 7. Send 0x00 (signals the WM+ to start sending data) 8. Send SLA+R (signals the WM+ that microcontroller is ready to receive data) 9. Receive 6 bytes of data 10. Repeat steps 5 to 9 The above algorithm is repeated every time the sensor data is to be read, at the end we will have two packets of 6 bytes each. Bit 1 of Byte 5 is used to determine which type of report is received : it is 1 when it contains MotionPlus Data and 0 when it contains extension data. Data Format The Wii Motion Plus reports its information as 6 bytes of data, the data from nunchuck and WM+ are sent alternatively with a bit in the packet mentioning which sensor data is being sent. The sensors are connected in what is called, Pass through mode. The data packet formats of nunchuck and WM+ are as shown in Fig. 2.5. Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

10

Figure 2.5: Data format of Wii MotionPlus

Yaw/Roll/Pitch fast/slow bits are 1 when the WM+ is rotating slowly (or not rotating at all), 0 when the WM+ is rotating fast. Extension connected is 1 when an extension is connected to the MotionPlus extension port. SX, SY are the Analog Stick X and Y positions, while AX, AY, and AZ are the 9-bit accelerometer data. BC and BZ are the state of the C and Z buttons. After receiving the data packets the data is rearranged to obtain the 6 sensor data. The sensor data is raw and needs further processing to obtain the accelerations.

2.2.3

Calculation of Euler Angles

After reading the sensor data, angles are calculated from both the accelerometer and the gyroscope. The physics involved is described below. Angle calculation from Accelerometers The accelerometer sensor data obtained are 9 bit, from 0 to 512. The value 256 which is the mid value corresponds to 0 acceleration, this value is termed as the bias value. Bias value is the value which denotes 0 acceleration. The values fom 256-512 correspond to positive acceleration and from 0-256 correspond to negative acceleration. Hence the sensor data is subtracted with 256 to obtain the acceleration values. Fig. 2.7 shows the accelerometer axis, theta is the pitch of the UAV. Due to the tilt of the UAV, components of earths gravitational force g act on

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

11

Figure 2.6: Data format of Wii Nunchuk

Figure 2.7: Euler angle calculation from Accelerometer

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

12

the accelerometer. The pitch can be calculated using: pitch = arctan(ay/az) Similarly roll can be calculated using: roll = arctan(ax/az) (2.2) (2.1)

Yaw cannot be calculated using accelerometer as rotational axis of yaw is perpendicular to g axis. Angle calculation from Gyroscopes The gyroscope data are 14 bit values, but the bias of the gyroscope keeps drifting hence there is no xed bias. The best way to approximate the bias value of the gyroscope is to take average of hundred samples when the UAV is stationary. Finding the Gyroscope Bias Values To obtain the bias values for Yaw, Roll and Pitch of the gyroscope the output of sensors was plotted in Matlab for 200 samples and then averaged. The values obtained are: 1. Yaw bias = 8278 2. Roll bias = 8145 3. Pitch bias = 7907 After the bias calculation the angular acceleration data can be obtained from the sensor data by subtracting it by the bias value. After experimentation we found that 20 represents turning at about 1 degree per second at low speed (Low speed bit = 1). So we need to divide by 20 to get the degrees per second. At high speed (Low speed bit = 0) 20 represents turning at about 5 degree per second. So we need to divide by 4 to get the degrees per second. Hence the equation to obtain angular acceleration from raw sensor data is : = (datagyro biasgyro )/scale (2.3) where, Scale = 20; Lowspeedbit = 1 4; Lowspeedbit = 0 To obtain the euler angles we need to integrate angular acceleration over the sampling period. = where, dt is the sampling period Department of Electronics and Communications, BVBCET, Hubli. (t)dt (2.4)

Control System of an Autonomous Quadrotor UAV

13

Figure 2.8: MATLAB plot of gyroscope values when UAV is stationary

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

14

Using the above equation and the sensor data from the 3 gyroscopes we calculate yaw, roll and pitch. Gyroscope bias is subjected to drift which causes error in the angle calculation. Integration has a cascading eect on the error, causing the calculated values to be unreliable after a certain period of time. Need for Sensor Fusion Observing the accelerometer plots we can conclude that accelerometer values are very noisy and aected a lot by vibration. They cannot be used as a standalone sensor for IMU. Though gyroscope readings are not aected by vibration, they suer drift which makes them ineective as a standalone sensor for IMU. To make a reliable IMU we use both the sensors. We make use of the gyroscopes ability to be insulated by noise and vibration and the fast response of the accelerometer. The drift of gyroscope is countered by correcting it periodically using accelerometer values. Kalman lter is one such lter which is very ecient in sensor fusion.

2.3
2.3.1

The Kalman Filter


Introduction to The Kalman Filter

The Kalman lter is a set of mathematical equations that provides an efcient computational means to estimate the state of a process, in a way that minimizes the mean of the squared error. The lter is very powerful in several aspects: it supports estimations of past, present, and even future states, and it can do so even when the precise nature of the modeled system is unknown. The Kalman lter addresses the general problem of trying to estimate the state X of a nth order discrete-time controlled process that is governed by the linear stochastic dierence equation: Xk = AXk1 + BUk1 + Wk1 with a measurement Z that is: Zk = HXk + Vk (2.6) (2.5)

The random variables Wk and Vk represent the process and measurement noise respectively).They are assumed to be independent (of each other), white, and with normal probability distributions: p(w) N (0, Q) p(v) N (0, R) Department of Electronics and Communications, BVBCET, Hubli. (2.7) (2.8)

Control System of an Autonomous Quadrotor UAV

15

In practice, the process noise covariance Q and measurement noise covariance R matrices might change with each time step or measurement, however here we assume they are constant. The n n matrix A in the dierence equation relates the state at the previous time k-1 step to the state at the current step k , in the absence of either a driving function or process noise. In practice A might change with each time step, but here we assume it is constant. The nl matrix B relates the optional control input u (of order l ) to the state X. The m n matrix H in the measurement equation relates the state to the measurement Zk . In practice H might change with each time step or measurement, but here we assume it is constant. The Kalman lter estimates a process by using a form of feedback control: the lter estimates the process state at some time and then obtains feedback in the form of (noisy) measurements. As such, the equations for the Kalman lter fall into two groups: time update equations and measurement update equations. The time update equations are responsible for projecting forward (in time) the current state and error covariance estimates to obtain the a priori estimates for the next time step. The measurement update equations are responsible for the feedback i.e. for incorporating a new measurement into the a priori estimate to obtain an improved a posteriori estimate. The time update equations can also be thought of as predictor equations, while the measurement update equations can be thought of as corrector equations. Indeed the nal estimation algorithm resembles that of a predictor-corrector algorithm for solving numerical problems as shown in Fig. 2.9. The time update equations project the state and covariance estimates forward from time step k-1 to step k. The measurement update rst computes the Kalman gain, The next step is to actually measure the process to obtain , and then to generate an a posteriori state estimate by incorporating the measurement. The nal step is to obtain an a posteriori error covariance estimate. After each time and measurement update pair, the process is repeated with the previous a posteriori estimates used to project or predict the new a priori estimates. This recursive nature is one of the very appealing features of the Kalman lter-it makes practical implementations much more feasible than (for example) an implementation of a Wiener lter which is designed to operate on all of the data directly for each estimate. The Kalman lter instead recursively conditions the current estimate on all of the past measurements.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

16

Figure 2.9: Kalman Filter Equations

Filter Parameters and Tuning In the actual implementation of the lter, the measurement noise covariance R is usually measured prior to operation of the lter. Measuring the measurement error covariance R is generally practical (possible) because we need to be able to measure the process anyway (while operating the lter) so we should generally be able to take some o-line sample measurements in order to determine the variance of the measurement noise. The determination of the process noise covariance Q is generally more dicult as we typically do not have the ability to directly observe the process we are estimating. Sometimes a relatively simple (poor) process model can produce acceptable results if one injects enough uncertainty into the process via the selection of Q . Certainly in this case one would hope that the process measurements are reliable. In either case, whether or not we have a rational basis for choosing the parameters, often times superior lter performance (statistically speaking) can be obtained by tuning the lter parameters. The tuning is usually performed o-line, frequently with the help of another (distinct) Kalman lter in a process generally referred to as system identication.

2.3.2

Implementation

To implement kalman lter for sensor fusion we develop a state space model of the IMU. Gyroscope angle measurements are more accurate and less prone

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

17

to vibration and jitter, hence we use them for obtaining the angle estimate in the kalman lter. To counteract the drift suered by the gyroscope we use the angle measurements from accelerometer to periodically correct the drift, hence accelerometer input acts as feedback or corrector equations. State model of IMU To implement the kalman lter we formulate the state space model of the IMU. We model the euler angle calculation in the form of two linear stochastic equations as shown in Eqns. 2.5 and 2.6. The Gyroscope output is used for the state estimation. The accelerometer output is used for the state correction. The gyroscope measures angular acceleration. Integrating this acceleration, we get the angle of swing. The equation to measure the angle of swing using gyroscope output is: = ((t) bias)dt (2.9)

where, ((t) bias) gives the angular acceleration. Accelerometer outputs the linear acceleration. Thus, the roll and pitch angles can be computed as follows. pitch = arctan(ay/az) (2.10) roll = arctan(ax/az) (2.11)

where, ax, ay, az are the acceleration components along X-, Y-, Z- directions - obtained from the accelerometer. Using the above equations we can develop the state model for obtaining euler angles from sensors. The state space equations are as follows: Xk = AXk1 + BUk1 + Wk1 Zk = HXk + Vk where, Xk = A= B= (k) bias(k) 1 dt 0 0 dt 0 (2.14) (2.15) (2.16) (2.17) (2.12) (2.13)

Uk = [gyro (k)] Wk is the process noise, Qk is the covariance of Wk Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

18

Qk =

AccRM Snoise 0 0 GyroRM Snoise

0.001 0 0 0.003

(2.18)

Zk = [accelerometer ] H= 1 0

(2.19) (2.20)

Vk = Measurement Noise, Rk is the Covariance of Vk Rk = 0.3 (2.21)

2.3.3

Kalman frequency

The frequency of execution of the kalman lter loop is known as the kalman frequency. For the IMU output to be real-time and accurate the kalman frequency should be suciently high. The sampling rate of the sensors has to be same as the kalman frequency. This is achieved by reading the sensors before the execution of each kalman loop. The inverse of the sampling rate gives the sampling period dt. The main loop containing the code for sensor reading and kalman lter is executed once every dt period of time. dt is calculated using the inbuilt timers in the microcontroller. The average sampling period in our application is about 15 ms and hence the sampling rate is about 65Hz. This sampling rate is sucient for the ecient working of IMU.

2.3.4

Tuning the Kalman Filter Covariance Parameters

The performance of the Kalman Filter is improved by ne-tuning the noise correlation parameters. The need for tuning arises because these parameters are dependent on the accuracy of the sensors. This is in reference with the Covariance Matrix of Process noise, Qk which is reproduced here. Qk = AccRM Snoise 0 0 GyroRM Snoise = 0.001 0 0 0.003 (2.22)

The Accelerometer RMS noise parameter Qangle and the Gyroscope RMS noise parameter Qgyro have to be properly set. Otherwise, the Kalman Filter output will be biased to either Accelerometer or Gyroscope output. If the value of Qangle is set lower than the actual Accelerometer RMS noise or if the Qgyro value is set too high than the actual Gyroscope RMS noise, the Kalman lter output follows the Accelerometer output more closely making the output very noisy as shown below.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

19

Figure 2.10: Kalman Filter performance when motors are on

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

20

On the other hand, if the value of Qangle is set too high than the actual Accelerometer RMS noise or if the Qgyro value is set too low than the actual Gyroscope RMS noise, the Kalman lter output lags the Accelerometer output making the output very delayed. As seen in Fig. 2.11, the Kalman lter curve (Red) lags the Accelerometer curve (Green). Thus, tuning is required.Tuning is done by trial and error, correcting the parameters, Qangle and Qgyro and plotting the results in Matlab. The process was repeated till the Kalman lter response was smooth enough to eliminate Accelerometer noise, and also quick enough to prevent any delay in the response. Accordingly, the parameters were nally tuned to the values given below. 1. Qangle = 0.0005 2. Qgyro = 0.003 The Covariance Matrix of Measurement noise, Rk is a parameter reecting how much jitter is expected from the Accelerometer. This parameter, by intuition, is set as Rangle = 0.3 radians.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

21

Figure 2.11: Kalman Filter performance when motors are o

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

22

Chapter 3

Flight Control
In this chapter, we present an overview of the theory of Quadrotor UAV ight control. We then explain what a PID controller is, how it is implemented and how it is tuned for the application at hand. In the succeeding subsection, we explain how PWM signals are generated both in the software and hardware domains. This is followed by a technical description of the Motor driver circuitry. We describe each component used in detail and the Circuit protection measures employed. Finally, we show how a testbench can be built to do ight tests which will be helpful in tuning PID loops and debugging.

3.1

Quadrotor Flight Control with Dierential Speed Control

Quadrotor uses four xed pitch rotors as shown in Fig. 3.1. Each motor+rotor produces two forces 1. Upward thrust due to displacement of air. 2. Rotory thrust opposite to the direction of rotation of rotors. The upward thrust is directly proportional to pitch of the blade, the area of the rotor and square of the speed of rotation. Quadrotor design uses dierential thrust to control the movement by varying only the speed of the motors. Hence, no complicated swash plate mechanism is required as in case of a conventional helicopter. The mechanical design is thus simplied compared to conventional helicopter. If all the motors of the UAV rotate in the same direction, it results in the whole UAV spinning about z-axis. Hence to prevent this, two adjacent motors are rotated in opposite directions i.e 2 clockwise motor+rotor and 2 counter-clockwise motor+rotor.

Control System of an Autonomous Quadrotor UAV

23

Figure 3.1: Quadrotor Flight Dynamics

Vertical Ascent,Descent and Hover For Vertical Ascent, all motors are rotated at same speed and hence they produce equal thrust. The UAV starts ascending when the combined thrust (F1+F2+F3+F4) over comes mg (weight of the UAV). The rate of ascent can be controlled by controlling the speed of motors. Similarly for Vertical Descent, speed of all motors is reduced depending on the rate of descent required. For the UAV to hover in a particular place, the total thrust of the motors has to equal the weight of the UAV. Forward / Backward / Left / Right movement To move the UAV in forward direction (along +ve x-axis) the speed of M1 is reduced and simultaneously M3 is increased hence F1>F3 and the UAV tilts forward in the z-x plane. It is ensured that (F1+F3)=(F2+F4) to keep the UAV from rotating along its z-axis. Since the motors are not horizontal, the thrust F1 gets divided into 2 components namely F1z opposite to mg to maintain altitude of UAV and F1x along +ve x-axis which tends to move the UAV forward. Referring to Fig. 3.2, we have Forward thrust, F 1x = F 1 cos a Upward thrust, F 1z = F 1 sin a = mg (to maintain altitude)

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

24

Figure 3.2: Thrusts generated by a Quadrotor

The amount of tilt a can be controlled by controlling F1 and F3. Similarly by increasing M1>M3 i.e F3>F1 the UAV tilts backwards and tends to move backward. Right and Left movements are achieved using the same method. Clockwise / Counterclockwise Rotation To rotate the UAV in clockwise direction, the speed of the 2 counterclockwise rotating motors is reduced hence producing a thrust in clockwise direction. Similarly to rotate the UAV counter-clockwise, speed of clockwise rotating motors is reduced. Hover Stability When the UAV is hovering at a place, all motors need to produce the same thrust and the rotational thrust should be balanced. Due to inherent dierences in the motors even while using similar motors, the RPM produced at a particular voltage diers on dierent motors. This produces dierential thrust. Hence, we need sensors in all the 6 degrees of freedom to sense any unwanted drift in any direction. The output of the sensors is monitored and corrective signals applied to stabilize the UAV. The processing of signals is done by an on-board controller. Generation of thrust by rotor The total thrust generated by each motor + rotor combination depends on a number of factors-Area covered by rotor blades on rotation, rotor RPM, air density, velocity of incoming ow of air, acceleration of air ow due to Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

25

propeller (depends on rotor blade pitch and rotor RPM). A general equation of thrust may be given as: T = (/4) .D2 . ( + /2) .. (3.1)

where, T = thrust [N] D = propeller diameter [m] v = velocity of incoming ow [m/s] = additional velocity, acceleration by propeller [m/s] = density of uid [kg/m3 ] (for air: = 1.225 kg/m3 ) Approximating ideal conditions, we can assume velocity of incoming ow constant; also density of air, propeller diameter, propeller pitch are constant. Hence we can reduce above equation toT RotorRP M (3.2)

3.2
3.2.1

Motor Control
PID Controller

A proportional-integral-derivative controller (PID controller) is a generic control loop feedback mechanism (controller). A PID controller calculates an error value as the dierence between a measured process variable and a desired setpoint. The controller attempts to minimize the error by adjusting the process control inputs. In the absence of knowledge of the underlying process as is the present case, PID controllers are the best controllers. However, for best performance, the PID parameters used in the calculation must be tuned according to the nature of the system. The PID controller calculation (algorithm) as shown in Fig. 3.3 involves three separate parameters: the proportional, the integral and derivative values, denoted P, I, and D. The proportional value determines the reaction to the current error, the integral value determines the reaction based on the sum of recent errors, and the derivative value determines the reaction based on the rate at which the error has been changing. The weighted sum of these three actions is used to adjust the process via a control element such as the position of a control valve or the power supply of a heating element. Heuristically, these values can be interpreted in terms of time: P depends on the present error, I on the accumulation of past errors, and D is a prediction of future errors, based on current rate of change. By tuning the three constants in the PID controller algorithm, the controller can provide control action designed for specic process requirements. The response of the controller can be described in terms of the responsiveness

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

26

Figure 3.3: PID Controller Block Diagram

of the controller to an error, the degree to which the controller overshoots the setpoint and the degree of system oscillation. Implementation of PID Controller The dynamics of the UAV are very complex and non-linear hence, it is tting to use a PID controller. We implement PID loops for the control of yaw, roll and pitch. It is a closed loop control system with feedback being the sensor readings themselves. Dening u(t) as the controller output, the nal form of the PID algorithm is: u(t) = Kp e(t) + Ki where, Kp = Proportional Gain Ki = Integral Gain Kd = Derivative Gain e(t) = set point - process variable The process variable here is the current value read from the sensors (yaw, roll or pitch) and set points are the values dened by the Autopilot. We set separate gains for each one of yaw, roll and pitch. The output of the PID controller, u(t) will dene the amount of correction fed to the motors. PID Tuning For optimum performance of the PID loops, the values of Kp, Ki, Kd have to be tuned appropriate to the UAV dynamics. It is desirable to use a Department of Electronics and Communications, BVBCET, Hubli. e(t)dt + Kd d/dte(t) (3.3)

Control System of an Autonomous Quadrotor UAV

27

vision system that would capture the UAV attitude in real-time and compare its recordings against the PID output. Due to absence of access to the aforementioned sophisticated tools required for tuning the PID controller, we select manual tuning. Algorithm used for PID tuning: 1. Set Ki and Kd values to zero. 2. Set Kp to some value and adjust it till the amplitude of overshoots are minimum. 3. Increase Kd in small steps till the number of overshoots reduce to a minimum.

3.2.2

PWM Generator

The PWM generator takes the output from the PID controller and generates the PWM signals to drive the motors. The output of the PID controller gives the measure of correction required to correct the error in the attitude of the UAV. If the PID pitch is positive it indicates the UAV is tilted in the forward direction and needs correction, similarly if it is negative, then it indicates that the UAV is tilted reversein the backward direction. The same concept applies to PID roll as well. The magnitude of the PID output gives the magnitude of correction required. The role of the PWM generator is to interpret the values and correspondingly vary the duty cycle of the PWM signals to the motors. If the UAV is tilted forward then the PWM generator reduces the duty cycle to the front motor and increases the duty cycle to the rear motor by the same amount. The magnitude of the change in duty cycle is directly proportional to the magnitude of PID output and also depends on the RPM of the motors. Fig. 3.4 shows a plot of RPM of motor rotation versus PWM signal width. From the nature of the slope it is clear that as the RPM increases small changes in PWM relates to larger changes in RPM. Hence at higher RPMs the change in the duty cycle for a certain magnitude of error is lesser than the change in duty cycle at lower RPMs for the same magnitude of error. The algorithm for PWM generation follows. 1. Obtain PID pitch. 2. If PID pitch is positive, (a) Decrease front motor duty cycle by (PID pitch/2)*gain. (b) Increase rear motor duty cycle by (PID pitch/2)*gain. 3. If PID pitch is negative, Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

28

Figure 3.4: RPM vs PWM

(a) Decrease rear motor duty cycle by (-PID pitch/2)*gain. (b) Increase front motor duty cycle by (-PID pitch/2)*gain. The same algorithm applies to roll as well. The gain in the algorithm depends on the RPM of the motors. At low RPMs, we set the value to 3; at mid RPMs, it is 2 and it is 1 for the lower RPMs. The classication of the RPM into low, mid and high slightly varies for the dierent motors. The segregation of the RPM and the gains were tuned experimentally. To generate the PWM signals, we use the 16-bit in-built timer of the microcontroller. The four PWM signals are output on four dierent I/O pins of the microcontroller. These signals are fed to the motor driver circuit.

3.2.3

Motor Driver

For propulsion of the UAV, we use four brushed motors (Mabuchi 280). The motors are driven by power mosfets (IRF540). A quad optoisolator (ILQ74) is used to isolate the control circuit from the motor drive circuit. The complete driver circuit is shown in Fig. 3.5. The UAV can be maneuvered in the desired direction by varying the thrust generated by the four motors. The thrust of motors can be varied by varying the RPM of motors which in turn is varied by varying the PWM to the motors. Components used: Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

29

Figure 3.5: Motor Driver Circuit

1. Power Mosfet - IRF540 2. Optoisolator - ILQ74 3. Diode - 1N4007 4. Capacitors and Resistors IRF540 The motors used consume around 1.4A for their operation at full speed. To drive them, a high power mosfet was used. Mosfets are Voltage controlled devices and can be easily controlled in accordance with a PWM signal. We used an N-channel Power Mosfet, IRF540 because of its easy availability and high current carrying capacity. The IRF540 pin connections are shown in Fig. 3.6. IRF540 Specications: 1. VDS Drain-source Voltage (VGS = 0) 100 V 2. VDGR Drain-gate Voltage (RGS = 20 kW) 100 V 3. VGS Gate- source Voltage 20 V 4. ID Drain Current (continuous) at TC = 25 C 22 A 5. td(on) Turn-on Delay Time 6. Rise Time 60 ns Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

30

Figure 3.6: IRF540

7. td(o) Turn-o Delay Time 50 ns The Mosfet is operated with a 12V power supply and a pullup resistance of 10K was used. This yields a current of, 12V / 10K = 1.2mA. Thus, the phototransistor should be able to sink atleast 1.2mA of current for proper operation. Fig, 3.7 shows the Transfer characteristic. At full speed, the motors would take 1.4A each with 12V across them. The Output characteristic is shown in Fig. 3.8. ILQ74 The brushed motors generate a lot of Electromagnetic radiation (EMI). This stray noise can reach the microcontroller and mess up the digital signals. Thus, there is a need to isolate the microcontroller circuit from the Motor driver circuit. We achieve this by using an optoisolator. The optoisolator consists of a Light-Emitting-Diode (LED) and a Photo-Transistor. When the LED is on, a base current is injected into the Base of the phototransistor and the transistor turns on and vice-versa. The optoisolator used is ILQ74. We use the ILQ74 because it consists of four pairs of optoisolators each of which can be used for each one of the motors. The ILQ74 is shown in Fig. 3.9. ILQ74 Specications: 1. Four Channel 2. TTL compatible A resistor of 220 was used for the emitter. Accordingly, the LED current will be, 5V / 220 = 22.7mA.Referring to the Collector-emitter current versus LED current graph in Fig. 3.10, the CE current will be around 15mA. This much current sinking capacity is enough for the next stage of the motor driver.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

31

Figure 3.7: IRF540 Transfer characteristic

Figure 3.8: IRF540 Output characteristic

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

32

Figure 3.9: ILQ74

Figure 3.10: ILQ74 Response

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

33

Figure 3.11: Motor Circuit of one channel

Motor EMI Protection Motors are inductive components and hence produce back EMF. To prevent/reduce the back EMF reaching the digital circuit, we place 1N4007 diodes across each motor. The back EMF generated forward biases the diode and hence the EMF gets a path to discharge preventing it from reaching the digital circuit. We also use a small ceramic capacitor of value, 0.1uF. This serves not just to reduce the back EMF. It prevents any stray AC content from being fed to the DC motors as capacitors pass AC content and block DC content. Fig. 3.11 shows the nal motor driver circuit for one channel. Circuit Operation When the PWM signal is high, the LED inside the optoisolator is o. Thus, the corresponding BJT drive transistor is also o. As a result, the gate of the mosfet is pulled up to the supply voltage. The mosfet is thus turned on when the PWM signal is on and motor is powered. Similarly, when the PWM signal is o, the LED is on causing the BJT driver to be on. This pulls down the gate of the mosfet to ground. Thus power is cuto to the motor when the PWM signal is low. The various waveforms are depicted in Fig. 3.12.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

34

Figure 3.12: Various PWM signals

Power System The power system is required to power the motors and also the onboard sensors and microcontroller. The sensors and microcontrollers are low discharge and do not put much constraints on the power system. The motors require a power system with high current discharge. Additionally to ensure substantial ight duration the power system should have high capacity. The weight of the power system is an additional constraint, there has to be a trade o between the various constraints. Lithium polymer (Lipo) batteries are light weight and capable of high discharge and decent capacity, hence they are ideal for UAVs. Lipo battery specications: 1. Voltage : 11.1 V 2. Capacity : 20 C 3. Weight : 197 gm

3.3

Testbench

The development of a control system for a ying robot requires the development of an adequate testbench. This can help lock some number of degrees of freedom in order to reduce control complexity and to avoid system damage. For our control experiments, we built a testbench as shown in Fig. 3.13. The two vertical arms of the testbench lock two degrees of freedom say, yaw and roll allowing motion in only one degree of freedom - pitch. Then,

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

35

Figure 3.13: Testbench developed for PID tuning

we manually tune the PID gain for pitch PID loop. Similarly, by locking yaw and pitch, we tune the PID gain for roll.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

36

Chapter 4

Results
4.1 Performance of the Kalman Filter

To optimize the performance of the Kalman Filter, we tuned the Kalman Filter parameters which dene the degree to which the Filter will depend on the two sensors. The results obtained after optimizing the Kalman lter Covariance parameters are as follows. Kalman Filter response with the motors o are is as depicted in Fig. 4.1. Kalman Filter response with the motors on are is as depicted in Fig. 4.2. Kalman Filter response when the UAV is stationary are is as depicted in Fig. 4.3. The plots clearly show the superior performance of IMU with Kalman Filtering compared to the raw data available from the accelerometer and gyroscope sensors. It can be seen that the Kalman Filter waveforms follow the waveforms of the accelerometer closely and do not have the characteristic drift of the gyroscope.

4.2

3D emulation of IMU in Processing software

To better visualize the response of the Kalman lter and to optimize the speed of response of the PID controller to any changes in the tilt angles, the IMU wasemulated in 3D using Processing software as shown in Fig. 4.4. The data being sent to the PC was emulated in 3D by the software in real-time. To emulate the IMU attitude in 3D, a box was created and its centre was shifted to the centre of the window. Then, for every set of sensor values received, the box was rotated about its axes by the amount of radians registered by the sensors.

Control System of an Autonomous Quadrotor UAV

37

Figure 4.1: Kalman Filter response when motors are o

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

38

Figure 4.2: Kalman Filter response when motors are on

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

39

Figure 4.3: Kalman Filter response when UAV is stationary

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

40

Figure 4.4: UAV attitude as seen in Processing

Emulating the IMU virtually in 3D helped us in guaging the accuracy of the tilt calculation. It also helped us check if the response of the Kalman lter was real-time.In addition, it was helpful in tuning the PID gains of the PID controller as shown in Fig. 4.5.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

41

Figure 4.5: UAV attitude along with PWM values used for debugging

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

42

Chapter 5

Conclusion and Future Work


5.1 Conclusion

We were successful in realizing a low-cost IMU using MEMS accelerometers and gyroscopes along with Kalman Filter for sensor fusion. We could formulate the state model of the IMU, implement the Kalman Filter and optimize it for an 8-bit microcontroller. We were also successful in emulating the IMU in 3D and in real-time which greatly helped in optimizing the lter response. However, in the stipulated time, we could not achieve all that we set out to do. Building the complete control system for an Autonomous UAV in a semesters time was a daunting task. The DC brushed motors which we used would not respond quickly enough to the controls sent to them. Hence, we could not achieve stable hovering of the UAV. Also, we did not have access to the tools required for proper tuning of the PID control loops. It is well known that PID tuning is as much of an art as it is science and comes from experience.

5.2

Future Work

In the future, we plan to pursue several improvements in the Flight control of the UAV. 1. We envisage using Brushless DC motors replacing the existing DC brushed motors. Brushless motors have several advantages over Brushed motors like linear response, higher eciency, more power, less noise and long life. This simplies the motor controller hardware and software. 2. We plan to incorporate a magnetometer to get accurate estimates of yaw. Accuracy in yaw control is important if the UAV is to be used for video capturing and image processing applications.

Control System of an Autonomous Quadrotor UAV

43

3. We plan to use a pressure sensor which will help the UAV sense its altitude. This will help is simplifying the Autopilot implementation. Once we achieve stable ight tests, we would also like to add intelligent features to the UAV. 1. We plan to enable the UAV to plan its own path depending on its environment. A laser scanner can be used to obtain the information from the UAVs surroundings. Then, a 3D model of the surroundings can be developed and obstacle detection algorithms be implemented to enable the UAV to detect obstacles and accordingly plan its path. This is quite challenging a task, but will greatly enhance the ability of UAVs to do indoor ights. 2. We plan to mount a video camera onboard the UAV and implement image processing operations like activity detection and recognition. Such intelligence features will greatly enhance the scope of applications for UAVs. 3. It is highly desirable to do all the Image processing operations on an onboard controller. So, we plan to migrate to a more powerful processor like the OMAP3530 which is available in ready-to-use small development boards like the Beagle Board and the Gumstix. 4. We also plan to incorporate a GPS onboard the UAV. With this, the UAV can do long distance reconnaissance ights.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

44

Bibliography
[1] Charles A. Clifton. Hybrid system based design for the coordination and control of multiple autonomous vehicles. Proceedings of the Fourth IEEE International Conference and Gesture Recognition, Grenoble, France, August 2005. [2] B. Erginer and E. Altug. Modeling and pd control of a quadrotor vtol vehicle. 2007 IEEE Intelligent Vehicles Symposium, 2007. [3] Spencer G Fowers. Stabilization and control of a quad-rotor micro-uav using vision sensors. August 2008. [4] S. L.Waslander D. Dostal J. S. Jang G. Homann, D. G. Rajnarayan and C. J.Tomlin. The stanford testbed of autonomous rotorcraft for multi-agent control (starmac). Proceedings of the 23rd Digital Avionics Systems Conference, 2004. [5] L. Beji K. Zemalache and H. Marref. Control of an under-actuated system: Application a four rotors rotorcraft. 2005 IEEE International Conference on Robotics and Biomimetics (ROBIO), 2005. [6] I. Kroo and F. B. Prinz. The mesicopter: A meso-scale ight vehicle. Stanford University, 1999. [7] CHEN Ben M. LIN Feng, LUM Kai-Yew and LEE Tong H. Development of a vision-based ground target detection and tracking system for a small unmanned helicopter. 2009. [8] A. Mokhtari and A. Benallegue. Dynamic feedback controller of euler angles and wind parameters estimation for a quadrotor unmanned aerial vehicle. 2004 IEEE International Conference on ICRA, 2004. [9] T. Hamel N. Guenard and V. Moreau. Dynamic modeling and intuitive control strategy for an x4-yer. Control and Automation, 2005. [10] R. Mahony P. Pounds and P. Corke. Modelling and control of a quadrotor robot. Australasian Conference on Robotics and Automation 2006, December 2006.

Control System of an Autonomous Quadrotor UAV

45

[11] Andre Noth Samir Bouabdallah and Roland Siegwart. Pid vs lq control techniques applied to an indoor micro quadrotor. Autonomous Systems Laboratory Swiss Federal Institute of Technology Lausanne, Switzerland. [12] A. Tayebi and S. McGilvray. Attitude stabilization of a four-rotor aerial robot. Image and Vision Computing, 2004. [13] H. Voos. Nonlinear state-dependent riccati equation control of a quadrotor uav. Control Applications, 2006 IEEE International Conference on, 2006.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

46

Appendix A

Circuit Diagram
The complete circuit diagram of the UAV is given in Fig. A.1. The circuit consists of the Atmega32 microcontroller which interfaces with the sensor module on the I2C (TWI on Atmega32) bus. The microcontroller also generates the PWM signals which feed the motor driver circuit. The motor driver circuit consists of Mosfets and an Optoisolator is used to protect the digital circuit from the EMI generated by the motors.

Control System of an Autonomous Quadrotor UAV

47

Figure A.1: Complete Circuit Diagram of the UAV

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

48

Appendix B

I2C
The I2C bus, read as I squared C, because of its simplicity and exibility, has become one of the most important microcontroller bus system used for interfacing various peripherals with the microcontroller. The I2C bus uses only two bidirectional data lines for communicating and the protocol specication can support up to 128 devices attached to the same bus. On the Atmega32 microcontroller, the I2C protocol is implemented as Two-WireInterface (TWI). The I2C protocol uses master and slave method, the master which is usually the microcontroller while the slave can be any I2C devices such as Serial EEPROM, I/O Expander or even another microcontroller. All of these devices connected to the I2C bus; one for the serial data called SDA (serial data) and the other for synchronize clock called SCL (serial clock); each of these slave devices has their own individual 7 bits of the address length. The 7 bits address consists of 4 bits device identication and 3 bits device physical address. By selecting the appropriate device address, the master can easily communicate with the entire slave devices connected to the I2C bus; the I2C bus protocol only allowed one connection to be established between master and slave at a time.

B.1

Data Transfer and Frame Format

Transferring Bits: Each data bit transferred on the I2C is accompanied by a pulse on the clock line. The level of the data line must be stable when the clock line is high. The only exception to this rule is for generating start and stop conditions. The Master initiates and terminates a data transmission. The transmission is initiated when the Master issues a START condition on the bus, and it is terminated when the Master issues a STOP condition. Between a START and a STOP condition, the bus is considered busy, and no other Master should try to seize control of the bus. A special case occurs when a new START condition is issued between a START and STOP

Control System of an Autonomous Quadrotor UAV

49

condition. This is referred to as a REPEATED START condition, and is used when the Master wishes to initiate a new transfer without releasing control of the bus. After a REPEATED START, the bus is considered busy until the next STOP. This is identical to the START behavior, and therefore START is used to describe both START and REPEATED START for the remainder of this datasheet, unless otherwise noted. START and STOP conditions are signaled by changing the level of the SDA line when the SCL line is high.

B.2

Address Packet Format

All address packets transmitted on the I2C are nine bits long, consisting of seven address bits, one READ/WRITE control bit and an acknowledge bit. If the READ/WRITE bit is set, a read operation is to be performed, otherwise a write operation should be performed. When a Slave recognizes that it is being addressed, it should acknowledge by pulling SDA low in the ninth SCL (ACK) cycle. If the addressed Slave is busy, or for some other reason can not service the Masters request, the SDA line should be left high in the ACK clock cycle. The Master can then transmit a STOP condition, or a REPEATED START condition to initiate a new transmission. An address packet consisting of a Slave address and a READ or a WRITE bit is called SLA+R or SLA+W, respectively. The MSB of the address byte is transmitted rst. Slave addresses can freely be allocated by the designer, but the address 0000 000 is reserved for a general call. When a general call is issued, all Slaves should respond by pulling the SDA line low in the ACK cycle. A general call is used when a Master wishes to transmit the same message to several Slaves in the system. When the general call address followed by a Write bit is transmitted on the bus, all Slaves set up to acknowledge the general call will pull the SDA line low in the ACK cycle. The following data packets will then be received by all the Slaves that acknowledged the general call. Note that transmitting the general call address followed by a Read bit is meaningless, as this would cause contention if several Slaves started transmitting dierent data. All addresses of the format 1111 xxx should be reserved for future purposes.

B.3

Data Packet Format

All data packets transmitted on the I2C are nine bits long, consisting of one data byte and an acknowledge bit. During a data transfer, the Master generates the clock and the START and STOP conditions, while the receiver is responsible for acknowledging the reception. An Acknowledge (ACK) is signaled by the receiver pulling the SDA line low during the ninth SCL cycle. If the receiver leaves the SDA line high, a NACK is signaled. When Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

50

Figure B.1: Data transfer from master to slave

the receiver has received the last byte, or for some reason cannot receive any more bytes, it should inform the transmitter by sending a NACK after the nal byte. The MSB of the data byte is transmitted rst.

B.4

Transmission modes

A transmission basically consists of a START condition, a SLA+R/W, one or more data packets and a STOP condition. An empty message, consisting of a START followed by a STOP condition, is illegal. The Slave can extend the SCL low period by pulling the SCL line low. This is useful if the clock speed set up by the Master is too fast for the Slave, or the Slave needs extra time for processing between the data transmissions. The Slave extending the SCL low period will not aect the SCL high period, which is determined by the Master. As a consequence, the Slave can reduce the TWI data transfer speed by prolonging the SCL duty cycle.

B.5

Data Transfer from master to slave

A master device sends the sequence S ADDR W and then waits for an acknowledge bit (A) from the slave which the slave will only generate if its internal address matches the value sent by the master. If this happens then the master sends DATA and waits for acknowledge (A) from the slave. The master completes the byte transfer by generating a stop bit (P) (or repeated start).

B.6

Data transfer from slave to master

A similar process happens when a master reads from the slave but in this case, instead of W, R is sent. After the data is transmitted from the slave to the master the master sends the acknowledge (A). If instead the master does not want any more data it must send a not-acknowledge which indicates to the slave that it should release the bus. This lets the master send the STOP or repeated START signal.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

51

Figure B.2: Data transfer from slave to master

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

52

Appendix C

USART
USART stands for Universal Synchronous Asynchronous Receiver Transmitter. It is sometimes called the Serial Communications Interface or SCI. Synchronous operation uses a clock and data line while there is no separate clock accompanying the data for Asynchronous transmission. Since there is no clock signal in asynchronous operation, one pin can be used for transmission and another pin can be used for reception. Both transmission and reception can occur at the same time - this is known as full duplex operation. Transmission and reception can be independently enabled. However, when the serial port is enabled, the USART will control both pins and one cannot be used for general purpose I/O when the other is being used for transmission or reception. The USART is most commonly used in the asynchronous mode. The most common use of the USART in asynchronous mode is to communicate to a PC serial port using the RS-232 protocol.A driver is required to interface to RS-232 voltage levels and the PICmicro R MCU should not be directly connected to RS-232 signals. The USART can be congured to transmit eight or nine data bits by the TX9 bit in the TXSTA register. If nine bits are to be transmitted, the ninth data bit must be placed in the TX9D bit of the TXSTA register before writing the other eight bits to the TXREG register. Once data has been written to TXREG, the eight or nine bits are moved into the transmit shift register. From there they are clocked out onto the TX pin preceded by a start bit and followed by a stop bit. The USART can be congured to receive eight or nine bits by the RX9 bit in the RCSTA register. After the detection of a start bit, eight or nine bits of serial data are shifted from the RX pin into the receive shift register one bit at a time. After the last bit has been shifted in, the stop bit is checked and the data is moved into the buer which passes the data through to the RCREG register if it is empty. The buer and RCREG register therefore form a two element FIFO. If nine bit reception is enabled, the ninth bit is passed into the RX9D bit in the RCSTA register in the same way as the

Control System of an Autonomous Quadrotor UAV

53

other eight bits of data are passed into the RCREG register. The rate at which data is transmitted or received must be always be set using the baud rate generator unless the USART is being used in synchronous slave mode. The baud rate is set by writing to the SPBRG register. The SYNC bit selects between synchronous and asynchronous modes, and these modes have dierent baud rates for a particular value in the SPBRG register. For asynchronous mode, the SYNC bit must be cleared and the BRGH bit is used to select between high and low speed options for greater exibility in setting the baud rate.

Department of Electronics and Communications, BVBCET, Hubli.

Control System of an Autonomous Quadrotor UAV

54

Appendix D

List of Components
The List of Components used in the complete circuit are given below. Component Microcontroller Mosfet Optoisolator Accelerometer Gyroscope Resistors Diodes Capacitors Motors Battery Component Name Atmega32 IRF540 ILQ74 LIS3L02 (Wii Nunchuk) IDG600 (Wii Motionplus) X3500W (Wii Motionplus) 220 10K 1N4007 0.1uF DC brushed Motors 3SIP 11.1V Li-Po Quantity 1 4 1 1 1 1 4 6 4 4 4 1

Table D.1: List of Components

Control System of an Autonomous Quadrotor UAV

55

Appendix E

Chassis Specications
Frame parts: 1. Arm rods (4): Carbon ber rods, Tube length: 247mm, Tube diameter: 5mm. 2. Frame center cross piece (1): strong high impact nylon. 3. Vertical risers (4): Durable plastic. 4. Base plate (1): Carbon ber. 5. Motor mounts (4): Durable plastic. Motors: 1. Motors (4): Mabuchi 280 brushed motor with custom windings. 2. Pinion gear (4): Brass 10 tooth gear attached to motor shaft. 3. Main gear (4): Injection molded from nylon, mounted on the upright portion of the motor mount (53 tooth). 4. Rotors (4): SAVS style (2 piece) nylon injected folding rotor blades. (a) 2 Clockwise B rotor blades (4 blade halves). (b) 2 Counter-clockwise A rotor blades (4 blade halves). (c) 4 - Carbon Fiber Cross Braces.

Potrebbero piacerti anche