Skip to content

hsfl/aeris-via-software

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AERIS / VIA Software

Brief Overview

This is the code repository for the VIA (Variability In Atmosphere) Payload firmware for the AERIS mission. VIA is one of three scientific payloads creating the first-ever trimodal, temporally-linked dataset examining upper atmospheric composition (NOx, O3) before, during, and after solar particle events.

AERIS Payload Architecture:

  • VIA (spectrometer) - Takes snapshots, triggers GPIO to coordinate other payloads
  • SEEs (particle detector) - Continuous recording, Β±2.5s window on VIA trigger
  • AMPPs (plasma detector) - Continuous recording, Β±2.5s window on VIA trigger

Temporal Linking (The Key):

VIA controls timing. When VIA captures a spectrum, it pulses GPIO β†’ SEEs and AMPPs capture synchronized Β±2.5s windows β†’ All three datasets bundled with VIA's timestamp β†’ OBC packages for downlink.

Why This Matters: SEEs and AMPPs don't track absolute time - they only count "1 second, 1 second, 1 second." The Β±2.5s buffer captures what happened BEFORE the VIA trigger (pre-event conditions), DURING (the event itself), and AFTER (post-event response). This creates temporally-linked trimodal measurements before, during, and after solar particle events.

VIA payload uses an Avantes AvaSpec-Mini2048CL spectrometer connected to Teensy 4.1 microcontroller acting as a USB host.

The firmware handles:

  • USB communication with the AvaSpec spectrometer using the USBHost_t36 library by Paul Stoffregen
  • Measurement data collection (4096 bytes / 2048 pixels)
  • SD card logging for data backup
  • Command console interface via USB Serial
  • GPIO trigger output (future) to synchronize SEEs and AMPPs payloads

System Architecture

Full Radio Link Architecture

            SATELLITE                                    GROUND STATION
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                     β”‚       β”‚                                     β”‚
β”‚  [VIA Spectrometer]                 β”‚       β”‚                                     β”‚
β”‚         ^                           β”‚       β”‚                                     β”‚
β”‚         β”‚                           β”‚       β”‚                                     β”‚
β”‚        USB (cmd+data)               β”‚       β”‚                                     β”‚
β”‚         β”‚                           β”‚       β”‚                                     β”‚
β”‚         v                           |       |                                     |
β”‚     [Teensy 4.1]───SPI1───>[RFM23]~~|~radio~|~~>[RFM23]───>[Receiver Teensy]      β”‚
β”‚         ^                           β”‚       β”‚                      β”‚              β”‚
β”‚         β”‚                           β”‚       β”‚                      β”‚              β”‚
β”‚      microUSB (cmd+data)            β”‚       β”‚                     USB             β”‚
β”‚         β”‚                           β”‚       β”‚                      β”‚              β”‚
β”‚         v                           |       |                      |              |
β”‚     [Pi Zero]                       β”‚       β”‚                      v              β”‚
β”‚         ^                           β”‚       β”‚                   [Computer]        β”‚
β”‚         β”‚                           β”‚       β”‚                      β”‚              β”‚
β”‚        SSH                          β”‚       β”‚              via_ground_station.py  β”‚
β”‚         β”‚                           β”‚       β”‚                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
  [Control Computer]
          β”‚
   via_interactive.py

Satellite Side:

  • Control computer SSH's into Pi Zero
  • via_interactive.py sends commands to Teensy
  • Teensy 4.1 runs VIA firmware (spectrometer + radio)
  • Commands: send triggers measurement β†’ radio transmission
  • Data saved locally to ~/Aeris/data/via/

Ground Station Side:

  • Receiver Teensy runs radio_receive_test.ino (from Artemis kit)
  • via_ground_station.py captures serial output and saves files
  • Data saved to ~/Aeris/data/via/ (same structure as satellite)

Radio Protocol:

  • Header: VIA:4106: (payload type and size)
  • Data: 60-byte chunks (RFM23 FIFO limit)
  • Footer: :END
  • Frequency: 433 MHz, GFSK modulation at 2kbps

Local Architecture (No Radio)

AvaSpec Spectrometer (USB)
         ↓
Teensy 4.1 (VIA Payload)
    β”œβ”€ SD Card (local logging)
    β”œβ”€ USB Serial (command console)
    └─ SPI1 β†’ RFM23 Radio (optional)

Current Version: V4.0 - Integrated Radio Transmission

Key Libraries

Library Purpose
USBHost_t36 Paul Stoffregen's USB Host library for Teensy - enables direct USB communication with the AvaSpec spectrometer
SdFat High-performance SD card library for data logging
pyserial Python serial communication for the interactive console
pty Unix pseudo-terminal for virtual serial port simulation

Quick Start

πŸ‘‰ See QUICKSTART.md for complete workflow

On the Pi 400

ssh aeris@192.168.120.22
aeris

That's it! The AERIS console handles everything - pick from the menu:

  • 1 - VIA Unit Tests
  • 2 - VIA Simulation (no hardware needed)
  • 3 - VIA HIL Test (real Teensy)

Or use CLI shortcuts:

aeris via test      # Run unit tests
aeris via sim       # Run simulation
aeris via sim -v    # Simulation with verbose output

AERIS Control Panel

Local Development

# Build and upload firmware
cd AvaSpecDriver
pio run --target upload

# Run console
./VIA.sh

AvaSpec Software Build Instructions

  1. Download and install VSCode & GitHub Desktop.
  1. Install both the C/C++ and PlatformIO extension in VSCode.
  1. Clone the repository from GitHub Desktop by clicking "Add" at the top left, "Clone Repository...", "URL," copying the link below into the prompt, and then clicking Clone.
  1. Go to VSCode and initialize the PlatformIO extension.
  2. In the "QUICK ACCESS" column, click on "Open" and then "Open Project" in the tab that opens. Locate and choose the "AvaSpecDriver" folder within the "aeris-via-software" folder.
  • This should have opened the AvaSpecDriver folder as a PlatformIO project with all the dependencies and configurations it needs.
  1. From the explorer column on the left, navigate the AvaSpecDriver folder to "src", then to "main.cpp".
  2. On the bottom left are multiple buttons; click the checkmark to build the code, confirming a successful build when [SUCCESS] appears on the terminal that pops up.
  • That finishes building the software.

To get relevant data, continue to "Getting Data" section.

Getting Data with Teensy 4.1

Hardware Connections

  1. AvaSpec Spectrometer: Connect to Teensy 4.1 via USB host port (spliced cable)
  2. SD Card: Insert into Teensy 4.1 built-in SD card slot
  3. USB Serial: Connect micro-USB to computer for command console
  4. Power: Provide 5V power to Teensy 4.1

USB Host Wiring

The AvaSpec USB cable is spliced and connected to Teensy USB Host pads:

  • πŸŸ₯ Red (5V) β†’ Teensy 5V Host Pad
  • 🟩 Green (D+) β†’ Teensy D+ Host Pad
  • ⬜ White (D–) β†’ Teensy D– Host Pad
  • ⬛ Black (GND) β†’ Teensy GND Host Pad

D+/D– twisted pair maintained for signal integrity.

Data Flow

The firmware provides an interactive command console:

  1. User sends commands via USB Serial (e.g., measure, auto 60)
  2. System collects full spectrum measurement (2048 pixels)
  3. Data logged to SD card in two formats:
    • Raw hex dump: /meas_XXXX.txt (~12,355 bytes)
    • CSV format: /spectrum_XXXX.csv (Pixel,Intensity)
  4. CSV data also output via USB Serial for live capture

Data Output Formats

  • Binary: 4,106 bytes (10-byte header + 4,096 bytes pixel data)
  • ASCII hex: ~12,355 bytes on SD card (/meas_XXXX.txt)
  • CSV: Pixel,Intensity format on SD card (/spectrum_XXXX.csv) and USB Serial
  • Future optimization: Raw binary transmission (67% size reduction)

Example Pixel Spectrum

Firmware Modules

Core Modules

  • main.cpp: Command console and measurement sequencing
  • AvaSpec.h/.cpp: USB Host driver for AvaSpec spectrometer (commands 0x05, 0x06, 0x0F, 0x13, 0xC0)
  • Logger.h/.cpp: SD card logging utility for measurements and telemetry
  • OBCBridge.h/.cpp: Optional UART bridge module (future use)

Hardware Configuration

  • USB Host: AvaSpec spectrometer connection (spliced cable)
  • Serial (USB): Command console and debug output at 115200 baud
  • Serial1 (UART): Optional OBC bridge at 115200 baud (TX=1, RX=0)
  • SD Card: Built-in Teensy 4.1 SD interface (BUILTIN_SDCARD)

Testing

Automated Test Suite

The tests/ directory contains a complete test suite for development without hardware:

  • test_data_generator.py: Generates realistic spectrum data
  • test_python_scripts.py: 10+ unit tests for data processing
  • virtual_serial_port.py: Simulates Teensy firmware for interactive testing
  • run_all_tests.sh: Automated test runner

Run all tests:

cd tests
./run_all_tests.sh

See tests/README.md for details.

Test Libraries & Dependencies

The test suite uses Python standard library only (no external dependencies required):

Library Purpose
unittest Test framework and assertions
csv Reading/writing spectrum CSV files
struct Binary data packing/unpacking
pty + os Virtual serial port creation (Linux/Mac)
threading Concurrent virtual serial port handling
subprocess Running test scripts
pathlib Cross-platform file path handling
datetime Timestamped session folders

No pip install required - works on any system with Python 3.6+.

Test Without Hardware

Simulate the full system locally:

aeris via sim       # Runs virtual serial port + console automatically

Or manually:

cd tests && python3 virtual_serial_port.py &
./VIA.sh /tmp/ttyVIA0

Simulation vs HIL Architecture

The simulation and hardware-in-loop (HIL) tests use the same interactive console - only the data source differs:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  scripts/via_interactive.py                         β”‚
β”‚         (parses serial data, progress bars, saves files)            β”‚
β”‚                                                                     β”‚
β”‚  Detects: "Starting Measurement", "CSV DATA OUTPUT:", etc.          β”‚
β”‚  Saves:   ~/Aeris/data/via/YYYYMMDD.HHMM/*.csv                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                             β”‚
              β–Ό                             β–Ό
       /tmp/ttyVIA0                  /dev/ttyACM0
       (virtual port)                (real Teensy)
              β”‚                             β”‚
              β–Ό                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ tests/                  β”‚   β”‚ AvaSpecDriver/src/                  β”‚
β”‚  virtual_serial_port.py β”‚   β”‚  main.cpp      (command console)    β”‚
β”‚  test_data_generator.py β”‚   β”‚  AvaSpec.cpp   (USB host + output)  β”‚
β”‚                         β”‚   β”‚  AvaSpec.h     (protocol constants) β”‚
β”‚ Generates:              β”‚   β”‚                                     β”‚
β”‚  - Gaussian peaks       β”‚   β”‚ Reads from:                         β”‚
β”‚  - Fake hex data        β”‚   β”‚  - Real AvaSpec spectrometer        β”‚
β”‚  - Simulated responses  β”‚   β”‚  - 4106 bytes per measurement       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                             β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                   SAME OUTPUT FORMAT
                   β”œβ”€ VIA> prompt
                   β”œβ”€ "Starting Measurement #N"
                   β”œβ”€ Hex dump (257 lines, 16 bytes each)
                   β”œβ”€ "CSV DATA OUTPUT:" + 2048 rows
                   └─ "Measurement Complete!"

Key insight: If it works in simulation, it will work on real hardware.

Pi 400 Remote Testing

A dedicated Raspberry Pi 400 serves as the remote testing machine for both VIA and SEEs payloads.

Connect and Run

ssh aeris@192.168.120.22
aeris

The AERIS console provides:

  • 0) Dual Console - VIA+SEES side-by-side in tmux
  • 1) Unit Tests - Automated Python test suite
  • 2) Simulation - Virtual serial port with fake data
  • 3) HIL Test - Real Teensy hardware
  • 7) Update Code - Pull latest from git
  • 8) Data Viewer - Browse and plot captured data
  • 9) HIL Deploy - Flash firmware and run hardware tests

HIL Deploy Menu

HIL Deploy Menu

CLI Shortcuts

aeris via test      # Run unit tests
aeris via sim       # Run simulation
aeris via sim -v    # Verbose mode
aeris update        # Pull latest code
aeris help          # Show all commands

Remote Access

Method Command
SSH (same network) ssh aeris@192.168.120.22
Tailscale (remote) ssh aeris@<tailscale-ip>

Unit Tests

VIA Unit Tests

Simulation Mode

VIA Simulation

Measurement Data

VIA Data Output

Dual Console Mode (VIA + SEES)

The AERIS Control Panel includes a Dual Console Mode that runs VIA and SEES side-by-side in tmux, enabling synchronized captures for temporally-linked bimodal data.

Dual Console Mode

Tmux Keyboard Shortcuts

Shortcut Action
Ctrl-a m Synchronized capture - sends measure to VIA and snap to SEES
Ctrl-a o SEES on (start buffering)
Ctrl-a f SEES off (stop buffering)
Ctrl-a n Switch to next pane
Ctrl-a q Quit and return to menu

Tmux Controls

Temporally-Linked Data Capture

When you press Ctrl-a m, both payloads capture simultaneously:

  • VIA: Takes a full spectrum measurement (2048 pixels)
  • SEES: Saves a Β±2.5s snap window (captures pre-event and post-event particle data)

Both files are timestamped identically, creating correlated datasets:

Temporally Linked Data

Data Viewer

The AERIS console includes a built-in data viewer (option 9) for browsing and plotting captured data files.

Data Viewer

VIA Spectrum View

View individual VIA measurements with CSV preview and ASCII spectrum plot:

VIA Data Viewer

Correlated Data View

View temporally-linked VIA+SEES pairs together, showing both the spectrum and particle data from the same capture moment:

Correlated Data

Getting Data with AvaSoft

Screenshot 2025-11-05 193505

Development Roadmap

Version History

  • V1.0: βœ… Standalone testing - USB to spectrometer, SD card logging
  • V2.0: βœ… UART bridge to OBC (deprecated in V3.0)
  • V3.0: βœ… Command console mode - Interactive control, dual CSV output
  • V4.0: πŸ”„ Full system (AERIS iOBC) - Merge into AERIS FSW, EPS/ADCS integration

Critical Path

  • Create Initial Driver
  • Validate Teensy and Spectrometer USB Ports can connect
  • Attempt Identification Command & Response to validate communication
  • Attempt Measurement Commands and read the "Unsolicitated" data messages
  • Read all 10 + 4096 bytes of data from a full measurement
  • Graph data by sending to computer Serial Port and graphing through MATLAB
  • Write data into SD Card storage
  • Implement command console interface (V3.0)
  • Dual CSV output (Serial + SD)
  • Python data capture utilities
  • Optimize for binary data transmission (67% size reduction)
  • Define Payload-to-Bus Software ICD fields for packetized CSV transmission
  • Add command handlers for remote "Start/Stop/Config" through spacecraft command bus
  • Integrate RPI connection code on Artemis OBC side
  • Interface into flat-sat testing environment
  • Full integration with Artemis spacecraft bus software

Repository

GitHub: https://github.com/hsfl/aeris-via-software

License: MIT (see LICENSE file)


Pi 400 Setup Scripts & Commands Reference

Three setup scripts in ~/Desktop/Work/Aeris/ configure the Pi 400 testing machine:

1. pi400_setup.sh β€” Initial System Setup

Installs system packages, Python environment, PlatformIO, and creates helper scripts.

Installed Packages:

  • git, curl, wget, vim, htop, screen, tmux, tree, build-essential
  • python3, python3-pip, python3-venv, python3-dev
  • pyserial, matplotlib, numpy, scipy, pandas
  • platformio, gh (GitHub CLI)

Shell Aliases (added to ~/.bashrc):

Alias Description
aeris cd ~/Aeris
via cd ~/Aeris/aeris-via-software
sees cd ~/Aeris/aeris-sees-software
via-test Run VIA unit tests
via-console Launch VIA interactive console
via-build Download VIA firmware from GitHub
via-flash Flash VIA firmware to Teensy
sees-test Run SEES unit tests
sees-console Launch SEES interactive console
sees-build Download SEES firmware from GitHub
sees-flash Flash SEES firmware to Teensy
aeris-status Show system status (Python, PlatformIO, USB, repos)
ports List serial ports (/dev/ttyACM*, /dev/ttyUSB*)
usb List connected USB devices (Teensy, FTDI, CP210, CH340)

2. setup_aeris_console.sh β€” Install aeris.up Command

Installs the aeris.up command to ~/.local/bin/ for launching the AERIS Control Panel.

Usage:

aeris.up              # Interactive menu
aeris.up via sim      # VIA simulation
aeris.up via test     # VIA unit tests
aeris.up via          # VIA hardware console
aeris.up sees sim     # SEES simulation
aeris.up sees test    # SEES unit tests
aeris.up sees         # SEES hardware console
aeris.up update       # Pull latest code from git
aeris.up help         # Show all commands

Options:

  • -v or --verbose β€” Enable verbose mode (show all output)

Interactive Menu Options:

Key Action
0 Dual Console (VIA+SEES in tmux)
1 VIA Unit Tests
2 VIA Simulation
3 VIA HIL Test
4 SEES Unit Tests
5 SEES Simulation
6 SEES HIL Test
7 Update Code (git pull)
8 Data Viewer
9 HIL Deploy (flash firmware)
E Exit

3. clone_repos.sh β€” Repository Setup

Clones/updates the AERIS repositories and downloads firmware binaries.

Actions:

  1. Clones aeris-via-software and aeris-sees-software from GitHub
  2. Configures git user name and email
  3. Authenticates GitHub CLI for artifact downloads
  4. Creates firmware download/flash scripts
  5. Downloads latest firmware binaries from GitHub Actions

Created Scripts:

Script Description
~/Aeris/via_build.sh Download VIA Teensy firmware + native binary
~/Aeris/via_flash.sh Flash VIA firmware to connected Teensy
~/Aeris/sees_build.sh Download SEES Teensy firmware + native binary
~/Aeris/sees_flash.sh Flash SEES firmware to connected Teensy

Directory Structure Created:

~/Aeris/
β”œβ”€β”€ aeris-via-software/     # VIA payload repo
β”œβ”€β”€ aeris-sees-software/    # SEES payload repo
β”œβ”€β”€ firmware/
β”‚   β”œβ”€β”€ via/firmware.hex    # VIA Teensy firmware
β”‚   └── sees/firmware.hex   # SEES Teensy firmware
β”œβ”€β”€ bin/
β”‚   β”œβ”€β”€ via_native          # VIA simulation binary
β”‚   └── sees_native         # SEES simulation binary
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ via/                # VIA measurement data
β”‚   └── sees/               # SEES particle data
β”œβ”€β”€ logs/
β”œβ”€β”€ backups/
└── docs/

Credits

AERIS Payload Software Team - Hawaii Space Flight Laboratory

2025