Astro club BITS Pilani's flight computer code
- Make individual .cpp and .h files for each sensor and task
- Include them in main and finalize the logic
- Debugging and testing
- Finalize the logic and implement it in Python
- Debugging and testing
- Write out the cases and conditions of what happens when
- Write the possible states and cases for transition between states & draw diagram of state machine
- Write test code for individual components (i.e. taking readings from GPS, BMP390, IMU, communication with E32, Raspi, triggering relay, triggering buzzer, testing ejection charges)
- Test the code
- Back to step 3 until code works
- Implement the state machine using state tables with placeholder function blocks for individual components
- Integrate the test code for individual components from step 3 to implement the placeholder functions
- Test the code with everything
Use a flight state variable and a switch case in loop to run the correct functions for each flight regime
ex:
enum State = {BOOT, READY, FLIGHT, DESCENT, LANDING, FAILURE}
State flightstate = BOOT
void loop(){
switch BOOT:
switch READY:
.....
}
Use a state variable(integer) to get and set states of individual sensors
#define RPI (1 << 0)
#define GPS (1 << 1)
#define LORA (1 << 2)
#define BMP (1 << 3)
#define IMU (1 << 4)
int sensorStatus = 0 // This is a global variable
// To manipulate and check statuses
sensorStatus |= RPI // Set status to true
sensorStatus &= ~LORA // Set status to false
sensorStatus ^= BMP // Toggle status
(sensorStatus & IMU) != 0 // Get if a status is true
- GPS Readings (getCoordinates, check alive)
- BMP390 reading (getAltitude, check alive)
- IMU reading (getRollPitchYaw,getAcceleration, check alive, checkIsTipOver)
- E32 communication and check (sendBytes function, check alive)
- Raspi communication (sendBytes, readBytes, check alive)
- Continuity Check (checkContinuity main, drogue, backup)
- Trigger Ejection Charges (trigger main, drogue, backup)
- Trigger Ejection Charges (from Raspi) (trigger main, drogue, backup)
- BMP390 readings (from Raspi) (getAltitude)
- Arduino communication (from Raspi) (readBytes, sendBytes)
- packTelemetryDataE32() // function combines all data (which is decided to be sent) into a byte array
- packLogsForRaspi() // combines all data into byte array
- storeDataFromArduinoToSDCardRaspi() // unpacks data and stores on sd card
- storeCameraFootagetoSDCardRaspi()
Individual components test code will be written in Arduino IDE as .ino
State machine and onwards will be written in PlatformIO in VSCode
Raspi code will be written in Python
- Install PlatformIO extentions on arduino
- Restart VSCode
- Click on its symbol -> pick symbol , open the arduino folder
- click on build symbol