Sunteți pe pagina 1din 22

UNIVERSITY OF ILLINOIS URBANA CHAMPAIGN

Advanced Digital Systems Laboratory - ECE395

Mini Quadrotor Recon


Drone
Tyler Steigerwald (tsteige2)
Steve Zazeski (szazesk2)

Mini Quadrotor - 1

Table of Contents
Abstract

Parts

Background

Programming

Vibration Management

15

Wiring Diagram

16

Aerodynamics & Weight

19

Issues / Suggestions

20

Quadrotor Advice

21

Pictures

22

Mini Quadrotor - 2

Abstract
This project builds a quadrotor aircraft that is autonomously controlled by a PIC
microcontroller with a set of waypoints sent to it before it takes off that the flight controls
follows while using various sensors to avoid obstacles on its way to completing its
waypoints.

Quadrotors use four fixed blade motors and a PID controller to balance itself in 3
dimensional space by adjusting the speed of the four motors. This project takes on the
goal to build a quadrotor in two stages, first to build a stable quadrotor and the second to
automate it with GPS to fly without a human pilot. This semester was focused on making
a working quadrotor using a PIC Microcontroller, four ESC, four brushless motors and an
accelerometer.

At the end of the semester we had a fully built quadrotor that could almost fly but we
plagued with multiple motor failures at the end due mostly to an unplanned issue of
vibration caused by the motors that broke the enamel magnet wire in the coils of the
motors.

Mini Quadrotor - 3

Parts
PIC MICROCONTROLLER

PIC18LF44k22 - I/P (L = Low Power 3.3v)


40-pin, 28x Analog 10-bit Channels, 7 x Timers, 2 x EUSART
We choose the 44k22 for its high pin count, multiple serial ports and high timer count. However it claims
to be able to run at 64Mhz but using the internal oscillator block, we were never able to actually achieve
that speed. That being said, a high Mhz clock actually makes creating the PWM to the ESC (which use servo
standards) more difficult.
OP AMPS

MIC4424CN0408
We dont have much info on these as we found these from a previous project. We used them to up the
3.3voltage from the PICs output to 5v so the ESC would work with the lower power PIC. In hindsight we
would recommend using a 5v PIC instead.
BATTERY

7.4v 1800mah 30C EZ Flite Lipo Battery<http://www.headsuprc.com/servlet/the-1952/7.4v-1800mah-30C-EZ/Detail>


COST

$13.95

SENSORS

MMA7341L 3-Axis Accelerometer 3/11G


COST

<http://www.pololu.com/catalog/product/1252>

$14.95

LPR510AL Dual-Axis Gyro with 100/400/s <http://www.pololu.com/catalog/product/1266>


Two-stage low-pass filtered output
Onboard voltage regulator for integration with 5V projects
COST
$19.95
BRUSHLESS MOTORS

Power Up 180 Sport <http://www.headsuprc.com/servlet/the-1591/Power-Up-180-Sport/Detail>


WEIGHT
POWER RATIO
MOTOR STYLE
5 PROP THRUST
TOTAL THRUST
COST

10 GRAMS (0.35oz)
2000KV
Outrunner
125 GRAMS at 2.7amps
500 GRAMS at 10.8 amps
$10.95 ($43.80 total)

TOTAL COST : $92.65 + Shipping + Tax + Rotors + Aluminum Frame + Spare Parts

Mini Quadrotor - 4

1.Background Information

Quadrotors are a type of vertical takeoff rotorcraft that were designed to be cheaper and capable of
lifting more weight than a single rotor aircraft. Helicopters use a large pitch changing main rotor and a
smaller tail rotor to counteract the rotation torque that the main rotor places on the body. Due to the
size of the main rotor, to make a helicopter controllable the main rotor has variable pitch to change how
much lift is actually being produced instead of relying on the motors to adjust the rotational speed of
the rotor. This makes the main rotor very complex and as you need to have controls to change the pitch
of a constantly rotating main shaft.

Quadrotors cuts out the complex variable pitch rotor by replacing it with 4 fixed pitch motors. Since
the rotors are smaller, the motors are capable of quickly adjusting the overall speed to react to flight
situations. Also without the addition pitch adjustment, fixed blades are much stronger and increase the
lifting capacity of a quadrotor.

Mini Quadrotor - 5

Rotor Rotation
Since quadrotors do not have tail rotors to counteract the torque produced by the blades, the quadrotor
instead needs to keep motor speeds in proportion of matching pairs to keep the quadrotor from
rotating. If all motors are running at the same amount, the quadrotor will hold steady. However, if one
of the motors is running faster and thus producing more torque, the quadrotor will start to spin in the
direction of the torque.
Hold Position
Rotate Right
Fly Right

All motors equalize each other torques


One motor runs faster to produce torque in the opposite direction
Adjust balance to tilt in the right direction

Mini Quadrotor - 6

Brushless Motors
To meet the weight requirements to make the quadrotor fly, we used brushless DC motors which
are drastically less weight than their brushed counterpart. In the initial test build we tried to build a
quadrotor using brushed DC motors but each motor weighed 70 grams and only produced 30 grams of
lift at voltages beyond the rated values of the motor.
We then used Outrunner Brushless Motors which weighed 10 grams and could produce 125 grams of
lift. Outrunner brushless motors work by basically taking a regular motor and reversing it. Instead of
rotating the large magnetic core, brushless outrunners rotate small lightweight neodynamic magnets
placed on the outside case of the motor. Brushless work by instead of having the motor use a brush
to reverse the electric phase, it instead has 3 phases run out to an Electronic Speed Controller or ESC
to power the phases in the correct order to control motor speed.
ESC - Electronic Speed Controller
ESC are basically small circuit boards that have a low end microcontroller (often amtel) and op amps
to feed the necessary power to motors. You will feed in a Servo Standard Pulse with an encoded duty
cycle to the ESC and the ESC will produce the necessary output to the motor. Our project used 10 and
20 AMP ESC but you can buy them in excess of 100AMP. While you could build in the ESC function into
your primary microcontroller, they are best offloaded to these devices because they require constant
switching of phases which would use up all of your MCUs processing time. Most ESC give add benefits
of motor startup, braking and coasting/shutdown options if it stops seeing a servo signal sent to it.
Plus the ESC lets you use only 1 output pin of your microcontroller instead of 3 pins for each motor.
Servo Standard Pulse
Most servo motors use a standardized pulse to send a digital signal of the angle you want the servo
to move to with builtin error protection in case the signal line breaks. Every 20ms (50hz) you need to
send a pulse that can last from 1ms to 2ms which equals 0% to 100%. So if you want to run at 50% you
will send a pulse out that last 1.5ms every 20ms. If the servo/ESC doesnt receive a 1-2ms pulse every
20ms then it will go into shutdown/coast mode.

Motor Prop [Propellers]


When selecting motor propellers you will see numbers like 5030. This means the propeller is 5 wide
with a forward pitch of 3 per revolution. Higher pitch means that it will make more lift with each

Mini Quadrotor - 7

rotation of the propeller.


Accelerometers
When an accelerometer sensor is sitting level on the ground the readings will be < 0 m/s 2, 0 m/s2, 9.8 m/s2> but when the unit is turned slightly counterclockwise around the y axis, the results will be
<2,0,-7.8>. Using this we are able to easily detect the angle of the quadrotor to maintain a hover or to
move forward. However, since the accelerometers perspective will change as the quadrotor angles,
we cannot use it to tell how far it is moving in any direction. To do this you either need to mount the
accelerometer into a gyroscope mount or use a gyroscope to correct for the rotation.

In this project we are simply using the accelerometer to detect balance. More advanced quadrotors
actually use just a gyroscope and integrate its output to get the balance as well.

Mini Quadrotor - 8

2.Programming
Our program has 3 stages: Startup, Normal and Panic modes. During the startup the usart is started up
first to give us debug information as soon as possible. Then the pulses for the motors are started up.
When we first enable the pulses, we need to feed a 5% duty cycle pulse to the ESC to notify them to
startup. Failure to produce a 50hz pulse will cause the ESC to panic and shutdown. Also the ESC startup
will calibrate the ESC to the lowest speed position incase your system does not produce an accurate 5%
duty cycle.

TIMERS
Instead of using the PWM module of the PIC we decided to go with the Timers and create the signals
ourself. We wanted to make sure that the 4 timers would keep a constant 50hz without having to
worry about interrupt conflicts that would cause a break in the constant 50hz pulses.

(M0, M1, M2, M3 are the motor pulses)

Mini Quadrotor - 9

// Turn on Interrupts --------------------------------INTCON = 0x20;


INTCON2 = 0x04;
// TMR0 high priority
RCONbits.IPEN = 1;
// Enable priority levels
// Setup Timer0 --------------------------------------T0CON = 0x80;
// set up timer0 - prescaler 1:2
TMR0H = 0x63;
// Set Countdown High
TMR0L = 0x91;
// Set Countdown Low
INTCONbits.GIEH = 1;
// Enable interrupts

So we setup Timer 0 to be a perfect 50hz clock that then starts Timer1 and Timer3. We used Timer3
because Timer1,3,5 configurations are the same while Timer2,4 are different. Timer1 will turn off the
output pulse when the desired duty cycle is reached. We setup a variable called motor[x] which holds
the duty cycle of all 4 motors. That value is set as Timer1s value to interrupt. Timer3 is setup to then
start the next motors pulse. Timer 3 is setup to go off every 3ms giving the last motor an extra 1ms
incase anything happens to go wrong. So using this method we can guarantee all 4 motors to get a
50hz pulse yet only use 12ms of the 20ms giving plenty of time for PID calculations.

Below is our timer interrupt code including the low level assembler block to call the high priority
interrupts [our timers].
/*******High priority interrupt vector ************************/
#pragma code high_vector=0x08
void interrupt_at_high_vector(void){
_asm GOTO high_isr _endasm
}
#pragma code

Mini Quadrotor - 10

/*****************High priority ISR **************************/


#pragma interrupt high_isr
void high_isr (void){
if (INTCONbits.TMR0IF){
// 50hz - 25ms
// TIMER0 --------------------------------------------------50hz SYNC
INTCONbits.TMR0IF = 0;
// Reset Interrupt
TMR0H = 0x63;
// Timer Reload to count 1s
TMR0L = 0x80;
// TMR0 = 25489
//Start Timer3 for 2.5ms Pulse
T3CON |= 1;
// ENABLE
TMR3H = 0xDA;
TMR3L = 0x00;
}else if(PIR1bits.TMR1IF){
// TIMER1 --------------------------------------------------PULSE OFF
PIR1bits.TMR1IF=0;
// Reset Interrupt Timer1
T1CON &= 0xfe;
// Disable Timer1
bitclear(RB,motorselect);
PORTB=RB;
motorselect++;
if(motorselect>4){
// If all motors are done goto PID
motorselect=0;
T3CONbits.TMR3ON = 0;
}
}
// TIMER3 --------------------------------------------------Next Motor
else if(PIR2bits.TMR3IF){
PIR2bits.TMR3IF=0;
TMR3H = 0xBA;
TMR3L = 0x00;
bitset(RB,motorselect);
PORTB=RB;
// Start Timer1 for Pulse OFF
T1CON |= 1;
// ENABLE
TMR1H = motor[motorselect]>>8;
TMR1L = motor[motorselect];
}
}

PID - PROPORTIONAL INTEGRAL DERIVATIVE CONTROLLER


We start the PID once we leave the startup section of our code and get into normal operation. The
first stage of the PID is to read the sensor data from the accelerometer. To remove noise, we have it
read the sensor 5 times in a row and take the average of the numbers. During our startup we have
already configured the baseAX (Base Accelerometer X value to center the voltage reading at 0)
void getSensors(){

Mini Quadrotor - 11

//Get Accelerometer Readings


// X-AXIS
OpenADC( ADC_FOSC_4 & ADC_RIGHT_JUST & ADC_20_TAD, ADC_CH0 &
ADC_INT_OFF,0);
dblchkX=0;
dblchkY=0;
for(i=0; i<5; i++){
Delay10TCYx( 5 );
ConvertADC();
while( BusyADC() );
dblchkX = ReadADC();
}
dblchkX=dblchkX/5;
accX = dblchkX - baseAX;

//
//
//
//

Delay for 50TCY


Start conversion
Wait for completion
Read result

if(accX>7 || accX<-7){
panic=1;
}
}

PID is a feedback loop of reading the sensors that have been offset so 0 is the desired value and then
reacting to the sensor values by summing the results of porportional, integral and directives to the
motor controller.
Proportional Control is the standard feedback reaction to balance an object
Derivative Control is a stopping force to not overshoot the balance point
Integral Control is a error correction force to compensate for off balance weight and other errors
The actual PID operations are quite simple. Proportional control is simply the current reading from the
sensor when it is corrected to be 0 when it is level. Derivative control is the difference of the sensor
from the last reading. Integral control is the difference added up and stored in a non resetting variable
through interactions. In our controller we then took the results and multiplied them by kp=5, ki=1,
kd=3 coefficients.
BalanceX = ( 5 * Porportional ) - ( 3 * Derivative ) + ( 1 * Integral );
MotorSPeed = Height + MotorOffset + BalanceX + MoveX;
The next page shows a single axis of PID controller code with additional modifications to make the PID
work better.
// PID CONTROLLER--------------------------------------------------------integralMAX=2000;
// To stop the integral from getting too large
if(accX>50){
accX=50;
// Bounds check for glitches that would hurt integral

Mini Quadrotor - 12

}
if(height<44000){
// 44000 is basically off the ground, start integral
if(accX > 0){
sumAX += 1;
}
if(accX < 0){
sumAX -= 1;
}
if(sumAX>integralMAX){
sumAX=integralMAX;
}
if(sumAX<-integralMAX){
sumAX=-integralMAX;
}
}
dAX=accX-lastAX;
lastAX=accX;
if(dAX>40 || dAX<-40){
dAX = 0;
accX = lastAX;
}
// BALANCE CONTROLLERS ***************************************************
kp = 5;
kd = 3;
ki = 1;
// ***********************************************************************
accXkp = kp*accX;
dAXkd = kd*dAX;
sumAXki = (ki*sumAX)/3;
balanceX = accXkp - dAXkd + sumAXki;
if (balanceX > 500){
balanceX = 500;
}
if(balanceX < -500){
balanceX =-500;
}

We limit the integral because if it gets too large it will eventually overflow the variable and have a
sudden decrease of integral control and we limit it so that when the quadrotor overshoots the balance
point, it wont take forever to reset it to 0 again. Integral control often has the issue that it builds up too
slowly when you need it and it stays around too long when you no longer need it.

SAFETY LOCKOUTS
When developing a quadrotor, a lot of things will go wrong and so we had built in safeties to protect
ourselves and hopefully the quadrotor from breaking itself.

Mini Quadrotor - 13

Motor RPM Limiters - We stopped our motors from going under 42000 (8000rpm) to stop it from
reving up too powerful. At about 44000 it will lift off the ground, so the extra 2000 gives it some
movement but not too much.
Balance Limiters - In our PID controller, at the end, we bounds check it and make sure its not
more than about 200 since any more means it probably will crash before it can correct that
much of an imbalance. Also this helps if a noise glitch occurs from the balance controller setting
the motors to full power to correct for noise.
ADC Limiters - We bound check the incoming accelerometer values and if we ever see a value
that is over +/- 45 degrees we assume this as a noise glitch. Also the panic stop safety will kick in
before this value.
Integral Limiters - Since the integral will keep building up, if we start the quadrotor during a test
flight and hold it unbalanced for a time before letting it lift off, the integral could be massive and
it would never be able to correct for it.
Accelerometer Panic Stop - If the quadrotor tilts too much, the panic will kick in and basically shut
it down. During initial testing we kept this at about 10 degrees or so because we didnt want to
break our quadrotor.

Mini Quadrotor - 14

3.Vibration Management
Running 4 motors at 8000 rpm creates a lot of vibration that is transposed through the frame
of the quadrotor. Two major components have various issues with the vibration.
Motors
During startup, vibration on the motors could cause the motor to not spin correctly and the
ESC will sense the phases not rotating correctly and shut down.
If the motors are running, vibration can cause the motors to not spin at the speed the ESC is
trying to run them at and cause the quadrotor to spin like a top.
Finally, the solid magnetic enamel wire running from the ESC to the motor phase coil would
cause a break in the wire to occur right where the wire enters into the coil. This break is
almost impossible to fix without cutting the windings out and rewinding the entire motor.
Accelerometer
One device that was mounted onto the frame of the quadrotor that had a huge issue
with vibration was the accelerometer. When the motors were off, the accelerometer
would produce a very clean and accurate angle to voltage output. However, when the
motors were running, the output of the accelerometer would look like pure noise on the
oscilloscope.

Managing Vibrations
Rubber Pads - We placed rubber pads under each brushless motor and on the underside
where the nuts lock onto the frame. This offered some vibration control but since the ESC
were mounted without pads, its questionable if this is a reason why the enamel wire was
breaking.
Smoothing Capacitors - We placed a 3.3uf capacitor between each axis of the
accelerometer to ground to remove the noise that we were seeing due to vibration. We
tried various capacitance and found too much caused the accelerometer to be way too slow
reacting. By reducing the capacitance you increase the noise but decrease the reaction time
of the accelerometer. We ended up in a middle ground of noise but then used digital filter/
averages to correct the outliers.

Mini Quadrotor - 15

4.Wiring Diagrams

ACCELEROMETER

Mini Quadrotor - 16

GYRO

OP AMP

Mini Quadrotor - 17

Mini Quadrotor - 18

5.Aerodynamics & Weight


This project requires a lot of consideration in aerodynamics, center of mass and weight
distribution.
Motors
ESC
MCU/Board
Frame
LiPo Battery
Total

10grams /each
~15grams /each
35grams
101grams
88grams

x4
x4

40 GRAMS
60 GRAMS
35 GRAMS
101 GRAMS
88 GRAMS
324 GRAMS

Mini Quadrotor - 19

6.Issues / Suggestions
Lighter weight frame - we started off with a 20 gram circuit board frame and it had too much vibration
through it so we upgraded to Aircraft Aluminum. In hindsight this was too much of a change and we
should've found a slightly stronger but lighter weight frame. While the motors could potentially lift
this, it would be easier to fly if we had a much lighter frame.
Use a 5v microcontroller to cut out the need for OP-AMPs
We accidentally bought a LF 3.3v PIC and regret not getting a 5V. We then bought sensors that used
3.3v but had ESC that needed 5V signals. Also our serial MAX chip wanted 5v as well. Overall we
should of done a better job reducing the different voltages that we will be needed. However the
GPS module only came as 1.8vdc which could withstand up to 3.3vdc signals. Though we didnt get
around to integrating the GPS.
Motor Rewinding
We damaged a number of motors due to vibration breaking the coil wires and so we decided to learn
how to rewind the motors. This actually looked like it was working great. We cut out the old windings
which took longer than rewinding the motors. It is actually quite simple. There are 9 sections of the
stator and you will wrap three phases. Starting with one 30AWG Enamel Magnet wire you will start
at any section and place 10 windings in, then skip 2, and wind that section with the same wire. Make
sure you keep your clockwise direction and number of windings the same in all sections. Then skip
2 more and finish the last winding. Repeat with Phase B and C. Then sand off the edges of all wires
and using an ohm meter check that there is no short between Phase A B and C. If its good, then wire
and solder one end of Phase A, B and C all together. Heat shrink all wires and you have a new motor
winding.
Sounds great huh? Either the enamel in the lab is bad or we nicked a wire but every motor we
rewound worked great for a while and then caught fire. But dont worry they burn out and smoke
really quickly and you are left with this.

Mini Quadrotor - 20

Quadrotor Advice
Just because you should be able to lift it doesnt mean it should weigh that much
Make everything as light as possible as it will make everything easier. Lower RPMS, less
vibration, less amperage, smaller battery, etc.

Get off the protoboard as soon as possible


You will waste so much time trying to get half of a quadrotor balancing to only find when you
mount everything on it, that it behaves entirely different. Either design a board or use a Perf
Board and mount it to the quadrotor as soon as you start trying to make it take off.

Use Bluetooth
You will want debug info off the PIC and you will want to have an entire keyboard of buttons
to send commands back to the PIC. Also you dont want any extra wires going to the
quadrotor.

Use a Computer Power Supply


Sure eventually you will want to run it on a battery but dont waste the recharge time, you
can mount the battery on the quadrotor for realistic weight but hook up the quadrotor to the
12V rail and enjoy 15amps of continuous power. The lab supplies cannot give more than a
couple amps which just dont work.

Safety Wires may not help


If you are looking to use wires to hold your quadrotor in one place, you will find it impossible
to balance because as soon as it hit one of the wires it will act like a pendulum and store
energy. Your best best is to weigh it down, place it on the floor and have a kill switch ready
for when it messes up.

Crashes
Your quadrotor is going to crash a lot. Buy extra parts because you will eventually break
motors, ESCs and blades. Often if you burn up a motor, you will also burn up the esc. And you
really need to have all the motors and esc the same brand and model if you want to balance
it.

Mini Quadrotor - 21

Mini Quadrotor - 22

S-ar putea să vă placă și