Using an Arduino to Trigger Staging in Two Stage Model Rocket

Hey everyone, I'm completely new to the world of Arduino and programming, but am familiar with model rocketry.
I want this project to be an intro to programming through something I'm already familiar with (model rockets).

I'll be editing this post as I go to include some of the great ideas members are contributing

The Project

Basically, I will launch the rocket from the ground normally (without using the Arduino), at which point a countdown will begin. Once the countdown is up Edit: (An accelerometer will instead be used to detect burnout of the first stage). When the accelerometer detects sustained deceleration, the second stage will be ignited in midair by the Arduino, and the first stage will fall away as the second stage shoots onward.

I need the Arduino to be able to detect the launch, so I am looking at accelerometers. However, I will need to make sure that the threshold for detecting launch is not so low that the countdown begins if I accidentally bump the rocket while it's on the launch pad.

As for the actual ignition process, I will be using a model rocket electric igniter with a firing current of 120mA. It has been brought to my attention that the Arduino can't supply this much current, so I will be using either a transistor or relay to provide the current necessary to ignite the second stage.

Also, when the Arduino detects a "launch", I want an LED on the exterior of the rocket to visibly illuminate (in case anyone is near the rocket when the countdown begins).
EDIT: The Arduino will check for sustained acceleration. This way bumps while prepping the rocket on the launch pad will not be detected as a "launch".

The Rocket

I have already designed the rocket in OpenRocket... pictures!

Also, if anyone is interested in how the stages are separated, I'd be happy to explain (just didn't want to clog this up even more than I already have)

EDIT: Here is the updated version

The first stage is a C11-7 (since "Plugged" C and D engines are discontinued). I will cut two exhaust holes (for the ejection charge) in the booster stage and cover the ejection side of the engine with some wadding since I do not require an ejection charge in the first stage (the booster stage is very light and can tumble safely back to the ground).

Here's the file for anyone interested. (You will need to download OpenRocket to view this)

EDIT: Here's the updated one: Google Drive: Sign-in

Programming

As I previously mentioned, I am completely new to coding/programming. From what I've read, you program the Arduino and its connected accessories with the Arduino IDE, which I already downloaded on my Windows laptop. I also read that the IDE language is C++, and have begun learning the basics from BuckysRoom Tutorials. Am I going about this the right way?

Edit: Just ordered a copy of Accelerated C++ and will be learning from this book instead.

Here's my understanding of what I need to do: Pick up an Arduino (probably an Uno r3)(more like a Pro Micro or Mini so I can fit it in the nosecone), a compatible LED, and an accelerometer (ADXL335) compatible with Arduino. Then connect the accelerometer and LED to the Uno, hook it up to my laptop, and begin programming with the IDE. Oh and the power supply is a 9V battery. Is this correct?

Also, is "connecting" an accelerometer to the Arduino as easy as plugging in a few things? Or will I need to solder?

Sorry for the lengthy read, but I appreciate you taking the time to do so. Any feedback is welcome. Thanks!

You DO understand that you have to test your arduino using a FAKE LAUNCH right ?
You can put it inside a carboard tube and put eye screws on it and pull it up a string or something to simulate a launch and connect a piezo buzzer so the buzzer goes off instead of the second stage.

Absolutely! I'm not just going to program the thing and throw it in the rocket. Good idea for testing...I'll use a similar method with the LED I'll already be purchasing.

easterbran:
Basically, I will launch the rocket from the ground normally (without using the Arduino), at which point a countdown will begin. Once the countdown is up, the second stage will be ignited in midair by the Arduino, and the first stage will fall away as the second stage shoots onward.

A countdown to second stage ignition is pretty iffy. You will have a fairly short window in which it is safe to ignite the second stage. You don't want to ignite it too early, for two reasons. The first is that if the first stage is still firing, the separation will cause the first stage to become extremely unstable under power. Too late, and the rocket could be nosing over. Since you are going to be using an accelerometer, you would probably be bettter off firing it at first stage burnout, which will be detectable by the accelerometer.

I need the Arduino to be able to detect the launch, so I am looking at accelerometers. However, I will need to make sure that the threshold for detecting launch is not so low that the countdown begins if I accidentally bump the rocket while it's on the launch pad.

Detecting the launch with the accelerometer is a good idea. You can prevent the detection of bumps by checking the accelerometer over a period of a few seconds, say 1/4 to 1/2 of your typical first-stage boost phase. If you bump the rocket, and detect something that looks like a launch, checking it every few hundred milliseconds for a few seconds will confirm a launch, or reset the possible_Launch variable.

Also, when the Arduino detects a "launch", I want an LED on the exterior of the rocket to visibly illuminate (in case anyone is near the rocket when the countdown begins).

You probably want the LED (or AN LED) to come on when the Arduino is "armed", before the launch. Turning on an LED when it detects a launch is a little too late for anyone standing near the rocket.

As I previously mentioned, I am completely new to this. From what I've read, you program the Arduino and its connected accessories with the Arduino IDE, which I already downloaded on my Windows laptop. I also read that the IDE language is C++, and have begun learning the basics from BuckysRoom Tutorials. Am I going about this the right way?

Yes

Here's my understanding of what I need to do: Pick up an Arduino (probably an Uno r3), a compatible LED, and an accelerometer compatible with Arduino. Then connect the accelerometer and LED to the Uno, hook it up to my laptop, and begin programming with the IDE. Oh and the power supply is a 9V battery. Is this correct?

Also, is "connecting" an accelerometer to the Arduino as easy as plugging in a few things? Or will I need to solder?

A 9V battery will probably do the trick, as long as it isn't too heavy, and as long as you can place it such that it balacnes properly. It won't last a whole lot of flights, though.

Well, connecting an accelerometer can be done in a number of ways, but just "plugging it in" is the worst way for a circuit that will be riding a rocket with a pretty high acceleration, so soldering is definitely the best way to go.

So your program will look something like this...

Am I accelerating?
Am I still acceleratiing after a few seconds?
OK.. I'm on the way.
Have I stopped accelerating?
Check again for a few hundred milliseconds
Still coasting?
Ignite second stage

For testing, you can mount the unit on the end of a stick, and swing it around. The accelerometer axis that's parallel to the stick will show acceleration. stopping the swinging will show no acceleration on that same axis. Use some indication you can see or hear to show the different points in the process.

If you give it a ride in a single-stage rocket, and log acceleration readings to EEPROM, you can get a good idea of what you need to look for in each stage.

Above all, be VERY careful. Test fully.

Then you can think about adding parachute deployment via the program.

Great information, lar3ry!

The "checking" concept is something I'll definitely utilize.

I agree with your input about using a timer to ignite the second stage and will be throwing out the "timer" idea, so I will be using the accelerometer to detect both Launch and Burnout of the first stage.

I do have a smaller rocket hanging out on my desk...I may have to send up the Arduino in that first to get an idea for the acceleration values like you mentioned.

Thanks!

What are the voltage and current requirements of the ignighter ?

rogerClark:
What are the voltage and current requirements of the ignighter ?

These guys: http://www.ehobbies.com/qus7025.html#PRtab

I'm not sure of the voltage requirements, though everyone uses 9V batteries to ignite them.

120mA is the firing current.

I didn't even consider whether the Arduino can supply this...I'm guessing that's why you asked?

easterbran:

rogerClark:
What are the voltage and current requirements of the ignighter ?

These guys: http://www.ehobbies.com/qus7025.html#PRtab

I'm not sure of the voltage requirements, though everyone uses 9V batteries to ignite them.

120mA is the firing current.

I didn't even consider whether the Arduino can supply this...I'm guessing that's why you asked?

Yes. Youll need to provide for that amount of current. You can use a low-cost transistor to fire it.

Arduino can only supply 40mA at 5V. I suspected it would take a lot more than that :wink:

You're going to need to use some sort of amplification or a relay
http://www.ebay.com.au/itm/IRF520-MOS-FET-Driver-Module-for-Arduino-New-/201098847189?pt=AU_B_I_Electrical_Test_Equipment&hash=item2ed26ce3d5

or

Or any transistor that will sink 120Ma will probably do.

A few more things to consider.

You probably want to keep the weight and size as small as possible. I'd use one of the mini Arduino clones e.g.
http://www.ebay.com.au/itm/Replace-ATmega328-Arduino-Pro-Mini-NEW-Arduino-Pro-Micro-ATmega32U4-5V-16MHz-/291132518559?pt=AU_B_I_Electrical_Test_Equipment&hash=item43c8d9b09f

Or

(but if you use a mini, you need a separate RS232 interface http://www.ebay.com/itm/USB-to-TTL-RS232-Arduino-Pro-Mini-Download-PL2303-Replace-FT232RL-CP2302-Serial-/171229503155?pt=LH_DefaultDomain_0&hash=item27de12deb3
as the board doesn't have those chips on it

To determine what acceleration to trigger the 2nd stage, I think you'd need to test fire just the first stage + dummy 2nd stage and log the acceleration

You can log to mini SD card using something like this

After you know the range and profile of the acceleration curve it will be easier to set the thresholds

Safety..

Put a real switch between in series with the Igniter, so that if the arduino triggers when on the ground it won't fire the 2nd stage
So one of the last preflight things you do is turn this switch on !

Re: Soldering
If there are high G loads or vibration etc, connectors work loose, so either glue them or learn to solder (its not hard :wink:

I am learning many new words today... :stuck_out_tongue_closed_eyes:

I will definitely implement the switch on the igniter.

A few questions:

-I read somewhere that relays are unreliable in model rockets because of the high G loads...or is this only for a specific type of relay?

I think you're right about using the Mini...that way I can cram it all into the nose cone.
-What is the purpose of the RS232 interface that you mentioned?

-Ideally, wouldn't the second stage be ignited as soon as the first stage burns out?
Meaning that as soon as acceleration switches directions (+ to -) on the vertical axis (and stays that way, so it's not just igniting every time the rocket passes through rough air), that's when I would want to ignite the second stage? Or can the accelerometer not detect that change in direction along a single axis? If my thinking is correct, then would I even need to do a trial run to collect acceleration data? Or could I just tell it "When you see the accel. change directions, ignite the second stage."?

Oh, and I can solder big stuff, just never tried with something as small as these. :slight_smile:

Is it possible to use a pressure sensor?

knut_ny:
Is it possible to use a pressure sensor?

How would a pressure sensor be used? As an alternative to the accelerometer? Do you mean a barometric pressure sensor for altitude?

It should be possible to estimate the height where you want to trigger 2nd stage.
A pressure sensor can tell height with better than 5m precition.

I believe you know burntime for 1st stage, estimated height and velocity at this point in flight.
Then i'd guess you will allow a little additional time for free climb, before firing stage 2.

Hi, just found this thread, I agree with raschemmel about some lab based tests.

Another idea, fit a buzzer to go off when the launch is detected, that way everybody will notice that the second stage timer has been triggered, an LED in the middle of nowhere in outside sunlight will not be very luminous.

The suggestion by knut_ny, the barometer is a good idea, you could log altitude.
Also it could be used to help the second stage timer.

  1. it could be used to start the timer, ie over 100ft the timer starts. (This way you don't have shock due to handling causing a problem.)
    or
  2. the stage separation device will not be activated unless its over say 100feet.

I have seen a lot of remote operations fail because someone forgets to turn some function on in the vehicle before it races or flies or dives away.

Have a lanyard type activate switch on the outside of rocket, it would be in place to keep things turned off, remove it to turn on.
That way if just before firing you see the lanyard still hanging from the rocket, it won't lead to an embarasing flight.

Tom..... :slight_smile:

Re rs232 to USB

Most mini Arduino boards don't have the USB interface so you can't program them without the USB to rs232 adaptor

I.e the Microcontroller chip the Atmega328 is programmed via rs232 , for in the Arduino world.
The Atmega comes pre installed with a tiny code loader program, which listens on rs232 after its powered on, and this allows the PC to program it.
The alternative would be to use a SPI based programmer, but this isn't normally necessary.

So if you want the lightest board, go for one like an Arduino mini, or possibly even a lillipad
If using an external USB adaptor is too much hassle, go for a Pro micro or a Nano

Actually Nanos are quite nice as they are small but still have the USB interface and also a voltage regulator, so you can feed them with 12v etc if you want

Hi, or use a nano, small with port fitted.

Tom.... :slight_smile:

rogerClark:
Most mini Arduino boards don't have the USB interface so you can't program them without the USB to rs232 adaptor

So if you want the lightest board, go for one like an Arduino mini, or possibly even a lillipad
If using an external USB adaptor is too much hassle, go for a Pro micro or a Nano

Actually Nanos are quite nice as they are small but still have the USB interface and also a voltage regulator, so you can feed them with 12v etc if you want

My choice would be the Pro Micro, They are like a Leonardo in operation, but are about the smallest in size and weight of all the Arduinos. They do have the USB Serial (micro USB Connector).

G force at take off is likely to be rather high. better get a few spare accelerometers. Too much G load will fracture the inards of one.

the accelerometer (eg like ADXL335) will survive! I'v seen every "Cansat" contain one, and they always live to tell their story.
Cansat rockets (see http://www.rocketrange.no) has engines that burn for approx. 3 secs. speed 550 km/h.
They climb to 950..1000m depending on cargo (0.3 .. 0.8 kg)

TomGeorge:
Hi, just found this thread, I agree with raschemmel about some lab based tests.

Another idea, fit a buzzer to go off when the launch is detected, that way everybody will notice that the second stage timer has been triggered, an LED in the middle of nowhere in outside sunlight will not be very luminous.

The suggestion by knut_ny, the barometer is a good idea, you could log altitude.
Also it could be used to help the second stage timer.

  1. it could be used to start the timer, ie over 100ft the timer starts. (This way you don't have shock due to handling causing a problem.)
    or
  2. the stage separation device will not be activated unless its over say 100feet.

I have seen a lot of remote operations fail because someone forgets to turn some function on in the vehicle before it races or flies or dives away.

Have a lanyard type activate switch on the outside of rocket, it would be in place to keep things turned off, remove it to turn on.
That way if just before firing you see the lanyard still hanging from the rocket, it won't lead to an embarasing flight.

Tom..... :slight_smile:

The buzzer is a great idea! Though I am going to use the accelerometer solely to detect launch and when to ignite the second stage. As another poster mentioned, the timing would have to be perfect in order to make sure that the rocket remains stable when igniting the second stage. Maybe in the future I'll implement a pressure sensor and use the measured altitude in conjunction with the accelerometer, but for now I'm going to keep it simple.