Rocket Flight Computer

by Oralab in Circuits > Microcontrollers

323 Views, 2 Favorites, 0 Comments

Rocket Flight Computer

Teensy_port_16_9.png

Hey !

If you're here you've probably heard of model rockets. If not, those are small rockets powered by a black-powder motor. A few seconds after the end of the burn, the motor explodes a charge which deploys the parachute. The rocket falls slowly and can land safely.

But when you fly bigger rockets (high power rockets), you go higher, and opening only a big parachute at apogee is not a good idea : you'll probably be carried away by the wind during this long fall. What you want is to reduce the duration of the fall, but land at a slow speed. A way to do this is by deploying a small parachute (the drogue) at apogee, and a big parachute (the main) at a lower altitude. This way you rocket will be carried by the wind only in the (short) last part, and land slowly.

That's where flight computers (FC) come into play. You need a way to eject a parachute at a predefined altitude. I needed several features, so I'm going to show you how to build and code a flight computer which can do a lot ! From designing your FC to programming it, ranging from its manufacturing, you'll know everything !

Supplies

For this you'll need :

  1. the microcontroller : a Teensy 4.1
  2. some sensors : a barometer, an IMU (accelerometer and gyroscope), and a GPS
  3. a radio module for communication
  4. a motor driver for the reaction wheel
  5. a stepper driver for the parachute (you'll see later why)
  6. an led and a buzzer so the FC can show us if something is wrong (or right : )
  7. some voltage regulators to power everything from the battery
  8. some mosfets to trigger the explosive charges
  9. some passive components (resistors, capacitors)
  10. some connectors

You can find a precise bills of materials (BOM) attached. Of course you don't have to use every component here if you want to make something simpler, which I recommend to you if it's your first FC. You'll see many things in this tutorial, and you can choose to use only some.

Define Your Needs

7-Locking-Mechanism.gif
8 - Cansat bay Exploded.jpg
reaction_wheel.gif
Reaction wheel lookup.png
Water in zero-g - Camera View.png
Nosecone inside view.png
Rogallo.gif

You first need to know what you're FC should be able to do. It should at least be able to measure altitude, and fire a pyro. For now you only need to think about what you want to achieve, and not how you want to achieve it. In my case I wanted to :

  1. precisely measure position
  2. fire four pyro channels, and be able to detect continuity on them
  3. reliably log data
  4. receive telemetry via radio
  5. control a reaction wheel which stabilize the rocket in the roll axis
  6. control two servomotors
  7. control a stepper motor which will be able to steer a paraglider wing
  8. turn on cameras

And for future projects a way to add things, like more servomotors, sensors... I'll just clarify some of my requirements so you understand it a bit better.

  1. I'll need precise positioning for future projects. For me it means fusing data from multiple sensor with a Kálmán filter
  2. I have two events (drogue and main), but I want redundancy, that's why four channels are needed
  3. Data logging helps knowing the reason of a failure, but even in case of success it's helpful to improve !
  4. Telemetry helps to know if everything is okay, sending position when the rocket has landed and potentially start some events
  5. I wanted to learn a little more on PID control and I find this cool : ) In the video the blue thing is a prototype which worked well, but the rocket was to heavy for the reaction wheel to have any effect
  6. They open a door to eject a CanSat
  7. The main parachute of this rocket is a Rogallo made by a friend, a type of glider which can be steered (we only tested it with some weight and it worked really well)
  8. The rocket has three cameras : one shooting the horizon, one shooting the ground (and the parachutes during descent), and one shooting water in zero-g. They fill their SD card quickly and consume some power, so it's better to have a way to turn them on only when you need it. I also thought that I was going to have to start the recording with their buttons, that's why I put optocouplers which I've never used (they turn on and start recording when powered by usb)

Make Some Research on the Components You'll Use

IMG_2745.JPEG
IMG_2586.JPEG

Now you can start to browse for the best components in your case. Best doesn't mean the most precise or most powerful, because it can costs a lot (so be stressful to use), and not be well documented on the internet. Moreover you're probably not going to use it to its full potential, and you can already do some crazy things with the cheapest ones.

Like you can see in the BOM, I used the cheapest components available (even the DC motor I used for the reaction wheel comes from a old printer). There's only one for which I've broke the bank, and I do not regret it : the Teensy 4.1.

If you haven't heard about it, the Teensy 4.1 from PJRC is the Rolls Royce of microcontrollers. It has a base clock frequency of 600MHz (almost 40 times faster than an Arduino Uno), 55 GPIOs, an expandable memory (you can solder ram and flash chips on it) and a native SD card port. At the beginning I thought it was a bit overkill, but I ended up using almost all GPIOs, the integrated SD card port saved me a component, and the expandable memory simplified a bit my circuitry. If it wasn't on it I would have had to learn how to connect externally a flash chip, and program it with a library not specifically made for it.

Draw the Schematic

Capture d'écran 2024-10-15 020934.png
Capture d'écran 2024-10-15 020332.png
Capture d'écran 2024-10-15 020415.png

The next step is to draw the schematic of your FC. I recommend you to start with hand drawings, especially for the power part : you have to think about how you power a component or another (for example the sensors use 5V, the servomotors 7V, and the pyros 12V). The wiring is pretty standard, and it's very similar from one component to another.

But if you want a PCB you'll need more than a hand drawn schematic : you have to design it on your computer. For this I've chose Autodesk Fusion, which lets you design electronics circuits and use the 3D model of the PCB in your mechanical assembly. It's great to have everything in one place ! Moreover to design this FC one of the main ressource I used is the Landing Model Rocket - Series from BPS.space, and he's using Eagle, the software on which Fusion Electronics is based. (By the way I really recommend you to watch it, you'll learn many things !) But nothing's stopping you from using something else, like KiCad, which is really well documented and free to use.

In your PCB design your going to use components, which are objects mapping a symbol (the drawn item you use in your schematic) with a footprint (the physical shape the component will have on a PCB). You can also add a 3D model to your component if you want to check that nothing is intersecting and make some renders (most of the simple components already have it). Then you're going to connect each component with power and the microcontroller, using virtual wires. This video from BPS.space explains pretty well the basics, and if you want a short explanation of the software you can use this video. You can also use the schematic I provide on this GitHub repository and delete things you don't want, or add some ; it's better than starting from nothing.

Route Your PCB

Capture d'écran 2024-10-14 102200.png
avionics_turntable.gif

Now that you have your complete schematic, you can start designing the real PCB. You have to place the footprint of your components on the board, so you first need to draw your board. You can make a circle if you mount it horizontally, like the FC from Lafayette Systems, but I needed to put it vertically because of all the components I have. For this you have to know that the manufacturers often have some special offers on the first board you order, only if the size is below 100mm*100mm. At the same time it also has to fit you airframe, in my case the maximum width I could use was 75mm. So I had to fit every components in 75*100mm, which was a bit tricky but not impossible.

I recommend you to first place the connectors you need (screw terminals at the top and the bottom for me), and the microcontroller in the middle. You can then place the components for which you don't have much choice. For example, the mosfets must be near the pyro terminals, and it's better to put the voltage regulators near the battery connectors. The passive components that are connected to those should also be near (to minimize the routes length), so let some room for them. You then place the rest of the components around the microcontroller. In general you'll want to put small components like resistors at the end. Be aware that you'll always be able to move components afterwards, so try things and see if they work. When you're finished, you can start routing.

The routing is not complicated, but can be quite long. You have to make the links between all the pins of your components (just like you would do with wires on a breadboard). You need to consider that higher power needs wider traces. For signal traces, 0.25mm is fine, for low power (sensors, stepper motor driver), 0.5mm, and for high power ones (battery, pyro channels), 2mm is good. About pyro channels, you'll see that 2mm may not be enough depending on your use (more in the testing step).

At the end if you're using Fusion you can click "push to 3D PCB" and you'll have a nice model of your FC !

Again for more details I recommend you the video of BPS.space on the subject.

Order It Online

Capture d'écran 2024-10-14 103501.png
IMG_2139.JPEG

You can export your file using the "Export Gerber..." button, and you'll obtain a zip file (you can find mine on the GitHub repository). Upload it on your favorite PCB manufacturer website (I know that PCBWay and JLCPCB have special offers for your first PCB and I was satisfied with the quality). You may leave the defaults settings that are fine, and hit the order button !

Solder Your Board

IMG_2169.JPEG
ROXA_soldering_iron.JPEG
IMG_2586.JPEG

As soon as you've received your boards you'll want to solder one right away ! Here are a few tips :

  1. Think of the order in which you're going to solder the components. In general you'll start with the smallest and end with the biggest but if you do weird things like me where some components block others you'll have to get creative ; ) Here's the order I've came up for my FC :
  2. Resistors (except those below the mosfets), capacitors
  3. Headers and stepper connector
  4. Led and buzzer
  5. Mosfets, regulators and optocouplers if you use them
  6. Screw terminals
  7. Motor driver and stepper driver's female headers (you can use the driver to help you with placement)
  8. GPS headers (without the GPS), Teensy's female header's
  9. GPS and RF module
  10. It's a bit tricky to solder the flash chip on the Teensy 4.1, you can use this video
  11. If you're not going to use a component right away, like the GPS for example, you can solder it later (it will consume less power and avoid some issues)

Program It !

ROXA_code.png

I won't go in the details of the programming but I'm going to give you the code I currently have (on the GitHub repository). It's not complete (it mainly lacks telemetry and a more reliable data logging) but it's sufficient to fly a rocket. Even with my poor programming skills I think the general structure is good enough to use the FC with all the components, and you can build onto this code. I'm actively working on this project so I'll update the code in the repository soon. I'm using the PlatformIO extension on VSCode to program the FC, which I like a lot : )

If you want to make something simpler I do not advise you to start with this. A simple sketch on the Arduino IDE will be easier to understand at the beginning and enough to fire a pyro by detecting decrease in altitude.

In any case I suggest you to make separate programs to test each component, and then merge everything.

If you want to learn more on advanced FC programming I highly recommend you the video of Lafayette Systems (the entire video is very interesting and the programming part starts at 10:14).

Test It Before Launch

Doors opened.png
IMG_2742.JPEG
IMG_2743.JPEG

I suggest you to do the "elevator test" to see if your FC is acting as expected. Get into an elevator on the lowest floor, turn on the computer and start ascending. When you get to the top, go down to the lowest floor and check that the on-board computer is lighting the pyros, and possibly other events if you have so. I used the RGB Led to show the different states of the flight computer, but I also recommend you to plug Leds (with resistors) on the pyro channels to see if they're really sending current. When you're sure it works you can do a test in the rocket with black powder (not in the elevator but somewhere there aren't any risk to hurt someone).

That's also the moment you're going to see if things don't work. In my case I'm cutting zip ties with nichrome wires for the main chute deployment, and the first time I've tested it a resistor burned, while it did not with the pyros. I think that's because the resistance of the nichrome wires is lower than the pyros ones', resulting in more current flowing in the limiting resistor. The small ones I used weren't able to handle it and they burned. The simplest solution I found was to bypass the limiting resistors (I don't really recommend you to do that, it can be dangerous for the batteries if you heat the wire for more than a few seconds). To avoid the high current to flow directly through the board, I ran some external wires to the mosfets and terminals (in parallel of those on the board). It's not pretty but it works, and you'll probably won't need to do this.

Another (small) mistake was that I wired the 5V of the board to the USB 5V pin on the Teensy, instead of the Vin, so the Teensy wasn't powered from the batteries. I added a wire to correct that, and it's now fixed on the files in the repo.

Launch !

launch_slowmo.gif
All rocket.png
1 - All_CanSat_Highligh.JPG
Camera side view.png

This flight computer flew only one time, and it performed exactly as it should so I was very happy : ) Unfortunately the bag containing the Rogallo (the main), was tangled up with some lines and did not release correctly. The rocket was only slowed by the drogue and hit the ground at a moderate speed (it ripped off some exterior pieces, but wasn't enough to break the flight computer). At that time I had not yet implemented the flash chip data logging, and without surprise the vibrations of the flight made the logging on the SD card impossible. It's really important to gather data so I'll improve on this point !

Overall I'm really happy about this project, I've learn a lot and want to continue improving it. I really want to thank the makers of all around the globe who taught me many things through internet and always piqued my interest, especially Joe Barnard from BPS.space and Lafayette Systems for this project. Happy making and experimenting !