Top Banner
Declaration We, the below named students of final semester Electronics and Com- munications 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 success- fully 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 de- gree or diploma. Sagar Medikeri USN 2BV06EC060 Shravan Kemtur USN 2BV06EC070 Reshma Desai USN 2BV06EC055 Vikas Vaddin USN 2BV06EC080 1
63

Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Aug 04, 2015

Download

Documents

Sagar Medikeri
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

DeclarationWe, the below named students of final semester Electronics and Com-

munications Department, B. V. Bhoomaraddi College of Engineering andTechnology, Hubli-31 declare that the work entitled Control System of anAutonomous Quadrotor Unmanned Aerial Vehicle has been success-fully 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 de-gree or diploma.

Sagar Medikeri USN 2BV06EC060

Shravan Kemtur USN 2BV06EC070

Reshma Desai USN 2BV06EC055

Vikas Vaddin USN 2BV06EC080

1

Page 2: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

AcknowledgementWe are and shall always be deeply obliged the unflinching support and

guidance of our beloved project guide Dr. Uma. K. Mudenagudi, Pro-fessor in Department of Electronics and Communications, whose excellencein this field and constant inspiration has kept us motivated. We sincerelyexpress our thanks for the help in providing all the required facilities andencouraging us throughout.

We owe a special sense of gratitude to Dr. R. M. Banakar, our re-spected and beloved HOD for her valuable advices and encouragement.

We also are grateful to Prof.B.L.Desai for his constant inspiration andencouragement.

Our special thanks go to Prof. Arun C. Giriyapur of BVB RoboticsClub who helped us immensely and provided us with all the facilities andequipments needed for the project.

We are also grateful to our beloved principal, Dr. Ashok S. Shettarwhose dynamism and single-handed efforts has inspired us to do somethingin time to come. We also extend our earnest gratitude to KLE society forhaving provided all the facilities.

Last but not the least, we owe our gratitude to the teaching and non-teaching staff of Department of Electronics and Communication Engineeringand our beloved parents and friends who have appreciated, encouraged andassisted us in our endeavours.

Project Associates

2

Page 3: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of anAutonomous UnmannedAerial Vehicle (UAV)

Sagar MedikeriShravan KemturReshma DesaiVikas Vaddin

Department of Electronics and Communications,BVBCET, Hubli, India.

under the guidance ofDr.Uma Mudenagudi

June 12, 2010

Page 4: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Abstract

In this project, we present the design details for the control system ofan Autonomous Unmanned Aerial Vehicle (UAV) built around a quadrotorconfiguration. Quadrotor UAVs are being increasingly deployed in militarywarcraft and of late, they have also found varied applications in the fieldof law enforcement, traffic analysis and swarm intelligence. UAVs requiresophisticated control system which are very challenging to build. Our focusin this project, is on the electronic control of the UAV rather than themechanical aspects of its design. We propose a control system consistingof two stages - the Inertial Measurement Unit (IMU) and the UAV FlightControl.

We demonstrate a low cost realization of IMU by fusing the output ofMEMS sensors (accelerometer and gyroscope) using the Kalman Filter. TheKalman Filter takes input from both the accelerometer and gyroscope andreturns an accurate estimate of the position of the UAV. We also describethe associated state modeling and optimization of the Kalman filter. Wethen demonstrate the superior performance of the Kalman Filter comparedto raw sensor data. The attitude of the craft is synthetically generated in 3Dusing Processing software to provide a clear picture of the IMUs working.

In flight control part, we achieve the flight of the UAV by differentiallycontrolling the speed of each of the four motors. A possible implementa-tion of the motor driver and differential speed control with PWM signals isshown. We implement the Proportional Integral Derivative(PID) controllerto obtain error parameters for yaw, roll and pitch. These error parame-ters are then used to generate appropriate PWM signal for each of the fourmotors. We then present the tuning of PID controller for this application.

Page 5: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Contents

1 Introduction 11.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3.1 IMU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3.2 Flight Control . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Literature Review . . . . . . . . . . . . . . . . . . . . . . . . 41.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.6 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Inertial Measurement Unit (IMU) 62.1 Introduction to IMU . . . . . . . . . . . . . . . . . . . . . . . 62.2 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.1 Sensor Mounting . . . . . . . . . . . . . . . . . . . . . 82.2.2 Reading the sensors . . . . . . . . . . . . . . . . . . . 82.2.3 Calculation of Euler Angles . . . . . . . . . . . . . . . 10

2.3 The Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . 142.3.1 Introduction to The Kalman Filter . . . . . . . . . . . 142.3.2 Implementation . . . . . . . . . . . . . . . . . . . . . . 162.3.3 Kalman frequency . . . . . . . . . . . . . . . . . . . . 182.3.4 Tuning the Kalman Filter Covariance Parameters . . . 18

3 Flight Control 223.1 Quadrotor Flight Control with Differential Speed Control . . 223.2 Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.2.1 PID Controller . . . . . . . . . . . . . . . . . . . . . . 253.2.2 PWM Generator . . . . . . . . . . . . . . . . . . . . . 273.2.3 Motor Driver . . . . . . . . . . . . . . . . . . . . . . . 28

3.3 Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

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

i

Page 6: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

5 Conclusion and Future Work 425.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

A Circuit Diagram 46

B I2C 48B.1 Data Transfer and Frame Format . . . . . . . . . . . . . . . . 48B.2 Address Packet Format . . . . . . . . . . . . . . . . . . . . . 49B.3 Data Packet Format . . . . . . . . . . . . . . . . . . . . . . . 49B.4 Transmission modes . . . . . . . . . . . . . . . . . . . . . . . 50B.5 Data Transfer from master to slave . . . . . . . . . . . . . . . 50B.6 Data transfer from slave to master . . . . . . . . . . . . . . . 50

C USART 52

D List of Components 54

E Chassis Specifications 55

ii

Page 7: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

List of Figures

1.1 The airframe of the UAV . . . . . . . . . . . . . . . . . . . . 21.2 Block diagram of UAV . . . . . . . . . . . . . . . . . . . . . . 3

2.1 Block Diagram of IMU . . . . . . . . . . . . . . . . . . . . . . 72.2 The 6 Degrees Of Freedom . . . . . . . . . . . . . . . . . . . 72.3 Axes of accelerometer with respect to the UAV . . . . . . . . 82.4 Sensor module . . . . . . . . . . . . . . . . . . . . . . . . . . 92.5 Data format of Wii MotionPlus . . . . . . . . . . . . . . . . . 102.6 Data format of Wii Nunchuk . . . . . . . . . . . . . . . . . . 112.7 Euler angle calculation from Accelerometer . . . . . . . . . . 112.8 MATLAB plot of gyroscope values when UAV is stationary . 132.9 Kalman Filter Equations . . . . . . . . . . . . . . . . . . . . . 162.10 Kalman Filter performance when motors are on . . . . . . . . 192.11 Kalman Filter performance when motors are off . . . . . . . . 21

3.1 Quadrotor Flight Dynamics . . . . . . . . . . . . . . . . . . . 233.2 Thrusts generated by a Quadrotor . . . . . . . . . . . . . . . 243.3 PID Controller Block Diagram . . . . . . . . . . . . . . . . . 263.4 RPM vs PWM . . . . . . . . . . . . . . . . . . . . . . . . . . 283.5 Motor Driver Circuit . . . . . . . . . . . . . . . . . . . . . . . 293.6 IRF540 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.7 IRF540 Transfer characteristic . . . . . . . . . . . . . . . . . 313.8 IRF540 Output characteristic . . . . . . . . . . . . . . . . . . 313.9 ILQ74 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.10 ILQ74 Response . . . . . . . . . . . . . . . . . . . . . . . . . 323.11 Motor Circuit of one channel . . . . . . . . . . . . . . . . . . 333.12 Various PWM signals . . . . . . . . . . . . . . . . . . . . . . 343.13 Testbench developed for PID tuning . . . . . . . . . . . . . . 35

4.1 Kalman Filter response when motors are off . . . . . . . . . . 374.2 Kalman Filter response when motors are on . . . . . . . . . . 384.3 Kalman Filter response when UAV is stationary . . . . . . . 394.4 UAV attitude as seen in Processing . . . . . . . . . . . . . . . 404.5 UAV attitude along with PWM values used for debugging . . 41

iii

Page 8: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

A.1 Complete Circuit Diagram of the UAV . . . . . . . . . . . . . 47

B.1 Data transfer from master to slave . . . . . . . . . . . . . . . 50B.2 Data transfer from slave to master . . . . . . . . . . . . . . . 51

iv

Page 9: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 1

Chapter 1

Introduction

In this project, we propose to design the control system of an AutonomousQuadrotor UAV. UAVs are aerial vehicles capable of flight without an on-board pilot. While there are various configurations of UAVs in existence likeairplanes and helicopters, the Quadrotor configuration is the most popularbecause of its mechanical simplicity and maneuverability. In a Quadrotorhelicopter, lift is generated by four propellers mounted in a ’+’ configuration.

We implement the control system in two stages - the Inertial Measure-ment Unit (IMU) and the Flight Control. The IMU reads the motion sensorsand obtains the best estimate of the position of the UAV by Kalman Filter-ing the raw sensor data.

The Flight Control module comprises of several subsystems which workin harmony to stabilize the flight of the UAV. We design a motor drivercircuit to drive the motors. We generate appropriate PWM signals to achievedifferential speed control of motors. We implement a PID controller toimprove the dynamic response of the UAV.

1.1 Motivation

The design of control system for a manually controlled UAV is a very chal-lenging task. Making the vehicle autonomous increases this complexity man-ifold. The challenge arises from the fact that the UAV, being a flying robotrequires accurate position sensing and fast dynamics. Accurate positionsensing requires sophisticated sensor fusion techniques. Fast dynamics re-quires software optimizations and efficient control loop mechanisms. One ofthe driving forces behind the choice of quad-rotors is the mechanical sim-plicity as compared to the conventional helicopter configuration which, dueto the swash plate mechanism is very complex.

The varied applications of the UAVs are also a motivating factor. UAVshave traditionally been used by the military for reconnaissance operationsand drone attacks. But, of late UAVs have found several new areas of appli-

Page 10: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 2

Figure 1.1: The airframe of the UAV

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

1.2 Problem Statement

We propose to implement a control system for a quadrotor UAV in thefollowing two stages:

1. To design an IMU for the UAV using MEMS accelerometers and gy-roscopes and to implement the Kalman Filter for sensor fusion to getan accurate estimate of the position of the UAV in three-dimensionalspace.

2. To model the UAV flight dynamics and to design the electronics foraccurate motor speed control and implement an efficient PID controllerto 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 weprocured a quadrotor chassis which is shown in Fig. 1.1.

We follow a structured approach to implement the control system ofa quad rotor UAV. The system is divided into two stages - the InertialMeasurement Unit (IMU) and the flight control. The IMU includes theKalman Filter for sensor fusion and the Flight Control unit involves softwareand hardware implementation of the motor controller. Fig. 1.2 shows thesystem block diagram.

Department of Electronics and Communications, BVBCET, Hubli.

Page 11: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 3

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 offreedom (6DOF) - three translation axes namely X-, Y-, Z- axes and threerotation axes namely Yaw, Roll and Pitch. These parameters define the ori-entation of the UAV in three-dimensional space and are collectively referredto as attitude of the UAV. For motion sensing, we use MEMS accelerome-ters and gyroscopes for their small size and easy interfacing. To keep ourcosts low, we hack the sensors from Wii game controllers, Nunchuk and Mo-tionplus. The sensors are read by a microcontroller (Atmega32) using I2Cinterface.

An efficient sensor fusion technique is required to make the gyroscopereadings follow that of the accelerometer since accelerometers suffer fromnoise and gyroscopes suffer from drift. For this, we implement the KalmanFilter for its ability to combine noisy sensor readings and get clean, accurateestimates. First, we model the dynamics of the system in accordance withthe framework of the Kalman filter and then, we implement the KalmanFilter equations using the matrices generated from the model. We thentune the Kalman Filter for optimum response by plotting the response ofthe filter against raw sensor readings in MATLAB. Tuning involves adjustingthe Kalman filter parameters till an acceptable response is obtained.

Department of Electronics and Communications, BVBCET, Hubli.

Page 12: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 4

1.3.2 Flight Control

We achieve UAV flight by differential speed control of motors. For flight con-trol, we begin by modeling the flight dynamics in terms of thrust generatedby the motors. The Flight Control stage consists of following subsystems:

1. Autopilot: This is the block responsible for autonomous flight. Thepath is pre-fed into the autopilot and the autopilot generates thepresent state (attitude/orientation)/flight mode required for the UAV.The autopilot ensures the UAV follows the path and constantly up-dates the state.

2. PID controller: The PID controller takes inputs from the IMU andthe Autopilot and generates the differential corrective signals. This isthe error control block of the control system. The difference betweenthe required state (generated by the autopilot) and the current state(generated by IMU) gives the error signal. PID equations are used togenerate error correction signals.

3. PWM generator: This block takes input from the PID controller andgenerates corresponding PWM waveforms proportional to the correc-tive signals using built-in timers in the microcontroller.

4. Motor controller: This is the motor driver circuit which takes PWMinput and drives the motor.

1.4 Literature Review

There is a fair amount of published research with regards to quadrotor air-craft. Various researchers have used the quad-rotor platform for studies incontrol. The quad-rotor is an under-actuated system and therefore requiresoutside observer style sensors for full attitude and position control.

The sensor systems on quad-rotor UAVs typically include an inertialmeasurement unit either commercially purchased or built by the researchteam for attitude estimation. The sensor fusion problem is usually solvedby implementing the Kalman Filter [3], Extended Kalman Filter [1] or theComplementary Filter. In recent times, there has also been growing use ofDirection Cosine Matrix (DCM) and quaternions for sensor fusion.

The Quadrotor configuration being an under-actuated system has spawneda lot of research in innovative control methods. Sliding mode control, basicPID, and LQ control are just a few of the control methods that have beenapplied to the quad-rotor platform [12], [5], [8], [2], [10], [13]. In [11],an analysis is made between two popular control techniques used for UAVflight 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.

Page 13: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 5

Researchers have begun studying quadrotors for multi-agent cooperativemissions called Swarm intelligence missions, their system dynamics and sta-bility, and assisted manual control for tele-operation [4], [6], [10], [9]. SLAM(Simultaneous Localization And Mapping) has become a popular approachfor this [7].

Since last few years, Radio-controlled UAVs are available commercially.Examples include the Silverlit X-UFO, the Draganflyer X4 and the Mikrokopter.All three of these products use four rotors in conjunction with a controlsystem that consists of gyroscopes for feedback. The Draganflyer X4 addi-tionally has an onboard camera for reconnaissance purposes. However, asthese crafts are designed as high-end hobbyist crafts, they also come with afairly steep price tag, as the Draganflyer products are upwards of USD 1500or more.

1.5 Applications

UAVs have traditionally been used by the military for reconnaissance oper-ations and drone attacks. But, of late UAVs have found several new areasof application like,

1. Search and Rescue operations in calamity-hit regions

2. Aerial photography and environment assessment

3. By the government for law enforcement, traffic congestion analysis

4. Aerial archaeology

5. Remote sensing functions which include electromagnetic spectrum sen-sors, biological sensors, and chemical sensors

6. Scientific 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 flight control mechanism. It covers the motorcontrol algorithm that we implemented and the various tests we conducted.In chapter 4, we compile the various results that were achieved. Finally, inchapter 5, we conclude the report and discuss about the future work in thisdirection.

Department of Electronics and Communications, BVBCET, Hubli.

Page 14: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 6

Chapter 2

Inertial Measurement Unit(IMU)

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

2.1 Introduction to IMU

An inertial measurement unit, or IMU, is an electronic device that measuresand reports on a craft’s velocity and orientation using a combination of ac-celerometers and gyroscopes. IMUs are used to maneuver aircraft, includ-ing UAVs , spacecraft, shuttles, satellites, missiles and many more systemswhere there is a need to know the orientation, alignment of the vehicle atall 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 suffers a failurethe whole control system fails. The IMU provides several vital data whichare essential to control the UAV. The IMU comprises of sensors and a filterto 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 DegreesOf Freedom (6-DOF). All the six degrees of freedom are shown in Fig. 2.2.

Page 15: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 7

Figure 2.1: Block Diagram of IMU

Figure 2.2: The 6 Degrees Of Freedom

The sensors used must not add significantly to the weight of the UAV sinceweight is a critical component in UAV applications. Accordingly we useMEMS (Micro-Electro-Mechanical Systems) versions of accelerometers andgyroscopes. The IMU needs to be capable of detecting the slightest changein orientation and also rapid movements which the UAV will be subjectedto, hence the sensors need to be highly sensitive and also have fast response.

Subjected to these requirements and considering the cost factor, we usethe sensors present in Nintendo’s Wii game controllers. The Wii nunchuckcontroller has a 3-axis accelerometer and the Wii motion+ has a 3-axisgyroscope. These sensors are ideally suited for the IMU since they arefabricated for a real time system with similar demands of precision andsensitivity. We interface the sensors using serial fast I2C protocol. The

Department of Electronics and Communications, BVBCET, Hubli.

Page 16: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 8

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 accelerometer’s axes coincide with theUAV’s axes as shown in Fig. 2.3. The gyroscope is placed on the axes ofUAV’s 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+) has2 ports, one to connect to the console and another pass-thru port to connectother controllers. We connect the nunchuck controller to the pass-thru portof 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.

Page 17: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 9

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 reg-ister 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 re-ceive 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 beread, at the end we will have two packets of 6 bytes each. Bit 1 of Byte 5 isused to determine which type of report is received : it is 1 when it containsMotionPlus Data and 0 when it contains extension data.

Data Format

The Wii Motion Plus reports its information as 6 bytes of data, the datafrom nunchuck and WM+ are sent alternatively with a bit in the packetmentioning which sensor data is being sent. The sensors are connected inwhat is called, Pass through mode. The data packet formats of nunchuckand WM+ are as shown in Fig. 2.5.

Department of Electronics and Communications, BVBCET, Hubli.

Page 18: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 con-nected is 1 when an extension is connected to the MotionPlus extensionport.

SX, SY are the Analog Stick X and Y positions, while AX, AY, and AZare the 9-bit accelerometer data. BC and BZ are the state of the C and Zbuttons. After receiving the data packets the data is rearranged to obtainthe 6 sensor data. The sensor data is raw and needs further processing toobtain the accelerations.

2.2.3 Calculation of Euler Angles

After reading the sensor data, angles are calculated from both the accelerom-eter 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 value256 which is the mid value corresponds to 0 acceleration, this value is termedas the bias value. Bias value is the value which denotes 0 acceleration.The values fom 256-512 correspond to positive acceleration and from 0-256correspond to negative acceleration. Hence the sensor data is subtractedwith 256 to obtain the acceleration values.

Fig. 2.7 shows the accelerometer axis, theta is the pitch of the UAV. Dueto the tilt of the UAV, components of earth’s gravitational force ’g’ act on

Department of Electronics and Communications, BVBCET, Hubli.

Page 19: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 20: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 12

the accelerometer. The pitch can be calculated using:

pitch = arctan(ay/az) (2.1)

Similarly roll can be calculated using:

roll = arctan(ax/az) (2.2)

Yaw cannot be calculated using accelerometer as rotational axis of yawis perpendicular to ’g’ axis.

Angle calculation from Gyroscopes

The gyroscope data are 14 bit values, but the bias of the gyroscope keepsdrifting hence there is no fixed bias. The best way to approximate the biasvalue of the gyroscope is to take average of hundred samples when the UAVis stationary.

Finding the Gyroscope Bias Values

To obtain the bias values for Yaw, Roll and Pitch of the gyroscope the outputof 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 obtainedfrom the sensor data by subtracting it by the bias value. After experimenta-tion we found that 20 represents turning at about 1 degree per second at lowspeed (Low speed bit = 1). So we need to divide by 20 to get the degreesper second. At high speed (Low speed bit = 0) 20 represents turning atabout 5 degree per second. So we need to divide by 4 to get the degrees persecond. Hence the equation to obtain angular acceleration from raw sensordata is :

ω = (datagyro − biasgyro)/scale (2.3)

where, Scale =

20;Lowspeedbit = 14;Lowspeedbit = 0

To obtain the euler angles we need to integrate angular acceleration overthe sampling period.

θ =∫

ω(t)dt (2.4)

where, dt is the sampling period

Department of Electronics and Communications, BVBCET, Hubli.

Page 21: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 22: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 14

Using the above equation and the sensor data from the 3 gyroscopes wecalculate yaw, roll and pitch. Gyroscope bias is subjected to drift whichcauses error in the angle calculation. Integration has a cascading effect onthe error, causing the calculated values to be unreliable after a certain periodof time.

Need for Sensor Fusion

Observing the accelerometer plots we can conclude that accelerometer valuesare very noisy and affected a lot by vibration. They cannot be used as astandalone sensor for IMU. Though gyroscope readings are not affected byvibration, they suffer drift which makes them ineffective as a standalonesensor for IMU.

To make a reliable IMU we use both the sensors. We make use of the gy-roscopes ability to be insulated by noise and vibration and the fast responseof the accelerometer. The drift of gyroscope is countered by correcting it pe-riodically using accelerometer values. Kalman filter is one such filter whichis very efficient in sensor fusion.

2.3 The Kalman Filter

2.3.1 Introduction to The Kalman Filter

The Kalman filter is a set of mathematical equations that provides an ef-ficient computational means to estimate the state of a process, in a waythat minimizes the mean of the squared error. The filter is very powerfulin several aspects: it supports estimations of past, present, and even futurestates, and it can do so even when the precise nature of the modeled systemis unknown.

The Kalman filter addresses the general problem of trying to estimatethe state ’X ’ of a nth order discrete-time controlled process that is governedby the linear stochastic difference equation:

Xk = AXk−1 + BUk−1 + Wk−1 (2.5)

with a measurement ’Z ’ that is:

Zk = HXk + Vk (2.6)

The random variables Wk and Vk represent the process and measurementnoise respectively).They are assumed to be independent (of each other),white, and with normal probability distributions:

p(w) ∼ N(0, Q) (2.7)

p(v) ∼ N(0, R) (2.8)

Department of Electronics and Communications, BVBCET, Hubli.

Page 23: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 15

In practice, the process noise covariance ’Q ’ and measurement noisecovariance ’R’ matrices might change with each time step or measurement,however here we assume they are constant.

The n × n matrix ’A’ in the difference equation relates the state at theprevious time k-1 step to the state at the current step k , in the absence ofeither a driving function or process noise. In practice ’A’ might change witheach time step, but here we assume it is constant. The n×l matrix B relatesthe 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, buthere we assume it is constant.

The Kalman filter estimates a process by using a form of feedback con-trol: the filter estimates the process state at some time and then obtainsfeedback in the form of (noisy) measurements. As such, the equations for theKalman filter fall into two groups: time update equations and measurementupdate equations. The time update equations are responsible for project-ing forward (in time) the current state and error covariance estimates toobtain the a priori estimates for the next time step. The measurement up-date equations are responsible for the feedback i.e. for incorporating a newmeasurement into the a priori estimate to obtain an improved a posterioriestimate.

The time update equations can also be thought of as predictor equa-tions, while the measurement update equations can be thought of as cor-rector equations. Indeed the final estimation algorithm resembles that ofa predictor-corrector algorithm for solving numerical problems as shown inFig. 2.9.

The time update equations project the state and covariance estimatesforward from time step k-1 to step k.

The measurement update first computes the Kalman gain, The nextstep is to actually measure the process to obtain , and then to generate an aposteriori state estimate by incorporating the measurement. The final stepis to obtain an a posteriori error covariance estimate.

After each time and measurement update pair, the process is repeatedwith the previous a posteriori estimates used to project or predict the new apriori estimates. This recursive nature is one of the very appealing featuresof the Kalman filter-it makes practical implementations much more feasiblethan (for example) an implementation of a Wiener filter which is designedto operate on all of the data directly for each estimate. The Kalman fil-ter instead recursively conditions the current estimate on all of the pastmeasurements.

Department of Electronics and Communications, BVBCET, Hubli.

Page 24: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 16

Figure 2.9: Kalman Filter Equations

Filter Parameters and Tuning

In the actual implementation of the filter, the measurement noise covariance’R’ is usually measured prior to operation of the filter. Measuring the mea-surement error covariance ’R’ is generally practical (possible) because weneed to be able to measure the process anyway (while operating the filter)so we should generally be able to take some off-line sample measurementsin order to determine the variance of the measurement noise.

The determination of the process noise covariance ’Q ’ is generally moredifficult as we typically do not have the ability to directly observe the processwe are estimating. Sometimes a relatively simple (poor) process model canproduce acceptable results if one injects enough uncertainty into the processvia the selection of ’Q ’ . Certainly in this case one would hope that theprocess measurements are reliable.

In either case, whether or not we have a rational basis for choosing theparameters, often times superior filter performance (statistically speaking)can be obtained by tuning the filter parameters. The tuning is usuallyperformed off-line, frequently with the help of another (distinct) Kalmanfilter in a process generally referred to as system identification.

2.3.2 Implementation

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

Department of Electronics and Communications, BVBCET, Hubli.

Page 25: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 17

to vibration and jitter, hence we use them for obtaining the angle estimatein the kalman filter. To counteract the drift suffered by the gyroscope weuse the angle measurements from accelerometer to periodically correct thedrift, hence accelerometer input acts as feedback or corrector equations.

State model of IMU

To implement the kalman filter we formulate the state space model of theIMU. We model the euler angle calculation in the form of two linear stochas-tic equations as shown in Eqns. 2.5 and 2.6.

The Gyroscope output is used for the state estimation. The accelerome-ter output is used for the state correction. The gyroscope measures angularacceleration. Integrating this acceleration, we get the angle of swing. Theequation to measure the angle of swing using gyroscope output is:

θ =∫

(ω(t)− bias)dt (2.9)

where, (ω(t) − bias) gives the angular acceleration. Accelerometer outputsthe linear acceleration. Thus, the roll and pitch angles can be computed asfollows.

pitch = arctan(ay/az) (2.10)

roll = arctan(ax/az) (2.11)

where, ax, ay, az are the acceleration components along X-, Y-, Z- direc-tions - obtained from the accelerometer. Using the above equations we candevelop the state model for obtaining euler angles from sensors. The statespace equations are as follows:

Xk = AXk−1 + BUk−1 + Wk−1 (2.12)

Zk = HXk + Vk (2.13)

where,

Xk =[

θ(k)bias(k)

](2.14)

A =[

10−dt

0

](2.15)

B =[

dt0

](2.16)

Uk = [θgyro(k)] (2.17)

Wk is the process noise, Qk is the covariance of Wk

Department of Electronics and Communications, BVBCET, Hubli.

Page 26: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 18

Qk =[

AccRMSnoise0

0GyroRMSnoise

]=

[0.001

00

0.003

](2.18)

Zk = [θaccelerometer] (2.19)

H =[

1 0]

(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 filter loop is known as the kalmanfrequency. For the IMU output to be real-time and accurate the kalmanfrequency should be sufficiently high. The sampling rate of the sensors hasto be same as the kalman frequency. This is achieved by reading the sensorsbefore the execution of each kalman loop. The inverse of the samplingrate gives the sampling period dt. The main loop containing the code forsensor reading and kalman filter is executed once every dt period of time.dt is calculated using the inbuilt timers in the microcontroller. The averagesampling period in our application is about 15 ms and hence the samplingrate is about 65Hz. This sampling rate is sufficient for the efficient workingof IMU.

2.3.4 Tuning the Kalman Filter Covariance Parameters

The performance of the Kalman Filter is improved by fine-tuning the noisecorrelation parameters. The need for tuning arises because these parametersare dependent on the accuracy of the sensors. This is in reference with theCovariance Matrix of Process noise, Qk which is reproduced here.

Qk =[

AccRMSnoise0

0GyroRMSnoise

]=

[0.001

00

0.003

](2.22)

The Accelerometer RMS noise parameter Qangle and the Gyroscope RMSnoise parameter Qgyro have to be properly set. Otherwise, the Kalman Filteroutput will be biased to either Accelerometer or Gyroscope output.

If the value of Qangle is set lower than the actual Accelerometer RMSnoise or if the Qgyro value is set too high than the actual Gyroscope RMSnoise, the Kalman filter output follows the Accelerometer output moreclosely making the output very noisy as shown below.

Department of Electronics and Communications, BVBCET, Hubli.

Page 27: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 28: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 20

On the other hand, if the value of Qangle is set too high than the actualAccelerometer RMS noise or if the Qgyro value is set too low than the ac-tual Gyroscope RMS noise, the Kalman filter output lags the Accelerometeroutput making the output very delayed. As seen in Fig. 2.11, the Kalmanfilter curve (Red) lags the Accelerometer curve (Green).

Thus, tuning is required.Tuning is done by trial and error, correctingthe parameters, Qangle and Qgyro and plotting the results in Matlab. Theprocess was repeated till the Kalman filter response was smooth enough toeliminate Accelerometer noise, and also quick enough to prevent any delayin the response. Accordingly, the parameters were finally tuned to the valuesgiven below.

1. Qangle = 0.0005

2. Qgyro = 0.003

The Covariance Matrix of Measurement noise, Rk is a parameter reflect-ing 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.

Page 29: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 21

Figure 2.11: Kalman Filter performance when motors are off

Department of Electronics and Communications, BVBCET, Hubli.

Page 30: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 22

Chapter 3

Flight Control

In this chapter, we present an overview of the theory of Quadrotor UAVflight control. We then explain what a PID controller is, how it is imple-mented and how it is tuned for the application at hand. In the succeedingsubsection, we explain how PWM signals are generated both in the softwareand hardware domains. This is followed by a technical description of theMotor driver circuitry. We describe each component used in detail and theCircuit protection measures employed. Finally, we show how a testbenchcan be built to do flight tests which will be helpful in tuning PID loops anddebugging.

3.1 Quadrotor Flight Control with Differential SpeedControl

Quadrotor uses four fixed 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 areaof the rotor and square of the speed of rotation.

Quadrotor design uses differential thrust to control the movement byvarying only the speed of the motors. Hence, no complicated swash platemechanism is required as in case of a conventional helicopter. The mechan-ical design is thus simplified compared to conventional helicopter.

If all the motors of the UAV rotate in the same direction, it results inthe whole UAV spinning about z-axis. Hence to prevent this, two adjacentmotors are rotated in opposite directions i.e 2 clockwise motor+rotor and 2counter-clockwise motor+rotor.

Page 31: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 theyproduce equal thrust. The UAV starts ascending when the combined thrust(F1+F2+F3+F4) over comes mg (weight of the UAV). The rate of ascentcan be controlled by controlling the speed of motors.

Similarly for Vertical Descent, speed of all motors is reduced dependingon the rate of descent required.

For the UAV to hover in a particular place, the total thrust of the motorshas 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 M1is reduced and simultaneously M3 is increased hence F1>F3 and the UAVtilts forward in the z-x plane. It is ensured that (F1+F3)=(F2+F4) to keepthe 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 tomaintain altitude of UAV and F1x along +ve x-axis which tends to movethe UAV forward.

Referring to Fig. 3.2, we haveForward thrust, F1x = F1 cos aUpward thrust, F1z = F1 sin a = mg (to maintain altitude)

Department of Electronics and Communications, BVBCET, Hubli.

Page 32: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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. Sim-ilarly by increasing M1>M3 i.e F3>F1 the UAV tilts backwards and tendsto move backward. Right and Left movements are achieved using the samemethod.

Clockwise / Counterclockwise Rotation

To rotate the UAV in clockwise direction, the speed of the 2 counter-clockwise rotating motors is reduced hence producing a thrust in clockwisedirection. Similarly to rotate the UAV counter-clockwise, speed of clockwiserotating motors is reduced.

Hover Stability

When the UAV is hovering at a place, all motors need to produce the samethrust and the rotational thrust should be balanced. Due to inherent differ-ences in the motors even while using similar motors, the RPM produced ata particular voltage differs on different motors. This produces differentialthrust. Hence, we need sensors in all the 6 degrees of freedom to sense anyunwanted drift in any direction. The output of the sensors is monitored andcorrective signals applied to stabilize the UAV. The processing of signals isdone by an on-board controller.

Generation of thrust by rotor

The total thrust generated by each motor + rotor combination depends ona number of factors-Area covered by rotor blades on rotation, rotor RPM,air density, velocity of incoming flow of air, acceleration of air flow due to

Department of Electronics and Communications, BVBCET, Hubli.

Page 33: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 25

propeller (depends on rotor blade pitch and rotor RPM). A general equationof thrust may be given as:

T = (π/4) .D2. (ν + ∆ν/2) .ρ.∆ν (3.1)

where,T = thrust [N]D = propeller diameter [m]v = velocity of incoming flow [m/s]∆ν= additional velocity, acceleration by propeller [m/s]ρ= density of fluid [kg/m3](for air: ρ= 1.225 kg/m3)

Approximating ideal conditions, we can assume velocity of incoming flowconstant; also density of air, propeller diameter, propeller pitch are constant.Hence we can reduce above equation to-

T ∝ RotorRPM (3.2)

3.2 Motor Control

3.2.1 PID Controller

A proportional-integral-derivative controller (PID controller) is a genericcontrol loop feedback mechanism (controller). A PID controller calculatesan ”error” value as the difference between a measured process variable and adesired setpoint. The controller attempts to minimize the error by adjustingthe process control inputs. In the absence of knowledge of the underlyingprocess as is the present case, PID controllers are the best controllers. How-ever, for best performance, the PID parameters used in the calculation mustbe tuned according to the nature of the system.

The PID controller calculation (algorithm) as shown in Fig. 3.3 involvesthree separate parameters: the proportional, the integral and derivativevalues, denoted P, I, and D. The proportional value determines the reactionto the current error, the integral value determines the reaction based on thesum of recent errors, and the derivative value determines the reaction basedon the rate at which the error has been changing. The weighted sum ofthese three actions is used to adjust the process via a control element suchas 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 onthe present error, I on the accumulation of past errors, and D is a predictionof future errors, based on current rate of change.

By tuning the three constants in the PID controller algorithm, the con-troller can provide control action designed for specific process requirements.The response of the controller can be described in terms of the responsiveness

Department of Electronics and Communications, BVBCET, Hubli.

Page 34: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 overshootsthe 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 fittingto 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 thesensor readings themselves. Defining u(t) as the controller output, the finalform of the PID algorithm is:

u(t) = Kpe(t) + Ki

∫e(t)dt + Kdd/dte(t) (3.3)

where, Kp = Proportional GainKi = Integral GainKd = Derivative Gaine(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 defined by the Autopilot. We setseparate gains for each one of yaw, roll and pitch. The output of the PIDcontroller, u(t) will define the amount of correction fed to the motors.

PID Tuning

For optimum performance of the PID loops, the values of Kp, Ki, Kd haveto be tuned appropriate to the UAV dynamics. It is desirable to use a

Department of Electronics and Communications, BVBCET, Hubli.

Page 35: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 27

vision system that would capture the UAV attitude in real-time and compareits recordings against the PID output. Due to absence of access to theaforementioned 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 areminimum.

3. Increase Kd in small steps till the number of overshoots reduce to aminimum.

3.2.2 PWM Generator

The PWM generator takes the output from the PID controller and generatesthe PWM signals to drive the motors. The output of the PID controllergives the measure of correction required to correct the error in the attitudeof the UAV. If the PID pitch is positive it indicates the UAV is tilted inthe forward direction and needs correction, similarly if it is negative, then itindicates that the UAV is tilted reversein the backward direction. The sameconcept applies to PID roll as well. The magnitude of the PID output givesthe magnitude of correction required. The role of the PWM generator is tointerpret the values and correspondingly vary the duty cycle of the PWMsignals to the motors. If the UAV is tilted forward then the PWM generatorreduces the duty cycle to the front motor and increases the duty cycle to therear motor by the same amount. The magnitude of the change in duty cycleis directly proportional to the magnitude of PID output and also dependson the RPM of the motors.

Fig. 3.4 shows a plot of RPM of motor rotation versus PWM signalwidth. From the nature of the slope it is clear that as the RPM increasessmall changes in PWM relates to larger changes in RPM. Hence at higherRPMs the change in the duty cycle for a certain magnitude of error is lesserthan the change in duty cycle at lower RPMs for the same magnitude oferror. 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.

Page 36: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 algorithmdepends on the RPM of the motors. At low RPMs, we set the value to 3; atmid RPMs, it is 2 and it is 1 for the lower RPMs. The classification of theRPM into low, mid and high slightly varies for the different motors. Thesegregation of the RPM and the gains were tuned experimentally.

To generate the PWM signals, we use the 16-bit in-built timer of themicrocontroller. The four PWM signals are output on four different I/Opins 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 thethrust generated by the four motors. The thrust of motors can be varied byvarying the RPM of motors which in turn is varied by varying the PWM tothe motors.

Components used:

Department of Electronics and Communications, BVBCET, Hubli.

Page 37: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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. Todrive them, a high power mosfet was used. Mosfets are Voltage controlleddevices and can be easily controlled in accordance with a PWM signal. Weused an N-channel Power Mosfet, IRF540 because of its easy availabilityand high current carrying capacity. The IRF540 pin connections are shownin Fig. 3.6.

IRF540 Specifications:

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 = 25C 22 A

5. td(on) Turn-on Delay Time

6. Rise Time 60 ns

Department of Electronics and Communications, BVBCET, Hubli.

Page 38: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 30

Figure 3.6: IRF540

7. td(off) Turn-off Delay Time 50 ns

The Mosfet is operated with a 12V power supply and a pullup resistanceof 10K was used. This yields a current of, 12V / 10K = 1.2mA. Thus, thephototransistor should be able to sink atleast 1.2mA of current for properoperation. 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). Thisstray noise can reach the microcontroller and mess up the digital signals.Thus, there is a need to isolate the microcontroller circuit from the Motordriver circuit. We achieve this by using an optoisolator. The optoisolatorconsists of a Light-Emitting-Diode (LED) and a Photo-Transistor. Whenthe LED is on, a base current is injected into the Base of the phototransistorand the transistor turns on and vice-versa.

The optoisolator used is ILQ74. We use the ILQ74 because it consistsof four pairs of optoisolators each of which can be used for each one of themotors. The ILQ74 is shown in Fig. 3.9.

ILQ74 Specifications:

1. Four Channel

2. TTL compatible

A resistor of 220 was used for the emitter. Accordingly, the LED currentwill be, 5V / 220 = 22.7mA.Referring to the Collector-emitter current versusLED current graph in Fig. 3.10, the CE current will be around 15mA. Thismuch current sinking capacity is enough for the next stage of the motordriver.

Department of Electronics and Communications, BVBCET, Hubli.

Page 39: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 40: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 32

Figure 3.9: ILQ74

Figure 3.10: ILQ74 Response

Department of Electronics and Communications, BVBCET, Hubli.

Page 41: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 pre-vent/reduce the back EMF reaching the digital circuit, we place 1N4007diodes across each motor. The back EMF generated forward biases thediode and hence the EMF gets a path to discharge preventing it from reach-ing 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 con-tent from being fed to the DC motors as capacitors pass AC content andblock DC content.

Fig. 3.11 shows the final motor driver circuit for one channel.

Circuit Operation

When the PWM signal is high, the LED inside the optoisolator is off. Thus,the corresponding BJT drive transistor is also off. As a result, the gate ofthe mosfet is pulled up to the supply voltage. The mosfet is thus turnedon when the PWM signal is on and motor is powered. Similarly, when thePWM signal is off, the LED is on causing the BJT driver to be on. Thispulls down the gate of the mosfet to ground. Thus power is cutoff to themotor when the PWM signal is low. The various waveforms are depicted inFig. 3.12.

Department of Electronics and Communications, BVBCET, Hubli.

Page 42: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 onboardsensors and microcontroller. The sensors and microcontrollers are low dis-charge and do not put much constraints on the power system. The motorsrequire a power system with high current discharge. Additionally to ensuresubstantial flight duration the power system should have high capacity. Theweight of the power system is an additional constraint, there has to be atrade off between the various constraints. Lithium polymer (Lipo) batteriesare light weight and capable of high discharge and decent capacity, hencethey are ideal for UAVs.

Lipo battery specifications:

1. Voltage : 11.1 V

2. Capacity : 20 C

3. Weight : 197 gm

3.3 Testbench

The development of a control system for a flying robot requires the de-velopment of an adequate testbench. This can help lock some number ofdegrees of freedom in order to reduce control complexity and to avoid sys-tem damage. For our control experiments, we built a testbench as shown inFig. 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.

Page 43: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 lockingyaw and pitch, we tune the PID gain for roll.

Department of Electronics and Communications, BVBCET, Hubli.

Page 44: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 KalmanFilter parameters which define the degree to which the Filter will dependon the two sensors. The results obtained after optimizing the Kalman filterCovariance parameters are as follows.

• Kalman Filter response with the motors off are is as depicted inFig. 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 depictedin Fig. 4.3.

The plots clearly show the superior performance of IMU with KalmanFiltering compared to the raw data available from the accelerometer andgyroscope sensors. It can be seen that the Kalman Filter waveforms followthe waveforms of the accelerometer closely and do not have the characteristicdrift of the gyroscope.

4.2 3D emulation of IMU in Processing software

To better visualize the response of the Kalman filter and to optimize thespeed of response of the PID controller to any changes in the tilt angles, theIMU wasemulated in 3D using Processing software as shown in Fig. 4.4. Thedata 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 centrewas shifted to the centre of the window. Then, for every set of sensorvalues received, the box was rotated about its axes by the amount of radiansregistered by the sensors.

Page 45: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 37

Figure 4.1: Kalman Filter response when motors are off

Department of Electronics and Communications, BVBCET, Hubli.

Page 46: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 47: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 48: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 accuracyof the tilt calculation. It also helped us check if the response of the Kalmanfilter was real-time.In addition, it was helpful in tuning the PID gains of thePID controller as shown in Fig. 4.5.

Department of Electronics and Communications, BVBCET, Hubli.

Page 49: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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.

Page 50: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 accelerometersand gyroscopes along with Kalman Filter for sensor fusion. We could formu-late the state model of the IMU, implement the Kalman Filter and optimizeit for an 8-bit microcontroller. We were also successful in emulating theIMU in 3D and in real-time which greatly helped in optimizing the filterresponse. However, in the stipulated time, we could not achieve all thatwe set out to do. Building the complete control system for an AutonomousUAV in a semester’s time was a daunting task. The DC brushed motorswhich we used would not respond quickly enough to the controls sent tothem. Hence, we could not achieve stable hovering of the UAV. Also, we didnot have access to the tools required for proper tuning of the PID controlloops. It is well known that PID tuning is as much of an art as it is scienceand comes from experience.

5.2 Future Work

In the future, we plan to pursue several improvements in the Flight controlof the UAV.

1. We envisage using Brushless DC motors replacing the existing DCbrushed motors. Brushless motors have several advantages over Brushedmotors like linear response, higher efficiency, more power, less noiseand long life. This simplifies the motor controller hardware and soft-ware.

2. We plan to incorporate a magnetometer to get accurate estimates ofyaw. Accuracy in yaw control is important if the UAV is to be usedfor video capturing and image processing applications.

Page 51: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 43

3. We plan to use a pressure sensor which will help the UAV sense itsaltitude. This will help is simplifying the Autopilot implementation.

Once we achieve stable flight tests, we would also like to add intelligentfeatures to the UAV.

1. We plan to enable the UAV to plan its own path depending on itsenvironment. A laser scanner can be used to obtain the informationfrom the UAV’s surroundings. Then, a 3D model of the surroundingscan be developed and obstacle detection algorithms be implementedto enable the UAV to detect obstacles and accordingly plan its path.This is quite challenging a task, but will greatly enhance the ability ofUAVs to do indoor flights.

2. We plan to mount a video camera onboard the UAV and implementimage processing operations like activity detection and recognition.Such intelligence features will greatly enhance the scope of applicationsfor UAVs.

3. It is highly desirable to do all the Image processing operations onan onboard controller. So, we plan to migrate to a more powerfulprocessor like the OMAP3530 which is available in ready-to-use smalldevelopment boards like the Beagle Board and the Gumstix.

4. We also plan to incorporate a GPS onboard the UAV. With this, theUAV can do long distance reconnaissance flights.

Department of Electronics and Communications, BVBCET, Hubli.

Page 52: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 44

Bibliography

[1] Charles A. Clifton. Hybrid system based design for the coordinationand control of multiple autonomous vehicles. Proceedings of the FourthIEEE International Conference and Gesture Recognition, Grenoble,France, August 2005.

[2] B. Erginer and E. Altug. Modeling and pd control of a quadrotor vtolvehicle. 2007 IEEE Intelligent Vehicles Symposium, 2007.

[3] Spencer G Fowers. Stabilization and control of a quad-rotor micro-uavusing vision sensors. August 2008.

[4] S. L.Waslander D. Dostal J. S. Jang G. Homann, D. G. Rajnarayanand C. J.Tomlin. The stanford testbed of autonomous rotorcraft formulti-agent control (starmac). Proceedings of the 23rd Digital AvionicsSystems Conference, 2004.

[5] L. Beji K. Zemalache and H. Marref. Control of an under-actuatedsystem: Application a four rotors rotorcraft. 2005 IEEE InternationalConference on Robotics and Biomimetics (ROBIO), 2005.

[6] I. Kroo and F. B. Prinz. The mesicopter: A meso-scale flight vehicle.Stanford University, 1999.

[7] CHEN Ben M. LIN Feng, LUM Kai-Yew and LEE Tong H. Develop-ment of a vision-based ground target detection and tracking system fora small unmanned helicopter. 2009.

[8] A. Mokhtari and A. Benallegue. Dynamic feedback controller of eulerangles and wind parameters estimation for a quadrotor unmanned aerialvehicle. 2004 IEEE International Conference on ICRA, 2004.

[9] T. Hamel N. Guenard and V. Moreau. Dynamic modeling and intuitivecontrol strategy for an x4-flyer. Control and Automation, 2005.

[10] R. Mahony P. Pounds and P. Corke. Modelling and control of a quad-rotor robot. Australasian Conference on Robotics and Automation 2006,December 2006.

Page 53: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 45

[11] Andr´e Noth Samir Bouabdallah and Roland Siegwart. Pid vs lq controltechniques applied to an indoor micro quadrotor. Autonomous SystemsLaboratory Swiss Federal Institute of Technology Lausanne, Switzer-land.

[12] A. Tayebi and S. McGilvray. Attitude stabilization of a four-rotor aerialrobot. Image and Vision Computing, 2004.

[13] H. Voos. Nonlinear state-dependent riccati equation control of a quadro-tor uav. Control Applications, 2006 IEEE International Conference on,2006.

Department of Electronics and Communications, BVBCET, Hubli.

Page 54: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 circuitconsists of the Atmega32 microcontroller which interfaces with the sensormodule on the I2C (TWI on Atmega32) bus. The microcontroller also gen-erates the PWM signals which feed the motor driver circuit. The motordriver circuit consists of Mosfets and an Optoisolator is used to protect thedigital circuit from the EMI generated by the motors.

Page 55: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 47

Figure A.1: Complete Circuit Diagram of the UAV

Department of Electronics and Communications, BVBCET, Hubli.

Page 56: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 48

Appendix B

I2C

The I2C bus, read as I squared C, because of its simplicity and flexibility,has become one of the most important microcontroller bus system usedfor interfacing various peripherals with the microcontroller. The I2C bususes only two bidirectional data lines for communicating and the protocolspecification can support up to 128 devices attached to the same bus. On theAtmega32 microcontroller, the I2C protocol is implemented as Two-Wire-Interface (TWI).

The I2C protocol uses master and slave method, the master which isusually the microcontroller while the slave can be any I2C devices such asSerial EEPROM, I/O Expander or even another microcontroller. All ofthese 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 addresslength. The 7 bits address consists of 4 bits device identification and 3bits device physical address. By selecting the appropriate device address,the master can easily communicate with the entire slave devices connectedto the I2C bus; the I2C bus protocol only allowed one connection to beestablished 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 bya pulse on the clock line. The level of the data line must be stable when theclock line is high. The only exception to this rule is for generating start andstop conditions. The Master initiates and terminates a data transmission.The transmission is initiated when the Master issues a START conditionon 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, andno other Master should try to seize control of the bus. A special case oc-curs when a new START condition is issued between a START and STOP

Page 57: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 49

condition. This is referred to as a REPEATED START condition, and isused when the Master wishes to initiate a new transfer without releasingcontrol of the bus. After a REPEATED START, the bus is considered busyuntil the next STOP. This is identical to the START behavior, and there-fore START is used to describe both START and REPEATED START forthe remainder of this datasheet, unless otherwise noted. START and STOPconditions are signaled by changing the level of the SDA line when the SCLline is high.

B.2 Address Packet Format

All address packets transmitted on the I2C are nine bits long, consistingof seven address bits, one READ/WRITE control bit and an acknowledgebit. If the READ/WRITE bit is set, a read operation is to be performed,otherwise a write operation should be performed. When a Slave recognizesthat it is being addressed, it should acknowledge by pulling SDA low in theninth SCL (ACK) cycle. If the addressed Slave is busy, or for some otherreason can not service the Master’s request, the SDA line should be left highin the ACK clock cycle. The Master can then transmit a STOP condition,or a REPEATED START condition to initiate a new transmission. Anaddress packet consisting of a Slave address and a READ or a WRITE bitis called SLA+R or SLA+W, respectively. The MSB of the address byte istransmitted first. Slave addresses can freely be allocated by the designer,but the address 0000 000 is reserved for a general call. When a generalcall is issued, all Slaves should respond by pulling the SDA line low inthe ACK cycle. A general call is used when a Master wishes to transmitthe same message to several Slaves in the system. When the general calladdress followed by a Write bit is transmitted on the bus, all Slaves setup to acknowledge the general call will pull the SDA line low in the ACKcycle. The following data packets will then be received by all the Slavesthat acknowledged the general call. Note that transmitting the general calladdress followed by a Read bit is meaningless, as this would cause contentionif several Slaves started transmitting different data. All addresses of theformat 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 ofone data byte and an acknowledge bit. During a data transfer, the Mastergenerates the clock and the START and STOP conditions, while the receiveris responsible for acknowledging the reception. An Acknowledge (ACK) issignaled by the receiver pulling the SDA line low during the ninth SCLcycle. If the receiver leaves the SDA line high, a NACK is signaled. When

Department of Electronics and Communications, BVBCET, Hubli.

Page 58: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 anymore bytes, it should inform the transmitter by sending a NACK after thefinal byte. The MSB of the data byte is transmitted first.

B.4 Transmission modes

A transmission basically consists of a START condition, a SLA+R/W, oneor more data packets and a STOP condition. An empty message, consistingof a START followed by a STOP condition, is illegal. The Slave can extendthe SCL low period by pulling the SCL line low. This is useful if the clockspeed set up by the Master is too fast for the Slave, or the Slave needs extratime for processing between the data transmissions. The Slave extending theSCL low period will not affect the SCL high period, which is determined bythe Master. As a consequence, the Slave can reduce the TWI data transferspeed 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 anacknowledge bit (A) from the slave which the slave will only generate if itsinternal address matches the value sent by the master. If this happens thenthe master sends DATA and waits for acknowledge (A) from the slave. Themaster completes the byte transfer by generating a stop bit (P) (or repeatedstart).

B.6 Data transfer from slave to master

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

Department of Electronics and Communications, BVBCET, Hubli.

Page 59: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 51

Figure B.2: Data transfer from slave to master

Department of Electronics and Communications, BVBCET, Hubli.

Page 60: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 52

Appendix C

USART

USART stands for Universal Synchronous Asynchronous Receiver Trans-mitter. It is sometimes called the Serial Communications Interface or SCI.Synchronous operation uses a clock and data line while there is no sepa-rate clock accompanying the data for Asynchronous transmission. Sincethere is no clock signal in asynchronous operation, one pin can be used fortransmission and another pin can be used for reception. Both transmissionand reception can occur at the same time - this is known as full duplexoperation. Transmission and reception can be independently enabled. How-ever, when the serial port is enabled, the USART will control both pins andone cannot be used for general purpose I/O when the other is being usedfor transmission or reception. The USART is most commonly used in theasynchronous mode. The most common use of the USART in asynchronousmode is to communicate to a PC serial port using the RS-232 protocol.Adriver 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 configured to transmit eight or nine data bits bythe TX9 bit in the TXSTA register. If nine bits are to be transmitted, theninth data bit must be placed in the TX9D bit of the TXSTA register beforewriting the other eight bits to the TXREG register. Once data has beenwritten to TXREG, the eight or nine bits are moved into the transmit shiftregister. From there they are clocked out onto the TX pin preceded by astart bit and followed by a stop bit.

The USART can be configured to receive eight or nine bits by the RX9bit in the RCSTA register. After the detection of a start bit, eight or ninebits of serial data are shifted from the RX pin into the receive shift registerone bit at a time. After the last bit has been shifted in, the stop bit is checkedand the data is moved into the buffer which passes the data through to theRCREG register if it is empty. The buffer and RCREG register thereforeform a two element FIFO. If nine bit reception is enabled, the ninth bit ispassed into the RX9D bit in the RCSTA register in the same way as the

Page 61: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 syn-chronous slave mode. The baud rate is set by writing to the SPBRG register.The SYNC bit selects between synchronous and asynchronous modes, andthese modes have different baud rates for a particular value in the SPBRGregister. For asynchronous mode, the SYNC bit must be cleared and theBRGH bit is used to select between high and low speed options for greaterflexibility in setting the baud rate.

Department of Electronics and Communications, BVBCET, Hubli.

Page 62: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

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 Component Name QuantityMicrocontroller Atmega32 1Mosfet IRF540 4Optoisolator ILQ74 1Accelerometer LIS3L02 (Wii Nunchuk) 1Gyroscope IDG600 (Wii Motionplus) 1

X3500W (Wii Motionplus) 1Resistors 220Ω 4

10KΩ 6Diodes 1N4007 4Capacitors 0.1uF 4Motors DC brushed Motors 4Battery 3SIP 11.1V Li-Po 1

Table D.1: List of Components

Page 63: Quadrotor Unmanned Aerial Vehicle - Inertial Measurement Unit, Kalman Filter, PID controller

Control System of an Autonomous Quadrotor UAV 55

Appendix E

Chassis Specifications

Frame parts:

1. Arm rods (4): Carbon fiber rods, Tube length: 247mm, Tubediameter: 5mm.

2. Frame center cross piece (1): strong high impact nylon.

3. Vertical risers (4): Durable plastic.

4. Base plate (1): Carbon fiber.

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 theupright portion of the motor mount (53 tooth).

4. Rotors (4): SAVS style (2 piece) nylon injected folding rotorblades.

(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.