summaryrefslogtreecommitdiff
path: root/include/log_format.hpp
diff options
context:
space:
mode:
authorDawsyn Schraiber <[email protected]>2025-06-20 00:10:22 -0400
committerGitHub <[email protected]>2025-06-20 00:10:22 -0400
commit5375c6d876f115a2bd75ec45796e5333ba928082 (patch)
tree51d8701b6e0b10b3171c8a146304a3accf57d150 /include/log_format.hpp
parente07f105022f3ad6e3c6ee2dfe4cc01eb91c1f373 (diff)
downloadactive-drag-system-5375c6d876f115a2bd75ec45796e5333ba928082.tar.gz
active-drag-system-5375c6d876f115a2bd75ec45796e5333ba928082.tar.bz2
active-drag-system-5375c6d876f115a2bd75ec45796e5333ba928082.zip
Big Kahuna - IREC 2025 - Dawsyn's Final Commit (#16)HEADmain
# Dawsyn's Final Commit This one is a little emotional as this is my final commit in this repository and as a member of Rocketry at Virginia Tech. This merges the changes seen in the branch known as 'big_kahuna' into main. This is the version of the ADS software as seen on [Roadkill](https://drive.google.com/file/d/120BvI-0ntliHo6i9UxcCn2pXAl-JsdP_/view?usp=drive_link) in the 2025 IREC competition. There are bound to be bugs, but I have found it useful to have the final competition version to be the one present on main at the end of every academic year. Hopefully this is useful to the next lead. ## Primary Changes + NEW I2C drivers to support sensors present on new ADS custom PCB + NEW logging library found in separate repository and pulled in as submodule ([pico-logger](https://github.com/rocketryvt/pico-logger)) + No longer dependent on different flash chip from one used for code storage! Compile executable as RP2040 'copy-to-ram' type to increase flash read/write speeds! + NEW fixed-point libraries to allow for increased performance and sensor sampling speeds on RP2040 that lacks FPU + FreeRTOS Simultaneous Multi-processing (SMP) architecture for task handling and easier introduction / testing of new features + Serial monitor / command system with task performance monitoring commands + WORKING Kalman filter that takes altitude from barometer as measurement and z-axis acceleration from IMU as control to generate state vector containing filtered altitude and vertical velocity + NEW CFD equations from the Ben-ogrithm (to replace the Chen-ogrithm) that includes: + Apogee prediction model that takes current drag force, altitude, and vertical velocity + Current Drag Force equation based on current deployment and vertical velocity to use for Apogee Prediction model + Desired Drag force equation based on current altitude and vertical velocity to generate what drag force is needed to reach 10K ft + Deployment percentage equation based on current velocity and desired drag force to map to flap deployment percentage
Diffstat (limited to 'include/log_format.hpp')
-rw-r--r--include/log_format.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/log_format.hpp b/include/log_format.hpp
new file mode 100644
index 0000000..013f9a4
--- /dev/null
+++ b/include/log_format.hpp
@@ -0,0 +1,69 @@
+#pragma once
+
+#include <stdint.h>
+#include <inttypes.h>
+
+#include "iim42653.hpp"
+#include "adxl375.hpp"
+#include "mmc5983ma.hpp"
+#include "ms5607.hpp"
+extern "C" {
+#include "fix16.h"
+}
+
+
+#define PACKET_SIZE 64
+#define PAD_SECONDS 2
+#define LOG_RATE_HZ 100
+#define PAD_BUFFER_SIZE (PACKET_SIZE * PAD_SECONDS * LOG_RATE_HZ)
+
+typedef enum {
+ PAD = 0,
+ BOOST,
+ COAST,
+ APOGEE,
+ RECOVERY,
+ END
+} state_t;
+
+typedef struct {
+ // 11 bytes General time and state data
+ uint64_t time_us :64;
+ state_t state :4;
+ uint16_t temperature_chip :12;
+ uint8_t deploy_percent :8;
+
+ // 16 bytes MS5607 data
+ uint32_t pressure :24; // 3
+ int32_t altitude :24; // 3
+ int32_t altitude_filt :32; // 4
+ int32_t velocity_filt:32; // 4
+ int16_t temperature_alt :16; // 2
+
+ // 12 bytes IMU data
+ int16_t ax :16;
+ int16_t ay :16;
+ int16_t az :16;
+ int16_t gx :16;
+ int16_t gy :16;
+ int16_t gz :16;
+
+ // 6 bytes MAG data
+ int16_t mag_x :16;
+ int16_t mag_y :16;
+ int16_t mag_z :16;
+
+ // 6 bytes High G Accel data
+ int16_t high_g_x :16;
+ int16_t high_g_y :16;
+ int16_t high_g_z :16;
+
+ // 12 bytes controls information
+ int32_t drag_force: 32; // 4
+ int32_t apogee_prediction: 32; // 4
+ int32_t desired_drag_force: 32; // 4
+
+ uint8_t data0: 8;
+} __attribute__((packed)) log_entry_t;
+
+void print_log_entry(const uint8_t* entry);