Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
a0fd211
chore: add stm32 files to gitignore
forrisdahl Oct 18, 2025
0c864ad
feat: add acoustic stm32cubeide project
forrisdahl Oct 18, 2025
f675a47
feat: add stm32 config
forrisdahl Oct 18, 2025
2ff419c
feat: add stm32cubeide generated drivers
forrisdahl Oct 18, 2025
c725ffa
fix: temporary disable cyclomatic compexity
forrisdahl Oct 18, 2025
8741ad5
feat: add ads8555 driver
forrisdahl Oct 19, 2025
6a0b0b0
feat: add CMSIS_DSP in project
forrisdahl Oct 19, 2025
559da65
fix: remove all f16.h
forrisdahl Oct 19, 2025
88efb20
fix: add ARM_MATH_CM7 flag
forrisdahl Oct 19, 2025
fc2ba9b
fix: remove *.s from .gitignore
forrisdahl Oct 19, 2025
8610488
feat: add startup .S file that was previously ignored
forrisdahl Oct 19, 2025
dfb1b72
feat: add dsp
forrisdahl Oct 19, 2025
97903d9
feat: add multilateration
forrisdahl Oct 20, 2025
db9441d
fix: buttterworth function used same pointer as source in destination
forrisdahl Oct 20, 2025
d0f8d56
refactor: remove redundant (void)
forrisdahl Oct 20, 2025
3e79fac
fix: butterworth io_o output to out_u instead of out_i
forrisdahl Oct 20, 2025
6aeacb7
feat: convert multilateration to use arm_math
forrisdahl Oct 21, 2025
fd6c222
feat: add deinterleave_fast function
forrisdahl Oct 21, 2025
841f79a
feat: add dsp_decimate function using arm_fir_decimate
forrisdahl Oct 22, 2025
394658c
feat: add fir_decimate to init and struct
forrisdahl Oct 22, 2025
cdbadd3
refactor: remove if statements from dsp init
forrisdahl Oct 22, 2025
5492fae
fix: add dsp_decimate to dsp.h, remove old decimate declaration
forrisdahl Oct 22, 2025
8fb756f
feat: add dsp_matched_filter function
forrisdahl Oct 22, 2025
bb5a284
feat: improve deinterleave function
forrisdahl Oct 22, 2025
d619e4a
refactor: replace ml_init with memset to 0
forrisdahl Oct 23, 2025
55a3a42
fix: remove remaining float16 files
forrisdahl Oct 23, 2025
78c08d9
fix: remove inline from deinterleave function
forrisdahl Oct 23, 2025
3157b4b
refactor: simplify dsp_init function by using macros for constants
forrisdahl Oct 23, 2025
1a9955d
style: chane input from n to size
forrisdahl Oct 24, 2025
36d2dea
feat: ml_solve using cholesky instead of inverse
forrisdahl Oct 25, 2025
4ecb0f4
feat: add fir coefficients
forrisdahl Oct 25, 2025
033fe07
style: rename multilateration function from ml to multilateration
forrisdahl Oct 26, 2025
763b1fe
feat: add send_can and send_usart function
forrisdahl Oct 26, 2025
2da0f3d
fix: communication.c include typo
forrisdahl Oct 26, 2025
32bce46
feat: update acoustics stm32cubeide project
forrisdahl Oct 26, 2025
f8a0237
feat: convert FIR and IIR from float to q15
forrisdahl Oct 26, 2025
10559b3
feat: add mix_to_baseband_q15 function
forrisdahl Oct 26, 2025
1d543a5
feat: add simd instructions in matched_filter
forrisdahl Oct 27, 2025
963f1ec
docs: add doxygen comments for all dsp functions
forrisdahl Oct 27, 2025
ed8abea
docs: add doxygen comment for dsp_context struct
forrisdahl Oct 29, 2025
6b7b308
refactor: convert from __PKHBT to read_q15x2_ia
forrisdahl Oct 29, 2025
793a5e2
refactor: use arm convention on mix_to_baseband
forrisdahl Oct 29, 2025
690c976
refactor: move deinterleave function from ads driver to dsp.c
forrisdahl Oct 30, 2025
3fadedb
feat: add test code in main to explore memory layouts
forrisdahl Oct 30, 2025
c81baa2
feat: add ad7606 driver skeleton
forrisdahl Nov 5, 2025
c874105
feat: add ad7606 register configuration enum and functions
forrisdahl Nov 5, 2025
26ab889
feat: add ad7606 set register and send register function
forrisdahl Nov 5, 2025
71b2321
feat: simplify ad7606 driver
forrisdahl Dec 24, 2025
586f441
refactor: Changed from VIT6 to ZIT6 package. Also added some file str…
Wiacer Jan 6, 2026
d30006c
refactor: just moved some files and got it to build in cubeide
Wiacer Jan 8, 2026
2bf62c2
feat: Python Multilatiration prototype finnished plus other stuff
Wiacer Jan 9, 2026
a747d33
feat: testing position solver noise sensitivity
Wiacer Jan 13, 2026
5162a58
feat: Python fullstack prototype basically fully finnished AND WORKS
Wiacer Jan 13, 2026
e4d5f28
feat: added proper UnderwaterAcoustics simulation using Julia
Wiacer Jan 15, 2026
cb18ccf
fix: enabled abstime so there is an actuall time difference between t…
Wiacer Jan 15, 2026
171ad3b
feat/refactor: redoing dsp pipeline due to multipath. Implemented SNR…
Wiacer Jan 21, 2026
574f2da
feat: kinda works i guess, presence detection that is
Wiacer Jan 21, 2026
9d564fd
feat: quite poggers implementation, works really nicely at detecting …
Wiacer Jan 21, 2026
0a434b7
fear: added the hardware to the data simulator using the bode plot ge…
Wiacer Jan 22, 2026
537ec79
refactor: removed PSD plotting since it was just a scaled copy of FFT…
Wiacer Jan 22, 2026
e1a5e61
feat/refactor: MASSIVELY improved the SNR calculation algorithm for s…
Wiacer Jan 22, 2026
273942a
feat: implemented buffers with blocks so that we only work on one of …
Wiacer Jan 22, 2026
1a6f9d8
refactor: added ability to call fullstack script from another script …
Wiacer Jan 22, 2026
091d717
BIG FEAT: the fullstack is actually fullstack now. With the detection…
Wiacer Jan 22, 2026
3ec0b1e
refactor: litt finpuss
Wiacer Jan 22, 2026
3990aea
feat: improved gui* (its kinda buggy so dont use overlap feature)
Wiacer Jan 23, 2026
cfd7365
feat/fix/refactor: Massively improved the gui for the data visualization
Wiacer Jan 23, 2026
6032b64
cleanup: cleaned up removing old files not in use
Wiacer Jan 23, 2026
421ba85
fix: fixed a bug with the gui that i don't remember
Wiacer Jan 23, 2026
4e29677
feat: added lines showing block borders when showing workspace
Wiacer Jan 23, 2026
a8b9917
fix: overlap button no longer offscreen
Wiacer Jan 23, 2026
2c2cb28
fix: pause buttons work now and properly configured gitignore
Wiacer Jan 23, 2026
1415ca6
feat: made the fft plots be bar plots
Wiacer Jan 23, 2026
39eec93
feat: added lines on arrival indices
Wiacer Jan 23, 2026
5642038
fix: removed ignored file from tracking
Wiacer Jan 23, 2026
d864e43
feat: got a really good example data and got a nice sanity check sinc…
Wiacer Jan 23, 2026
0f2a1fd
feat: added more passable args to the fullstack prototype
Wiacer Jan 23, 2026
0aa2fc0
fix: detected indicies show properly now
Wiacer Jan 23, 2026
8e97eb0
feat: added optional intentional corruption for testing
Wiacer Jan 23, 2026
b910979
attempt: tried implementing tests
Wiacer Jan 24, 2026
3e6d75c
feat: proper first peak detection, so the fullstack works really nice…
Wiacer Jan 24, 2026
b7a5499
feat: implemented tests and cool stuff
Wiacer Jan 24, 2026
7b1fc3c
feat: added more info to the test output
Wiacer Jan 24, 2026
aa265ce
feat/fix: fixed some stuff added some stuff. idk
Wiacer Jan 27, 2026
fc42351
feat: add CMSIS_DSP to new project
forrisdahl Feb 26, 2026
5940aa5
feat: use channel struct instead of multiple channel arrays
forrisdahl Feb 26, 2026
320959d
feat: reduce spi clock
forrisdahl Feb 26, 2026
4787511
I really don't know
Wiacer Mar 1, 2026
c08c998
Merge branch 'feat/acoustics' of https://github.com/vortexntnu/vortex…
Wiacer Mar 1, 2026
185366c
feat: ADC output gets sent to UART
Wiacer Mar 2, 2026
68cd41a
feat: added functions for reading ADC output. also added cool macros …
Wiacer Mar 2, 2026
28e6f0b
refactor: moved functions from main to adc driver
Wiacer Mar 2, 2026
c2e5886
feat/fix: added dout4 read adc function. Fixed dout8
Wiacer Mar 3, 2026
3683922
rebase: rewrote the entire adc driver and organized the workspace
Wiacer Mar 5, 2026
77b615d
fix: fixed the ad7606 driver i think
Wiacer Mar 7, 2026
084be3c
feat: life is good. 62.5kSPS achieved using interrupts and basically …
Wiacer Mar 7, 2026
3fe1b6e
125kHz not achieved and shit don't work
Wiacer Mar 8, 2026
cf4b72a
refactor: cleaned up after SPI hell (it isn't over though)
Wiacer Mar 9, 2026
4e70842
feat: RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH!!!!!!!!!!!!!!!!!!!
Wiacer Mar 9, 2026
92b9937
feat: life is amazing
Wiacer Mar 11, 2026
db6ce5d
cwt funker ikke enda
Wiacer Mar 11, 2026
a5c8779
feat: all detection is algorithms are done in TCM with help of MDMA now
Wiacer Mar 12, 2026
0b49e31
feat: cwt misbehaving
Wiacer Mar 12, 2026
5788055
idk: added some stuff fixed some stuff idk
Wiacer Mar 14, 2026
2d1464d
life is good
Wiacer Mar 23, 2026
7f5c2c0
idk honestly
Wiacer Mar 28, 2026
5f94fe1
feat: DSP part finally finnished
Wiacer Mar 28, 2026
a694c04
TDOA direction estimation works i think. Testing needed
Wiacer Mar 28, 2026
aaf7e17
trying to get can to work
Wiacer Mar 29, 2026
d2da2b5
feat: retning works kinda
Wiacer Apr 1, 2026
365ca3d
begynte på canvus parser
Wiacer Apr 2, 2026
a9e0d82
acoustics works?
Wiacer Apr 2, 2026
158cc15
feat: add can plotter
forrisdahl Apr 3, 2026
aaf2b2c
acoustics works?
Wiacer Apr 3, 2026
17b0700
Merge branch 'feat/acoustics' of https://github.com/vortexntnu/vortex…
Wiacer Apr 3, 2026
d73806b
It kinda just works
Wiacer Apr 4, 2026
546460e
acoustics works
Wiacer Apr 6, 2026
949c0f2
feat: many small improvements
Wiacer Apr 13, 2026
d062194
MAJOR refactor: polished acoustics
Wiacer Apr 26, 2026
0d23eca
feat: Got it working baby.
Wiacer Apr 27, 2026
82c1b0d
fix: temperature monitoring ADC was firing an interrupt so often the …
Wiacer Apr 27, 2026
85b9f6b
added ros2 live viewer
Wiacer May 15, 2026
4447c49
refactor: Cleaned up the big ugly function
Wiacer May 15, 2026
d4daab4
Merge branch 'feat/acoustics' of https://github.com/vortexntnu/vortex…
Wiacer May 15, 2026
82e3d90
polish: removed functions and variables from acoustics.h that weren't
Wiacer May 16, 2026
6682e72
changed some function names and stuff
Wiacer May 16, 2026
e16992e
Ensured that the system can't get stuck in the can state
Wiacer Jun 7, 2026
fbdd24c
Removed firmware old and got rid of "2" in name
Wiacer Jun 7, 2026
cdbd341
removed and moved a bunch of stuff
Wiacer Jun 7, 2026
84dee5e
Made the sim guide comprehensible
Wiacer Jun 7, 2026
b137577
Attempting to ignore CMSIS library stuff
Wiacer Jun 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ compile_commands.json
*.o
*.out
*.a
*.s
*.dylib
*.so
*.exe
Expand All @@ -63,3 +62,13 @@ Thumbs.db
.idea/
*.vscode/

# eclipse specific git ignore
.metadata/
RemoteSystemsTempFiles/
.settings/
Debug/
*.launch

# STM32 git ignore
*.mxproject
*.su
Original file line number Diff line number Diff line change
@@ -0,0 +1,372 @@
#include "external_pressure.h"

#include <string.h>
#include <math.h>

/* Include your Harmony / peripheral header here */
#include "definitions.h" /* or the correct header for SERCOM3_I2C_xxx */

/* ---------- Configuration ---------- */

#define MS5837_ADDR 0x76U
#define MS5837_RESET 0x1EU
#define MS5837_ADC_READ 0x00U
#define MS5837_PROM_READ 0xA0U
#define MS5837_CONVERT_D1_8192 0x4AU
#define MS5837_CONVERT_D2_8192 0x5AU

/* context: https://github.com/ArduPilot/ardupilot/pull/29122#issuecomment-2877269114 */
#define MS5837_02BA_MAX_SENSITIVITY 49000U
#define MS5837_02BA_30BA_SEPARATION 37000U
#define MS5837_30BA_MIN_SENSITIVITY 26000U

/* Replace this with your system delay function */
static void ms5837_delay_ms(uint32_t ms)
{
/* Example options:
- SYS_TIME_DelayMS(ms, &handle);
- vTaskDelay(pdMS_TO_TICKS(ms));
- core timer loop
*/

/* Placeholder busy loop - replace for real hardware */
volatile uint32_t count;
while (ms--)
{
for (count = 0; count < 10000U; count++)
{
__asm__ volatile ("nop");
}
}
}

/* ---------- Internal helpers ---------- */

static bool ms5837_write_command(uint8_t cmd)
{
return SERCOM3_I2C_Write(MS5837_ADDR, &cmd, 1U);
}

static bool ms5837_read_adc24(uint32_t *value)
{
uint8_t cmd = MS5837_ADC_READ;
uint8_t buf[3];

if (!SERCOM3_I2C_WriteRead(MS5837_ADDR, &cmd, 1U, buf, 3U))
{
return false;
}

*value = ((uint32_t)buf[0] << 16)
| ((uint32_t)buf[1] << 8)
| ((uint32_t)buf[2]);

return true;
}

static bool ms5837_read_prom_word(uint8_t index, uint16_t *word)
{
uint8_t cmd = (uint8_t)(MS5837_PROM_READ + (index * 2U));
uint8_t buf[2];

if (!SERCOM3_I2C_WriteRead(MS5837_ADDR, &cmd, 1U, buf, 2U))
{
return false;
}

*word = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];
return true;
}

static uint8_t ms5837_crc4(uint16_t n_prom[])
{
uint16_t n_rem = 0;
uint8_t i;
uint8_t n_bit;

n_prom[0] = (uint16_t)(n_prom[0] & 0x0FFFU);
n_prom[7] = 0U;

for (i = 0; i < 16U; i++)
{
if ((i % 2U) == 1U)
{
n_rem ^= (uint16_t)(n_prom[i >> 1] & 0x00FFU);
}
else
{
n_rem ^= (uint16_t)(n_prom[i >> 1] >> 8);
}

for (n_bit = 8U; n_bit > 0U; n_bit--)
{
if (n_rem & 0x8000U)
{
n_rem = (uint16_t)((n_rem << 1) ^ 0x3000U);
}
else
{
n_rem = (uint16_t)(n_rem << 1);
}
}
}

n_rem = (uint16_t)((n_rem >> 12) & 0x000FU);
return (uint8_t)(n_rem ^ 0x00U);
}

static void ms5837_calculate(MS5837_t *dev)
{
int32_t dT = 0;
int64_t SENS = 0;
int64_t OFF = 0;
int32_t SENSi = 0;
int32_t OFFi = 0;
int32_t Ti = 0;
int64_t OFF2 = 0;
int64_t SENS2 = 0;

dT = (int32_t)(dev->D2_temp - ((uint32_t)dev->C[5] * 256UL));

if (dev->model == MS5837_02BA)
{
SENS = ((int64_t)dev->C[1] * 65536LL) + (((int64_t)dev->C[3] * dT) / 128LL);
OFF = ((int64_t)dev->C[2] * 131072LL) + (((int64_t)dev->C[4] * dT) / 64LL);
dev->P = (int32_t)((((int64_t)dev->D1_pres * SENS) / 2097152LL - OFF) / 32768LL);
}
else
{
SENS = ((int64_t)dev->C[1] * 32768LL) + (((int64_t)dev->C[3] * dT) / 256LL);
OFF = ((int64_t)dev->C[2] * 65536LL) + (((int64_t)dev->C[4] * dT) / 128LL);
dev->P = (int32_t)((((int64_t)dev->D1_pres * SENS) / 2097152LL - OFF) / 8192LL);
}

dev->TEMP = (int32_t)(2000LL + ((int64_t)dT * dev->C[6]) / 8388608LL);

if (dev->model == MS5837_02BA)
{
if ((dev->TEMP / 100) < 20)
{
Ti = (int32_t)((11LL * (int64_t)dT * (int64_t)dT) / 34359738368LL);
OFFi = (int32_t)((31LL * (dev->TEMP - 2000) * (dev->TEMP - 2000)) / 8LL);
SENSi = (int32_t)((63LL * (dev->TEMP - 2000) * (dev->TEMP - 2000)) / 32LL);
}
}
else
{
if ((dev->TEMP / 100) < 20)
{
Ti = (int32_t)((3LL * (int64_t)dT * (int64_t)dT) / 8589934592LL);
OFFi = (int32_t)((3LL * (dev->TEMP - 2000) * (dev->TEMP - 2000)) / 2LL);
SENSi = (int32_t)((5LL * (dev->TEMP - 2000) * (dev->TEMP - 2000)) / 8LL);

if ((dev->TEMP / 100) < -15)
{
OFFi += (int32_t)(7LL * (dev->TEMP + 1500) * (dev->TEMP + 1500));
SENSi += (int32_t)(4LL * (dev->TEMP + 1500) * (dev->TEMP + 1500));
}
}
else
{
Ti = (int32_t)((2LL * (int64_t)dT * (int64_t)dT) / 137438953472LL);
OFFi = (int32_t)(((int64_t)(dev->TEMP - 2000) * (dev->TEMP - 2000)) / 16LL);
SENSi = 0;
}
}

OFF2 = OFF - OFFi;
SENS2 = SENS - SENSi;

dev->TEMP -= Ti;

if (dev->model == MS5837_02BA)
{
dev->P = (int32_t)((((int64_t)dev->D1_pres * SENS2) / 2097152LL - OFF2) / 32768LL);
}
else
{
dev->P = (int32_t)((((int64_t)dev->D1_pres * SENS2) / 2097152LL - OFF2) / 8192LL);
}
}

/* ---------- Public API ---------- */

bool MS5837_Begin(MS5837_t *dev)
{
return MS5837_Init(dev);
}

bool MS5837_Init(MS5837_t *dev)
{
uint8_t i;
uint8_t crcRead;
uint8_t crcCalculated;
uint16_t prom_copy[8];

if (dev == NULL)
{
return false;
}

memset(dev, 0, sizeof(*dev));
dev->fluidDensity = 1029.0f;
dev->model = MS5837_UNRECOGNISED;
dev->initialized = false;

SERCOM3_I2C_Initialize();

if (!ms5837_write_command(MS5837_RESET))
{
return false;
}

ms5837_delay_ms(10U);

for (i = 0; i < 7U; i++)
{
if (!ms5837_read_prom_word(i, &dev->C[i]))
{
return false;
}
}

dev->C[7] = 0U;

for (i = 0; i < 8U; i++)
{
prom_copy[i] = dev->C[i];
}

crcRead = (uint8_t)(dev->C[0] >> 12);
crcCalculated = ms5837_crc4(prom_copy);

if (crcCalculated != crcRead)
{
return false;
}

if ((dev->C[1] < MS5837_30BA_MIN_SENSITIVITY) ||
(dev->C[1] > MS5837_02BA_MAX_SENSITIVITY))
{
dev->model = MS5837_UNRECOGNISED;
}
else if (dev->C[1] > MS5837_02BA_30BA_SEPARATION)
{
dev->model = MS5837_02BA;
}
else
{
dev->model = MS5837_30BA;
}

dev->initialized = true;
return true;
}

void MS5837_SetModel(MS5837_t *dev, uint8_t model)
{
if (dev != NULL)
{
dev->model = model;
}
}

uint8_t MS5837_GetModel(const MS5837_t *dev)
{
if (dev == NULL)
{
return MS5837_UNRECOGNISED;
}

return dev->model;
}

void MS5837_SetFluidDensity(MS5837_t *dev, float density)
{
if (dev != NULL)
{
dev->fluidDensity = density;
}
}

bool MS5837_Read(MS5837_t *dev)
{
if ((dev == NULL) || (!dev->initialized))
{
return false;
}

if (!ms5837_write_command(MS5837_CONVERT_D1_8192))
{
return false;
}

ms5837_delay_ms(20U);

if (!ms5837_read_adc24(&dev->D1_pres))
{
return false;
}

if (!ms5837_write_command(MS5837_CONVERT_D2_8192))
{
return false;
}

ms5837_delay_ms(20U);

if (!ms5837_read_adc24(&dev->D2_temp))
{
return false;
}

ms5837_calculate(dev);
return true;
}

float MS5837_Pressure(const MS5837_t *dev, float conversion)
{
if (dev == NULL)
{
return 0.0f;
}

if (dev->model == MS5837_02BA)
{
return ((float)dev->P * conversion) / 100.0f;
}
else
{
return ((float)dev->P * conversion) / 10.0f;
}
}

float MS5837_Temperature(const MS5837_t *dev)
{
if (dev == NULL)
{
return 0.0f;
}

return (float)dev->TEMP / 100.0f;
}

float MS5837_Depth(const MS5837_t *dev)
{
if (dev == NULL)
{
return 0.0f;
}

return (MS5837_Pressure(dev, MS5837_PA) - 101300.0f) / (dev->fluidDensity * 9.80665f);
}

float MS5837_Altitude(const MS5837_t *dev)
{
if (dev == NULL)
{
return 0.0f;
}

return (1.0f - powf((MS5837_Pressure(dev, 1.0f) / 1013.25f), 0.190284f)) * 145366.45f * 0.3048f;
}
Loading