The Rocket Recovery System is the 3rd generation of flight controller I have developed in my own time as part of this hobby. However, it doesn't share many similarities with the previous flight controllers, hence the new name. By definition a system is a construct or collection of different elements that together produce results not obtainable by the elements alone. This new flight controller was actually physically easier to produce as it is made from two main components as opposed to the constituent electronic passive components placed on the PCB, individual soldered and routed.
The RRS contains an Arduino Nano and HMC5883L compass module. Both housed on the PCB using some 2.54mm female headers. The PCB tracks are scarce and with some work, one could use some Veroboard, but I had the PCB and it only took an evening. The Nano and HMC5883L can easily be removed and placed in a breadboard, or used in other applications. The main reason for using an Arduino Nano is the increased mathematical computing ability that is required to process the data from the HMC5883L. As equally important as this fact, is that the Arduino can also more easily deal with complex electronic interfaces such as i2c and SPI. The Nano brings many many benefits to the system and is a very small package. I am using a Chinese clone, but have bought some genuine Arduinos in the past, so please consider buying at least one genuine one to support the folks who've made this powerful technology accessible to all. The rise in low cost, very powerful MEMS sensors, enables vast amounts of very useful data to be sent very quickly to a microprocessor. The Nano cost £1.76 and the HMC5883L cost 99p.
The compass sensor itself completely changes the system operation- it is actually much simpler than the previous flight controller. This is what is needed when at the field. The less you need to think about, the less mistakes you can make. No need to worry about a time delay or launch trigger. The RRS deploys a parachute at apogee when the rocket tips over past a certain degree, which almost always happens at apogee.
How does it work?
The main change to this flight controller is the detection of when to deploy the parachute. The previous controllers detected launch and waited a certain amount of time until apogee, to deploy the parachute. However, I was keen to try and detect the apogee itself, then deploy the parachute. This negates the need for a delay, which can vary for flight conditions, rocket size and sometimes, the launch detection can be missed and the timer never actually starts counting down at all. To detect apogee, one could think of using a clever accelerometer algorithm which detects what stage of the launch the rocket is at, or maybe using an airspeed sensor. There are countless cool ideas for detecting apogee. Please see this link that gives a massive overview of recovering a rocket, produced by Air Command Rockets:
I decided upon using the earth magnetic field to detect when the rocket has tipped over. Provided the rocket is stable, this will be at apogee (if it is not, then deploying the parachute wouldn't be a bad idea as there is no predicting where it's going)! This decision was partially made for me, as I was already using the HMC5883L sensor module at school. in a different application. Plus I had seen others have success with various magnetic sensor add-ons to different flight controllers. Though, these magnetic sensors seemed to be geared towards Pyro rockets. Knowing that using the earths magnetic field to detect apogee was possible, I started some basic experimentation.
The removing of passive components from the PCB and replacing them with an Arduino leaves an elephant in the room- software. The Arduino runs a version of C known as 'Wiring', but has all the power of C. Despite programming not being my strength, I do enjoy it and saw it as a challenge. This project I knew, would be heavily reliant on programming for the operation. Plus this software wouldn't be a load of conditional statements like previous PICAXE programs. This C program would need to use libraries and functions to divide the software up into a logical and readable format. Luckily, because the Arduino is so popular nowadays, there are many folks online who have used this common module before and it didn't take long before I stumbled across libraries. Some good and some bad. Some with superb explanations and comments and others which one could tell, had been done by a perfect software engineer (i.e. know one else can understand what's going on in there code). After reading the datasheet for the HMC5883L chip itself, I settled on a library that could perform all tasks required for my specification. This included a nice calibration mode, which most libraries seemed to omit, but is vital as specified in the datasheet. The library I settled on was written by Omer Ikram ul Haq. I actually contacted him and thanked him for the code. He was also happy to talk through some of the parts I didn't understand with me, so thank you Omer. This code deals with the i2c interface that links the Arduino and HMC5883L. See the link to his GitHub:
But how does one use a magnetic field to detect when the rocket tips over? Well think of a bar magnet. The field lines run parallel to the sides of the bar magnet and then return into the ends. The earth can be thought of as a large bar magnet with field lines running from North to South. The HMC5338L can detect the strength of these field lines in three planes, x, y and z. So when x is aligned with these field lines running north to south, a maximum value is read. The units of this value are unimportant in my application, they just give strength. Therefore it can be recognised, that depending on the orientation of the sensor in the rocket (which MUST be consistent), I can use two of the axis to detect the strength of these field lines and perform some trigonometry using the atan2 function. The rocket cuts lines of flux when it rotates and plunges back to earth, this flux cutting is the key. This trigonometry is used to work out the angle of the rocket from vertical, once passed 90 degrees, behold the simple if statement.
The experimentation entailed using a Nano, the sensor module and this code. Basically, trial and error was used to see what values are produced, when the board is moved around...
The deploying of the parachute uses a servo motor in the same format as before..