Arduino Powered Rocket Guidance System

This is my first Instructable so bear with me.

This is an Arduino Powered Rocket Guidance System. I submitted this for the Google Global Science Fair. My science project is at https://sites.google.com/site/arduinorocket/ . It took me three months to design and build the rocket. I could launch the rocket because the rocket was too heavy and I could find enough power to run the servos. 

What you will need:
Arduino (Uno or Mega, your choice)
a lot of Jumper wires (like a box of 100 from sparkfun.com )
Memsic 2125 Dual-Axis Accelerometer  (you can use whatever sensor you want, i just liked this one)
9v to Barrel Jack Adapter  (you can also use, http://www.sparkfun.com/products/10512 )
Solderless Breadboard
Servos  (these are pretty expensive, here are some smaller and cheaper ones: http://www.hobbypartz.com/topromisesg9.html )

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Build the Rocket

The rocket is easy to build once you get the hang of it. The way that I built the rocket is on my blog/website:  http://therocketgeek.wordpress.com/my-rockets/phoenix-1/. The building of the rocket isn't that hard, its takes a lot of glue and patience. 

Step 2: Servos

The idea was to attach the fins of the rocket to servos. When the accelometer senses that there is movement it tells the Arduino to move certain servos which moves the fins and changes the rocket't trajectory. I originally had only four servos to work the entire rocket. the problem is that the rocket can only move in four axes; this is problem when the rocket moves between axes. To solve this problem I offset another set of fins 45 degrees. This uses eight servos. I bought Common Sense R/C servos from Amazon.com for about $50. 

The offset is done by drawing a circle the same diameter as the body tube you made. You then draw a pair of perpendicular bisecting lines at the center of the circle. You then, using a Geometry compass, bisect all four of the angles. You then draw all of the angle bisectors until the line extends outside of the circle. Then line up the first four fins on the bottom of the rocket. Then transfer the lines of the bisectors to the body tube until it is clearly above the lower fins. 

Step 3: Servo Plates(disks)

Cut out four disks the same diameter of the body tube. Draw perpendicular bisectors in the center of the disk. Then line up the middle of the servo with the lines. Make sure that just the part that connects to the servo horn sicks outside of the disk. cut a slit to accommodate for the servo brackets. Once servos are lined up and fit in slits, use an Exacto knife to cut smaller slits for zip ties (also known as cable ties). I had to connect two ties together to make a bigger tie. Wrap tie around the servo and the plate and connect the last two ends of the tie until the servo is secure to the disk. Clip off the ends to clean up a bit.

Repeat this process until all servos are secured to the disks. There should be four servos on two disks.

Then cut slits on the two other cardboard disks for zip ties. secure these to the servos as well.

On only one of the servo disks cut four holes in the shape of standard sized Estes Rocket motors (A-C). Roll four note cards in the shape of the rocket engines. Then insert and glue these to the servo plates.

Step 4: Fitting Together

Cut squares on the disks. Pull servo wires out through squares and pull them into the body tube. I straightened paperclips and cut them into sections to fit into the servo plug and onto the breadboard. I connected all of the servos to the breadboard and then connected all of the power lines to the + and - rails on the board. Be sure to know what wire does what! If you don't this won't work. Black means Ground or Gnd. Red or Orange means 5v or whatever your servo requires to move. White or whatever the color is of the last wire is the line in that tells the servo how far to move. The line in wires need to go to the PWM pins on the Arduino. I used 0-7 PWM pins on the Arduino. Then I connected five 9v batteries in series, then taped them together to make a battery pack. Connect the positive end of the battery pack to the + rail on the board. Then connect the negative end of the pack to the - rail on the board as well. The Arduino runs off of a 9v batter connected via the barrel jack on the Arduino board. 

Step 5: Sensor

Connect the accelerometer's input wires to two PWM pins. Be sure to read the code to find what pins the accelerometer sends info to. The accelerometer's Gnd and 5v can be run off of the Arduino board itself. After everything is connected, stuff everything into the body tube and put the nose cone on. Then attach the fins to the servos. Upload the code and make sure it works. 

Like I said before, this rocket was too heavy and I had electrical problems from the battery pack. Don't used aluminum foil on the batteries for the battery back, the foil gets hot and can catch fire. I would use paper clips or something that can conduct electricity really well. 

Step 6: Code

This code might not work, feel free to change it and let me know how you changed it. This is the public's domain.

/*
This scketch is based upon the Memsic 2125 accelerometer read code from http://www.arduino.cc/en/Tutorial/Memsic2125
and the RCServoMotorsControlledWithAccelMeter2
   based on the ITP's sample code
   http://itp.nyu.edu/physcomp/Labs/Servo
These sketches have been modified and reworked by Chris Barta.
therocketgeek.wordpress.com

  This example code is in the public domain.
*/
#include <Servo.h>

Servo myservo;

const int xPin = 11; // X output of the accelerometer
const int yPin = 12; // Y output of the accelerometer

long lastPulse = 0; // Time in milliseconds of the last pulse
int refreshTime = 10; // Time needed in between pulses

int minSensorValue[xPin] = {-180, -180}; // the least value the accelerometer can read
int maxSensorValue[yPin] = {180, 180}; // the greatest value the accelerometer can read
int pulseWidth[xPin][yPin] = { 0, 0 }; // Pulse width for the servo motors

int sensorRange[xPin][yPin] = { maxSensorValue[0] - minSensorValue[0],
                               maxSensorValue[1] - minSensorValue[1] };
int i = 0;

int phase = 0; // variable to select the servo motor to drive

void setup()
{
myservo.attach(1, 45, 135); // define what pin the servos are on
myservo.attach(2, 45, 135); // the minimum angle
myservo.attach(3, 45, 135); // that can be rotated
myservo.attach(4, 45, 135); // and the maximum angle
myservo.attach(5, 45, 135); // that can be rotated
myservo.attach(6, 45, 135);
myservo.attach(7, 45, 135);
myservo.attach(8, 45, 135);
myservo.write(90); // set servo to mid-point (90 degrees)

pinMode(xPin, INPUT); // set x value from accelerometer as an input
pinMode(yPin, INPUT); // set y value from accelerometer as an input
}

void loop()
{
// variables to read the pulse widths:
int pulseX, pulseY;
// variables to contain the resulting accelerations
int accelerationX, accelerationY;

// read pulse from x- and y-axes:
pulseX = pulseIn(xPin,HIGH);
pulseY = pulseIn(yPin,HIGH);

// convert the pulse width into acceleration
// accelerationX and accelerationY are in milli-g's:
// earth's gravity is 1000 milli-g's, or 1g.
accelerationX = ((pulseX / 10) - 500) * 8;
accelerationY = ((pulseY / 10) - 500) * 8;

// pulse the servo again if the refresh time (20ms) have passed:
if (millis() - lastPulse >= refreshTime) {

if (accelerationX < 0) // if the rocket moves off the X-axis then
{
myservo.attach(1); // the two servos 1,3 will move to oppose the movement
myservo.write(135); //the direction of servo 1
myservo.attach(3); // the two servos are facing each other
myservo.write(45); // so they have to move "opposite" directions

} else if (accelerationX > 0); // if the rocket goes in
(accelerationY > 0); // the x,y direction
{
myservo.attach(5); // then the servos in the uppersection
myservo.write(135); // (5,7) sill counteract the motion in that direction
myservo.attach(7);
myservo.write(45);
}

}else if (accelerationX = 0); //if there is no movement then
(accelerationY = 0); // keep the servos aligned with the rocket
{
myservo.attach(5);
myservo.write(90);
myservo.attach(7);
myservo.write(90);
}

{
if (accelerationX > 0) // same thing only in the other direction
{
myservo.attach(1);
myservo.write(45);
myservo.attach(3);
myservo.write(135);

}else if (accelerationX < 0);
(accelerationY < 0);
{
myservo.attach(5);
myservo.write(45);
myservo.attach(7);
myservo.write(135);

if (accelerationX = 0);
(accelerationY = 0);
{
myservo.attach(5);
myservo.write(90);
myservo.attach(7);
myservo.write(90);
}
}


if (accelerationX = 0); //if there is no movement
{
myservo.attach(1); // then keep the servos aligned with the rocket
myservo.write(90);
myservo.attach(3);
myservo.write(90);
}
}
if (accelerationY < 0)
{
myservo.attach(2);
myservo.write(45);
myservo.attach(4);
myservo.write(135);

}else if (accelerationX > 0);
(accelerationY < 0);
{
myservo.attach(6);
myservo.write(135);
myservo.attach(8);
myservo.write(45);
}
{
if (accelerationX = 0);
(accelerationY = 0);
{
myservo.attach(6);
myservo.write(90);
myservo.attach(8);
myservo.write(90);
}
}

{
if (accelerationY > 0)
{
myservo.attach(2);
myservo.write(135);
myservo.attach(4);
myservo.write(45);

}else if (accelerationX < 0);
(accelerationY > 0);
{
myservo.attach(6);
myservo.write(45);
myservo.attach(135);
myservo.write(135);
}
{
if (accelerationX = 0);
(accelerationY = 0);
{
myservo.attach(6);
myservo.write(90);
myservo.attach(8);
myservo.write(90);
}
}
}
if (accelerationY = 0);
{
myservo.attach(2);
myservo.write(90);
myservo.attach(4);
myservo.write(90);
}
{
delay(100); // this is to delay repeat time so the servos can catch up
}
}



Also, you can go to https://sites.google.com/site/arduinorocket/products-experiment . It is pretty much the same thing except there are indentations. 

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    16 Discussions

    0
    None
    edmundajw

    5 months ago

    I know this is really old now, but I read some detail on the Google project page that confused the hell out of me to start with, before I realised the error. So I'm posting for the benefit of anyone else that reads this. I'm not sure the author will have any interest, it was that long ago.

    The issue is here;

    'The rocket weighed 1.2 pounds. For scientific calculations, I needed to convert pounds to kilograms.
    1.2 x 0.45359237 = 0.544310 N.
    That is the force that gravity is acting on the rocket. I need to find the mass in order to do any calculations. Using Newton's 2nd law: F=ma (Force=mass x acceleration) I can calculate how much mass the rocket has.
    F=ma
    Force(Gravity's force) = Mass x Acceleration(9.8 m/s^2)
    0.544310 N = Mass x 9.8 m/s^2
    Arrange the equations so I find the mass:
    Mass = 0.544310 N / 9.8m/s^2
    Mass = 0.05554183673 kg'

    While the maths is technically correct, you have made a big error in assuming the 'weight' you read from the scale is in fact weight, and therefore force, and needs to be converted to Mass.
    Weight is a force, and is measured in Newtons. It's equal to mass in kg times acceleration, as above.
    The 'weight' you got from your measuring scales was pounds, which as you rightly said can be converted to kg. This is a mass, not a force in Newtons.
    The issue here is that while you're right to assume that the measuring scales are only capable of measuring force (aka weight), they are in fact DISPLAYING to you mass. This is because the scales have been made and calibrated to assume a gravitational acceleration value of 9.81, and therefore they are calibrated to display at a 1:9.81 ratio. This is to say that the scales have already done this calculation of weight in Newtons to Mass in KG for you.
    So when you assume that this value is force, and divide by 9.81, you're coming up with a mass value almost a factor of 10 out.

    'The rocket weighed 1.2 pounds. For scientific calculations, I needed to convert pounds to kilograms.
    1.2 x 0.45359237 = 0.544310 N.'

    It is incorrect to say the rocket weighed 1.2 pounds. Admittedly, this is more of a problem with our language. In actuality your weighing scales told you that the rocket has a mass of 1.2 pounds. It has a mass of 0.54kg. The force its mass exerts due to gravity is (0.54 * 9.81) Newtons.

    Hopefully this will help someone out. I fully admit it can be very confusing, and the above mistake is very easy and logical to make. I have a degree in Aerospace Engineering, and this boggled my mind for a minute... I'm only slightly ashamed to admit...

    0
    None
    Rocket Guy

    1 year ago

    I am doing this project and have some questions

    1. Can I use a 3 axis accelerometer? If yes could you suggest some wiring

    2. Are 4 servos ok

    3. Will the code still work If I edited it for 4 servos

    4. Is the code ok for the accelerometer or do I have to edit it

    Waiting for the reply. School Science Fair approaching

    0
    None
    Ahan1224

    5 years ago on Introduction

    Im doing a very similar project like this except the rocket is bigger and so is the motor for my project im using Either a Cti I170 or an I-1287

    and im doing it on a Madcow Super Dx3 4.0 inch Payloader

    and I don't know a thing about code or Arduinos what should I do

    Also would you recommend screwing the fins and epoxying them to the servos so they don't rip off due to excessive force? some of the motors I want to use can take the thing close to 700 mph or over Mach 1 would there be a way to do minor adjustments to the course instead of a super fast turn?

    I figure I could just launch it at a Nar launch if I launch it from the away pad I only want to prevent the rocket from going into an insane roll and keep it going straight up

    1 reply
    0
    None
    KimJongSpoonAhan1224

    Reply 3 years ago

    If you want your rocket to go straight up, just tilt the fins 2 or 3 degrees, or sand them with asymmetric aerofoils. No need for all this arduino shenanigans. These servos don't have the minute control authority to turn the rocket slightly, especially over mach 1.

    0
    None
    KimJongSpoon

    3 years ago

    I would have done things a little bit differently. I would have used plywood for the centering rings as opposed to cardboard. The cardboard will either a. rip under the strain of the launch, or ignite when the ejection charge goes off. Speaking of ejection charge, it is generally considered bad practice and even illegal in some areas and launch sites to launch without a recovery system. 4 servos would be enough here, and the ones you have are massively overkill. as far as electronics go, you don't need the breadboard at all, and you could use a much smaller arduino to control the servos. I would have secured the motors with CA glue as opposed to zip ties, and the electronics would go higher. Remember, for a rocket to be passively stable it's center of aerodynamic pressure needs to be at least on caliber (diameter of the sustainer's body tube) lower than the center of mass. The center of mass is right about at the back of this rocket, so it probably won't be passively stable. This means that as the nose deviates from the velocity vector, it will tend to increase deviation as opposed to correct it. Even the arduino would have trouble correcting for this with the fins. Also, keep in mind that model rockets are supposed to have thrust-weight ratios of at least 4:1 or else they won't come off of the rod/rail/tower cleanly. With a rocket of this weight, you would have to be flying it on something like an H or I-class motor, which are illegal to own if you don't have your L1, Jr L1, or are planning on using it for your qualifying flight. Whatever body tube material that you are using probably isn't strong enough to contain the 300 Newton seconds of force that the motor would put on the rocket. The electronics all piled up against one side would make sure that the CoM isn't in line with the thrust vector, and not mounting them means that when the rocket launches, they will shift around, changing the CoM in flight, something which generally causes Catastrophic Failures.

    0
    None
    TeamStorm

    4 years ago

    8 servos is overkill. As is the mega. The control movements need to be very small and the forces on the fins will rip them right off.
    an arduino pro mini would be good for this.

    0
    None
    JosephH2

    5 years ago on Step 2

    Four control fins should be plenty to achieve full yaw, pitch, and roll authority. You could do it with three, even, which is important considering the weight of those servos you're mounting...

    sorry, no. i had too many problems occur. the batteries were getting hot, i didn't want to risk anything on my equipment so i don't actually know if this works. i was hoping that the public can help out and give guidance.

    5 replies
    0
    None

    check the system for shorts, try ultralight servos, try a lithium battery, and use multiple rocket engines, I've worked with model rockets for a long time and heavy payload systems that ive built typically use 4-6 rockets.

    0
    None

    i would need to make a bigger rocket and smaller servos. but i never shot it off because that is about $200 worth of equipment and i don't want to loose that.

    Then why did you make a instructable about it if you don't know if it works?

    Besides model rocketry is all about taking risks. You make a big risk, it works out you get great and valid data. You don't you still get valid data. Besides if everyone is afraid of losing their rockets. But if everyone let that control them no one would ever launch anything!

    sure but i don't know how good a high school student can be.
    get and Arduino Uno, its cheaper and smaller
    get smaller servos than what i have, less weight and easier to work with
    find a better power source, look at other Instructables or have the other people who commented help you.
    All of the other parts are lightweight. you can probably find a cheaper Accelerometer from Sparkfun or something.

    let me know if you need anymore help, just remember that i have only 2 years of experience and i am a full time student