Skip to content

MVHS-Rocket-Group/STM32-Flight-Computer

Repository files navigation

STM32-Flight-Computer

Travis-CI Build Status

Travis CI Dashboard: travis-ci.com/MVHS-Rocket-Group/STM32-Flight-Computer

Repository Structure

  • .pio/*: PlatformIO config files and build directory. (Generated upon execution of first build)
  • .vscode/*: VSCode config files.
  • include/*: C/C++ header files.
    • constants.h: Provides constant definitions.
    • helpers.h: Provides development infrastructure for project.
    • mean_sensor_filter.h: Lightweight sensor noise filter taking a time-average for all inputs.
    • state.h: State struct providing convenient storage for all values in the state vector.
  • lib/*: C/C++ libraries.
  • src/*: C/C++ source code files.
    • main.cpp: Primary entry point for program.
  • .gitattributes, .gitignore: Git SCM config files.
  • travis.yml: Travis CI (continuous integration) automated build checker config.
  • platformio.ini: PlatformIO build config.
  • STM32-Flight-Computer.code-workspace: VSCode workspace file.
  • TODO.md: TODO list for project.

Description

STM32 (Blue Pill development board, STM32F103C8T6 MCU part) flight computer and FDR for high-power SRM rockets. This program is developed in conjunction with the PlatformIO IDE system with integration into VSCode and Atom editors, a substantial upgrade from the oxymoron Arduino IDE.

Program upload and line-by-line debugging support is provided by the wonderful ST-Link V2 connected to the STM32's SWD (Serial Wire Debug) port and a serial text terminal by an FTDI breakout board connected to UART1 on the STM32.

Relevant Peripherals

Principal control flow

Background on PWM control for Servo Motors and ESCs

RC PWM has a "window" period of 20ms (milliseconds), with a pulse ranging in width from 1ms to 2ms, where 1ms is ~0% command and 2ms is ~100% command. Duty cycle, a percentage, is a ratio of on-time to off-time.

ESC PWM Diagram

Therefore:

  • 0% throttle command --> 5% duty cycle
  • 100% throttle command --> 10% duty cycle

Documentation on PWM usage in Arduino

Rocket IMU Axes

From perspective of a cockpit at the nose cone: (TODO: Verify if these are still correct!)

Originally defined like a fighter plane due to how early spacecraft were flight cockpits plopped on the top of rocket boosters.

Vehicle Axis: Axis Description: IMU Measurement Axis:
X roll - vertical axis through center of rocket +X (acc), +X (gyro)
Y pitch - horizontal axis -Y (acc), +Y (gyro)
Z yaw - horizontal axis -Z (acc), +Z (gyro)

Helpful Resources

PlatformIO STM32 linker scripts

For some reason, the default STSTM32 linker scripts for the generic STM32F103C8, the chip on the Blue Pill, assume that the the MCU has 64K of program flash memory, which is just not the case, as most boards around have 128K of flash. This shouldn't be an issue, but for the extra headroom, this is a good mod. Original post on PlatformIO Community forum.

File Original Post-mod
[USER_DIR]\.platformio\platforms\ststm32\boards\genericSTM32F103C8.json "maximum_size": 65536, "maximum_size": 131072,
[USER_DIR]\.platformio\platforms\ststm32\ldscripts\stm32f103x8.ld FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K

Releases

No releases published

Packages

No packages published