Posts Tagged ‘ helicopter ’

I’m going to be rich!!!

In the fall of 2010, while completing my bachelor’s senior project, I accidentally designed a helicopter that flies without its rotors moving!  I’m going to make billions!

Advertisements

Proportional-Integral-Derivative (PID) Controller

PID Intro:

The heart of any real control system has a feedback controller.  When the system’s process is unknown or hard to model, a Proportional-Integral-Derivative (PID) controller is an efficient method for control.  If the system’s process is known, a custom controller will yield higher efficiency.  However, modeling complex systems in attempt to design a custom controller may result in a much higher development time and cost than can be afforded.  In both cases, a PID controller is a very efficient method for controlling all types of systems.

thanks to wikipedia.org for the diagram

PID Theory:

PID controllers can be understood(partially) without an in depth lecture on control theory. PID controllers use 3 sub-controllers combined into 1 controller using a simple sum. The 3 controllers are:

  • Proportional:
    The proportional section of a PID controller is a basic intuitive approach to feedback control. A naive approach to feedback control would say, the farther away from perfect the system is, the more it should work to get perfect. In a perfect world without friction, momentum, etc., this system alone would work great! This is proportional control. However, our world is imperfect and we need to add smarter feedback compensation.
  • Integral:
    The integral section of a PID controller compensates environment imperfections such as friction, wind, and other such imperfections that would resist the system to reach its perfect state. An integral controller works by keeping a sum of all the error the system has seen. In calculus, this is equivalent to the area underneath the curve up to the current point. The controller increases its control signal as the summed error gets larger.
  • Derivative:
    The derivative section of a PID controller compensates environment imperfections such as momentum which causes the system to overshoot its perfect state. The derivative controller lessens its control signal as the speed in which it is achieving its perfect state increases. In calculus, this is the slope of the error signal.

Example:

Let’s consider an example to show how a PID controller could be used. Our example will be an airborne GPS navigation system in a helicopter. The aircraft knows where it is and where it is being told to be. Using basic subtraction, it can figure out the distance to the desired location. This is the error signal. It indicates how far from perfect it is.

Lets say that the PID controller is controlling the forward thrust of the helicopter and that the direction is automatically set by something else (in other words, the helicopter always points the direction it should).

The proportional controller would just set the thrust according to the distance away from the target location. This is a simple approach but most likely will not work by itself. As the helicopter gains momentum, it will become harder to slow down. Using proportional control only, the helicopter will overshoot its target and possibly oscillate around the target location. Another issue is wind. The thrust controller should compensate for wind because a tail wind could cause an positional overshoot and a head wind might cause it to never get there.

The integral controller continues to sum the error it incurs and adjusts appropriately. In the head wind example, the thrust would increase until the aircraft could reach its target destination.

The derivative controller measures the speed in which the error signal is changing, which for the helicopter is simply the relative ground velocity. As the helicopter approaches its destination the derivative controller reduces the thrust allowing the helicopter not to overshoot its target position. In the event of tail wind, it reduces the thurst even more so that it can’t be pushed past the target.

For the helicopter example, all 3 sub-controllers must be used. To use all of them, you just sum the control signals of all 3.

Implementation:

If you think this sounds hard to implement, you are wrong. PID controllers were designed to be generic and easily adapted to all systems. As mentioned before, PID controllers have 3 sub-controllers. Each controller has a parameter that must be tuned, called ‘gain’. To add a PID controller to a system, you just need to attach the generic PID controller and tune the 3 values.

The following C code is an efficient PID controller.

typedef struct {
    double windup_guard;
    double proportional_gain;
    double integral_gain;
    double derivative_gain;
    double prev_error;
    double int_error;
    double control;
} PID;

void pid_zeroize(PID* pid) {
    // set prev and integrated error to zero
    pid->prev_error = 0;
    pid->int_error = 0;
}

void pid_update(PID* pid, double curr_error, double dt) {
    double diff;
    double p_term;
    double i_term;
    double d_term;

    // integration with windup guarding
    pid->int_error += (curr_error * dt);
    if (pid->int_error < -(pid->windup_guard))
        pid->int_error = -(pid->windup_guard);
    else if (pid->int_error > pid->windup_guard)
        pid->int_error = pid->windup_guard;

    // differentiation
    diff = ((curr_error - pid->prev_error) / dt);

    // scaling
    p_term = (pid->proportional_gain * curr_error);
    i_term = (pid->integral_gain     * pid->int_error);
    d_term = (pid->derivative_gain   * diff);

    // summation of terms
    pid->control = p_term + i_term + d_term;

    // save current error as previous error for next iteration
    pid->prev_error = curr_error;
}

Windup Guard:

As you may have noticed, the code has a feature called windup guard. This is a critical feature that must be used in most control systems. Windup guarding is simply just setting a cap on the maximum value that the integrated error can be. This is typically most needed for startup conditions and situations for switching in and out of control. Let’s look at our helicopter example again. Consider the situation where the helicopter can be piloted by a person or the PID autonomous controller. If the human operator had a target destination only a few feet away from the current position but held the helicopter still, the integral portion of the PID controller would continue to sum the error seen. Eventually this error would grow very large. If the pilot then switched to autonomous mode, the controller’s output thrust signal would be huge, most likely causing a wreck. There are two solutions to this problem. The first is using a cap for the maximum absolute value of the integrated value. This is the windup guard. Another solution would be to call the pid_zeroize function each time the GPS target is set and each time the autonomous control system is enabled. In either case, setting a safe maximum value using a windup guard is good practice.

Optimization:

This code can be optimized if the pid_update function is called at the exact same rate every time. In this case, all references to ‘dt’ can be removed. This will change the optimal values for the integral and derivative gains but once tuned, will respond the same way. In this code, this optimization only removes one multiplication operation and one division operation.
It is possible to change this code to run on fixed-point arithmetic rather than floating-point. This dramatically increases the efficiency but system limits and precision may be compromised. Only use fixed-point if you are sure that you are using enough precision.

EDIT: fixed bug on line 31. changed multiply to divide.

Quadcopter Frame Design

My first quadrotor frame design is simple, sturdy, reliable, and a bit ugly.  I have made no attempt to make it cute, flashy, or visually desirable in any way.  If and when I determine that the structural design performs well, I’ll use some better tools to make a more flashy design.  Until then, I’ll be flying on my raw cut aluminum frame.

My basic design is two 24 inch(610 mm) X 1/2 inch(13 mm) X 1/2 inch(13 mm) square aluminum arms.  I knotched both in the center so that they can cross each other.  There are two 5 1/4 inch(133 mm) alumimum plates holding everything strong and square.  The frame is very strong, rigid, and relatively low weight.

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.

Starting a quad-rotor helicopter project

Past:
I recently graduated from the University of Utah in Computer Engineering. My senior project was a fly-by-wire system for an unmanned helicopter. We used an Align T-Rex 600 ESP helicopter for the project. Designing a stabilization system for this size of helicopter presents many problems. Given that the tips of the blades travel at 350 mph, physical danger was obviously the biggest concern. We successfully implemented our design.

Even though we felt moderate success, we didn’t feel that our system performed as well as it could have. All the supporting hardware and software was implemented but the time needed to calibrate the many features of stabilization caused us to end the project before all features could be utilized. The excessive calibration time is a result of calibrating a 53 inch helicopter during flight. Any changes in the system had to be modified very slowly.

This project gave me a lot of experience with inertial measurement and feedback control. It also gave me a HUGE desire to make something better!

Future:
Now I begin a multi-rotor helicopter project. I aim to fix all the faults in the previous design while overcoming many of the short comings of current multi-rotor designs. I will start by designing a 4 rotor system because it is the cheapest. Once I master the quadcopter, I’ll try a hexacopter or an octocopter. I have been impressed by many multicopter designs. Some are:

  • HexaKopter by MikroKopter
    This design shows a lot of intelligent software engineering. The GPS capabilities of this system are phenomenal. The supporting stabilization system is also very intelligent (see the oscillating coke bottle).
  • GRASP Labs Quadrotor
    Having the entire room and obstacles marked with position sensors is kind of cheating for autonomous vehicles, but I must admit that these helicopters are amazing! Recovering from severe initial conditions is very impressive.

My goals are to:

  • overcome the inheritly slow yaw response of current quad-rotor designs.
  • design an extremely aggressive stabilization system.
  • find a good balance between size and payload capability.
  • make the chassis rigid enough to survive moderately severe crashes.
  • create a quadcopter that is ridiculously fun to drive!

My initial design will be very minimal. I will start off with only a basic quad-rotor design controlled by a transmitter/receiver pair. No other communication will be used. I’m designing this to be minimal so that I can focus on the inertial measurements and feedback control. Once these are mastered, I’ll add fluffy features like:

  • software ground station
  • GPS hold and navigation
  • video downlink