![]() |
Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
|
This is the documentation on the Flight Software (FSW) that runs on the Teensy microcontroller in the Artemis CubeSat's On-Board Computer (OBC) board. This page is designed to give a high-level understanding of the FSW and introduce essential computing concepts that the FSW uses.
This code runs on the Teensy 4.1 microcontroller. As the link shows, this is a very capable microcontroller. If you are familiar with Arduino, the Teensy is very similar. You can think of the Teensy as a souped-up Arduino, with more ports and processing power.
There are many ways to program a Teensy. This project uses the PlatformIO IDE within Visual Studio Code. This allows us to use a more powerful IDE than Arduino IDE (which is still great for prototyping!). Make sure you follow the instructions in the Development Environment Setup Guide in order to program the Teensy.
This section will give an overview of the FSW, how it works, and its functional components.
The Teensy, as mentioned earlier, is essentially a powerful Arduino. The FSW is built on the Arduino's programming principles. That is, there is a setup()
function that is called once, followed by a loop()
function that runs in an infinite loop, forever. These links are to the functions in the main.cpp file, and are the starting point for the code. In essence, this is the top-level Arduino code, the same as any other Arduino sketch.
It could be possible to put all our code into this one file, but this would be a massive file that would be hard to read and maintain. In addition, we want to be able to separate the code based on what components of the CubeSat it effects.
As a result, we split up the codebase and execution using multithreading. Each thread (we call them channels in our implementation) is responsible for some component of the CubeSat, such as the radios, sensors, or PDU. A brief description of each channel is given below.
As the descriptions show, each channel runs independently, sharing information in the form of PacketComm packets inserted into each others' queues. At a high level, the Teensy flips through these channels quickly, executing a little bit of each channel before moving on to the next channel. The code must therefore be written with the assumption that it may be interrupted at any time. Further information is given in the multithreading section.
This section describes the PlatformIO build flags and their uses.
We can take advantage of the build flags feature of PlatformIO to selectively compile the code for testing and debugging. The build flags are found in the platformio.ini file in the root directory of the code. They are listed on individual lines, like so:
build_flags = DEBUG_PRINT
The ;
symbol comments out a flag, disabling it.
These flags are used to run test code, generating test data to see how the program handles incoming data.
Flag Name | Function |
---|---|
TESTS | Enable to run tests on the satellite. |
If you've used Arduino before, you might be familiar with the Serial.print()
style of debugging. We use the same method of debugging in this project for simplicity. When enabled, the Teensy will print debug statements over the Serial connection established over USB to the Terminal in VSCode.
Multiple flags are available for use, depending on what statements you'd like to print.
Flag Name | Function |
---|---|
DEBUG_PRINT | Enable to print debug messages to the Terminal. |
DEBUG_PRINT_RAPID | Enable to print messages that will are generated |
rapidly, such as polling requests. | |
DEBUG_PRINT_HEXDUMP | Enable to print hexdumps to the serial console. |
DEBUG_MEMORY | Enable to print memory capacity messages to the serial |
console. |