Note

The linked repository is a cleaned-up reference rewrite of the architecture we flew, not the exact flight code.

The Constraints of an Atmospheric Descent

The annual international CanSat competition challenges university engineering teams to pack an entire operational satellite payload into the dimensions of a beverage can. Our mission: launch to 700 meters aboard a rocket, separate at apogee, stabilize descent with heat shields and parachutes, and transmit live pressure, altitude, temperature, and GPS coordinates back to the ground station at 1 Hz.

Unlike desktop software where a crash can be caught with an exception handler and restarted, an embedded flight controller operates with hard physical consequences. If a sensor read blocks for 1,200 milliseconds, an entire transmission cycle is dropped. If voltage dips during motor actuation and the microcontroller resets without state persistence, the flight is lost.

Selecting the Brain: Teensy 4.1 & TeensyThreads

We standardized on the Teensy 4.1 (ARM Cortex-M7 running at 600 MHz). Its high clock speed and rich hardware serial buses allowed us to run multiple hardware peripherals—an Adafruit BMP3XX precision barometric altimeter, an IMU accelerometer/gyroscope, a TinyGPSPlus serial receiver, and an XBee/RF telemetry transmitter—simultaneously.

To keep timing deterministic, we structured the architecture around dedicated thread loops using the TeensyThreads library rather than putting everything inside a monolithic loop():

Simplified representation of the concurrent sensor polling and telemetry broadcast threads.cpp
// Flight software thread orchestration overview
#include <TeensyThreads.h>
#include <Adafruit_BMP3XX.h>
#include <TinyGPSPlus.h>

Adafruit_BMP3XX bmp;
TinyGPSPlus gps;
volatile TelemetryPacket currentPacket;
volatile FlightState currentState = IDLE_ON_PAD;

void sensorThread() {
  while (true) {
    if (bmp.performReading()) {
      currentPacket.altitude = bmp.readAltitude(SEALEVELPRESSURE_HPA);
      currentPacket.temperature = bmp.temperature;
      currentPacket.pressure = bmp.pressure / 100.0F;
    }
    updateFlightStateMachine(currentPacket.altitude);
    threads.sleep(50); // Sample sensor at 20 Hz
  }
}

void telemetryRadioThread() {
  while (true) {
    formatCSVTelemetry(currentPacket);
    transmitXBeeRadio();
    threads.sleep(1000); // 1 Hz broadcast constraint
  }
}

Telemetry Serialization & Noise Immunity

Competition rules strictly dictate telemetry formats, checksums, and timing. Every second, a telemetry string with timestamp, packet count, altitude, pressure, GPS coordinates, and state flags must be beamed down.

During initial field tests, we observed that string concats in Arduino C++ caused heap fragmentation over long operational windows. We eliminated dynamic heap allocation entirely, switching to fixed-width character buffers and snprintf formatting. This reduced memory volatility to zero and preserved microcontroller headroom.

Hardware Lesson

Never use dynamic String objects on embedded flight controllers. Pre-allocated char arrays prevent silent heap starvation when running continuous multi-hour test sessions.

Virginia Results & What It Taught Me

In Virginia, USA, Team UIU ASCEND secured 7th place globally, 2nd in Asia, and 1st in Bangladesh among 34 international finalist teams.

Beyond the score, the competition solidified how I write software: systems engineering is about identifying single points of failure before physical launch, testing under realistic vibration and environmental conditions, and documenting exact operational boundaries. It also inspired me to step into teaching, instructing high school and university students at the SIC Bangladesh aerospace workshop the following year.