Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created sht30 internal temp fault monitoring #55

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Core/Inc/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//#include <nerduino.h> Replace
#include "datastructs.h"
#include "segment.h"
#include "Core/Drivers/Embedded-Base/general/include/sht30.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ive discovered that for whatever reason it doesnt love the full path, so actually just "sht30.h" will work better


/* We want to make sure we aren't doing useless analysis on the same set of data since we are
* backfilling segment data */
Expand Down Expand Up @@ -33,4 +34,14 @@ AccumulatorData_t* bmsdata;

AccumulatorData_t* prevbmsdata;

/**
* @brief Create a new object to store the most recent data point for the temp sensor
*/
sht30_t* sht30data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like the @brief got doubled here, but also dont think we need one at all. creating an sht30 object right nect to an acc data one is pretty self explanatory imo, so feel free to remove both


/**
* @brief Create a new object to store the most recent data point for the temp sensor
*/
void sht30_init();

#endif
2 changes: 2 additions & 0 deletions Core/Inc/bmsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define MIN_TEMP -15 // deg C
#define MAX_VOLT_MEAS 65535
#define MIN_VOLT_MEAS 0
#define MAX_INTERNAL_TEMP 0 // needs to be set

// Boosting Parameters
#define BOOST_TIME 5 // seconds
Expand Down Expand Up @@ -48,6 +49,7 @@
#define LOW_CELL_TIME 15000
#define HIGH_TEMP_TIME 60000
#define CURR_ERR_MARG 50 // in A * 10
#define HIGH_INT_TEMP_TIME 0 // to be determined

#define DCDC_CURRENT_DRAW 2 // in A, this is generous

Expand Down
9 changes: 8 additions & 1 deletion Core/Src/analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ Timer ocvTimer;

bool is_first_reading_ = true;

void push(AccumulatorData_t* data)
void push(AccumulatorData_t* data, sht30_t* sht30data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just gonna wanna update the acual call of this function in main.c to use this new param as well

{
if (prevbmsdata != nullptr)
delete prevbmsdata;

prevbmsdata = bmsdata;
bmsdata = data;

sht30_get_temp_humid(sht30data)

disable_therms();

high_curr_therm_check(); /* = prev if curr > 50 */
Expand Down Expand Up @@ -525,3 +527,8 @@ void diff_curr_therm_check()
}
}
}

void sht30_init(sht30_t* sht30data)
{
sht30data->i2c_handle = &hi2c1;
}
2 changes: 2 additions & 0 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ int main(void)
// NERduino.begin();
compute.compute_set_fault(NOT_FAULTED);
segment.init();

analyzer.sht30_init();
/* USER CODE END Init */

/* Configure the system clock */
Expand Down
5 changes: 3 additions & 2 deletions Core/Src/stateMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tristate_timer over_voltcharge_tmr;
tristate_timer overVolt_tmr;
tristate_timer lowCell_tmr;
tristate_timer highTemp_tmr;
tristate_timer internalTemp_tmr;

tristate_timer prefaultOverCurr_tmr;
tristate_timer prefaultLowCell_tmr;
Expand Down Expand Up @@ -189,7 +190,7 @@ void request_transition(BMSState_t next_state)
current_state = next_state;
}

uint32_t sm_fault_return(AccumulatorData_t* accData)
uint32_t sm_fault_return(AccumulatorData_t* accData, sht30_t* sht30_data)
{
/* FAULT CHECK (Check for fuckies) */

Expand All @@ -204,7 +205,7 @@ uint32_t sm_fault_return(AccumulatorData_t* accData)
{.id = "High Cell Voltage", .timer = overVolt_tmr, .data_1 = accData->max_voltage.val, .optype_1 = GT, .lim_1 = MAX_VOLT * 10000, .timeout = OVER_VOLT_TIME, .code = CELL_VOLTAGE_TOO_HIGH, .data_2 = accData->is_charger_connected, .optype_2 = EQ, .lim_2 = false },
{.id = "High Temp", .timer = highTemp_tmr, .data_1 = accData->max_temp.val, .optype_1 = GT, .lim_1 = MAX_CELL_TEMP, .timeout = LOW_CELL_TIME, .code = PACK_TOO_HOT /* -----------------------------------UNUSED---------------------------------*/ },
{.id = "Extremely Low Voltage", .timer = lowCell_tmr, .data_1 = accData->min_voltage.val, .optype_1 = LT, .lim_1 = 900, .timeout = HIGH_TEMP_TIME, .code = LOW_CELL_VOLTAGE /* -----------------------------------UNUSED---------------------------------*/ },

{.id = "High Internal Temp", .timer = internalTemp_tmr, .data_1 = sht30_data->temp .optype_1 = GT, .lim_1 = MAX_INTERNAL_TEMP, .timeout = HIGH_INT_TEMP_TIME, .code = INTERNAL_THERMAL_ERROR /* -----------------------------------UNUSED---------------------------------*/ },
NULL
// clang-format on
};
Expand Down
Loading