Posts Tagged ‘ gyro ’

Quadcopter Software Design

Before I begin discussing the quadcopter design, here is a diagram that shows the high-level software structure for my design:

All future software design posts will reference to this diagram.  Here is a short explanation of the necessity and function of each block:

PWM Decoder Driver:
In order to interpret flight commands from a standard RC Transmitter/Receiver, any multi-rotor design must have some sort of PWM decoder.  My decoder will be expecting a single signal containing all PWM channels (details here).  The decoder driver will translate the several channels of pulse widths into values to be interpreted by the command translator.

Command Translator:
Depending on the flight mode, the PWM values given by the transmitter are interpreted differently.  The command translator determines which mode the user is flying in and translates the commands accordingly.

I2C Master:
The inertial sensors I’ve chosen to use all run on the I2C protocol.  This high-speed protocol will be a great interface to use because of its addressing scheme and its interrupt time efficiency.  The I2C protocol is more complicated that most serial protocols but the LPC1768 has built-in hardware to handle the physical layer.  The I2C interrupt scheme for this hardware is very efficient with each interrupt needing only a few lines of code.

Sensor Fusion:
As mentioned in an earlier post, I will be implementing several sensor fusion algorithms to find out which has the best performance.  The first one I will implement is the Extended Kalman Filter (EKF).  The EKF algorithm is widely known to be one of the best methods for state (in my case aircraft attitude) estimation.  This filter will take the sensor readings from the various sensors and output an estimation of the current aircraft attitude.  For my initial design it will be important to measure:

  • Roll – Side to side angle relative to the horizon
  • Pitch – Front to back angle relative to the horizon
  • Roll Rate – Side to side rotational rate relative to the horizon
  • Pitch Rate – Front to back rotational rate relative to the horizon
  • Yaw Rate – Horizontal rotational rate relative to magnetic heading
  • Magnetic Heading – Direction relative to magnetic north

Proportional-Integral-Derivative (PID) Stabilization:
Once the desired aircraft attitude is determined from the transmitter commands and the actual aircraft attitude is determined from the sensor fusion algorithm, PID controllers are used to determine the fastest way to make the desired attitude become the actual attitude.  PID controllers are very efficient for control of a system in which an accurate physical model is unknown.  Using calculus to determine error slopes and areas, PID controllers compensate for environmental noise and disturbances while overcoming steady state error and oscillations.  PID controllers are VERY simple to design and code but are VERY hard to tune and calibrate.  (see this post)

Multi-Rotor Throttle Mixing (MRTM):
Standard helicopters use Cyclic Collective Pitch Mixing (CCPM) to adjust the aircraft attitude.  It works by adjusting the pitch of the blades depending on their current angular position.  I came up with term MRTM, as I haven’t found a term defined for multi-rotor helicopters.  MRTM works by adjusting the speed of several propellers in such a way that results in the same aircraft control and a typical helicopter (a post will soon follow that explains this in detail).  MRTM can be used to control the attitude of many styles of multi-rotor helicopters.

PWM Encoder Driver:
Once everything has been computed, the PWM Encoder takes the control values and generates a pulse width modulated (PWM) output for each motor.  This is the exact opposite process of the PWM Decoder.  The LPC1768 has good support for PWM output.  I’ll be able to output all channels of PWM without using any interrupts or processing time.  Can’t beat that!

Advertisements

Quadrotor Parts List

Here is the initial parts list for my quadcopter design:

Product Description Quantity Price


Turnigy Brushless Outrunner

2217 20turn 860kv 22A
4 $53.12
($13.28ea)


Turnigy ESC

Plush 30amp
4 $48.76
($12.19ea)


Turnigy LiPo

5000mAh 3S 25C Lipo
1 $27.43


XT60 Connectors

Male/Female (5 pairs)
1 $3.19


Turnigy Balancer/Charger

Accucel-6 50W 6A w/ accessories
1 $22.99


Pyramid Power Supply

PS12KX 10-amp 13.8-volt
1 $46.99


APCProp

12 x 3.8″ Slow Flyer
2 $7.90
($3.95ea)


APCProp

12 x 3.8″ Slow Flyer Pusher
2 $11.84
($5.92ea)


Spektrum DX5e

5 Channel 2.4 GHz DSM2 Transmitter
1 $59.99


Spektrum AR500

5 Channel 2.4 GHz DSM2 Receiver
1 $39.99


LPCXpresso LPC1768

ARM Cortex-M3 Development Board
1 $28.50


9 DOF Sensor Stick

3-Axis Gyro, Accelerometer, Magnetometer
1 $99.99


OR Gate

CMOS Quad 2-Input
1 $1.00


Buffer

CMOS Quad 2-Input
1 $1.00


Aluminum Tubing

6061 1/2″ x 1/2″ x 72″, 0.063″ Wall
1 $21.14


Aluminum Sheet

6061 12″ x 12″, 0.063″ Thick
1 $10.06


Coleman Wire

16 Gauge 100 Feet
1 $11.24


Bullet Connectors

3.5mm 3 Pairs
4 $19.80
($4.95ea)

The aim of this design is for an extremely aggressive quadcopter. My design goals are for the stabilization system to handle VERY abrupt changes in attitude and able to recover from any acrobatic mishap. I’ll be adding a mode for acrobatics where absolute angles are not used for stabilization. Instead, the stabilzer will hold to a rotational rate. If an acrobatic maneuver goes south, one switch flip will be able to bring the helicopter back to a stabile hover. The only remaining control not adjusted by the stabilizer is the throttle.

I’m sure that there will be additional items I will need but haven’t thought of. I will try to keep this list up to date for those of you using it for your own copter build.

EDIT: added 16-gauge wire and 3.5mm connectors

Initial Quadrotor Design

 

I have been researching a variety of multi-rotor helicopter setups for some time.  I’ve been trying to identify the strengths and weaknesses of each design type.  I have come up with an initial design for my quad-rotor helicopter.  In attempts to create a very aggressive aircraft, I have designed the propellers to be a close as possible, as large as possible, and the motors to have a high power to weight ratio.  All of my assumptions about quadcopter design are very spectulative since I haven’t ever built one before. 

My first matter of design is a powerful CPU.  My fly-by-wire T-Rex 600 project used 4 Arduinos and they left a sour taste in my mouth.  Arduinos are great for quick prototyping but anything with substance needs a better processor.  Besides, I’m a Computer Engineer so I can’t justify using someone else’s poorly designed microcontroller libraries.  My microcontroller of choice for this project is the LPC1768 ARM Cortex-M3 by NXP Semiconductors.  It is a powerhouse!  I’ve written most of the low-level hardware drivers and a few of the higher level routines, such as PID controllers and Collective Cyclic Throttle Mixing (CCTM).  The combination of the ARM’s Cortex-M3 core with NXP’s hardware peripherials makes this as amazingly powerful design.  ARM+NXP=Happiness!

For aircraft attitude measurement, I’m planning on using the 9DOF Sensor Stick from Sparkfun.  Version 2 is still under design so I’ll have to wait on that.  I’m going to implement 3 different types of sensor fusion algorithms and see which type works the best.  The 3 algorithms are:

  • Complimentary Filter
  • Direction Cosine Matrix
  • Extended Kalman Filter

In the animation above, the two circles representing the propellers show the two sizes I will test.  The inner circles are a 12×3.8″ APCprop and the outer circles are a 14×4.7″ APCprop.  I haven’t seen another helicopter use the 14″ props before so I’ll get the 12″ props working first.

This is an explanation of the animation per level:

Level One (bottom):

  • LiPo battery
  • Receiver

Level Two (between the two metal plates):

  • 4x Electronic Speed Controllers

Level Three (top):

  • CPU
  • 3-Axis of Gyroscopes, Accelerometers, and Magnemeters

Outer Arms:

  • 4x Motors
  • 4x Props

I know that having the props close together makes the attitude harder to stabilize.  On the other hand, having the props close together will (I hope) induce much more torque on the frame from the motors.  This will help me overcome the lame yaw response of most quadrotor helicopters.  I’m banking on the fact that my CPU will be running at 100 MHz and I’ll hopefully have the sensor fusion filters and PID controller running at 400+Hz.  This should allow me to precisely adjust each axis of stabilization.  For better discrete calculus computations (integration and differentation) I’ll try running the sensor fusion algorithms above 1kHz and only commanding the ESCs at their maximum speed (50Hz-400Hz).  This will make the computations more accurate because each time step will produce less error.