-
Notifications
You must be signed in to change notification settings - Fork 0
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
ADBMS Integration #138
base: develop
Are you sure you want to change the base?
ADBMS Integration #138
Changes from all commits
60650d1
89b9d97
004e83d
fe7b35e
331f9dd
a7bff61
ccff5e0
d1b4701
c671679
f0a2a60
e611107
6791c57
93379f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "Drivers/Embedded-Base"] | ||
path = Drivers/Embedded-Base | ||
url = https://github.com/Northeastern-Electric-Racing/Embedded-Base.git | ||
[submodule "Drivers/adbms"] | ||
path = Drivers/adbms | ||
url = [email protected]:Northeastern-Electric-Racing/adbms.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
#include "compute.h" | ||
|
||
#include "serialPrintResult.h" | ||
|
||
// clang-format off | ||
/** | ||
* @brief Mapping Cell temperature to the cell resistance based on the | ||
|
@@ -120,22 +122,6 @@ const uint8_t RELEVANT_THERM_MAP_L[NUM_CELLS_PER_CHIP][NUM_RELEVANT_THERMS] = | |
{6 + MUX_OFFSET, 8 + MUX_OFFSET, NO_THERM}, | ||
}; | ||
|
||
uint8_t THERM_DISABLE[NUM_CHIPS][NUM_THERMS_PER_CHIP] = | ||
{ | ||
{1,0,1,0,0,1,0,1,1,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,1,0 }, | ||
{1,0,1,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1 }, | ||
{1,0,1,0,0,1,0,0,1,0,0,1,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0 }, | ||
{1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,0,1,0,0,1,0,0,0,0 }, | ||
{1,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1 }, | ||
{1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0 }, | ||
{1,0,1,0,0,1,0,0,1,0,1,1,0,0,1,1,0,0,1,0,1,1,1,0,0,0,0,0,0,0,1,0 }, | ||
{1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1 }, | ||
{1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0 }, | ||
{1,0,1,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,0 }, | ||
{1,1,1,0,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0 }, | ||
{1,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,0 } | ||
}; | ||
|
||
/* | ||
* List of therms that we actually read from, NOT reordered by cell | ||
*/ | ||
|
@@ -223,9 +209,11 @@ void calc_pack_temps(acc_data_t *bmsdata) | |
bmsdata->min_temp.val = MAX_TEMP; | ||
bmsdata->min_temp.cellNum = 0; | ||
bmsdata->min_temp.chipIndex = 0; | ||
|
||
int total_temp = 0; | ||
int total_seg_temp = 0; | ||
int total_accepted = 0; | ||
|
||
for (uint8_t c = 0; c < NUM_CHIPS; c++) { | ||
for (uint8_t therm = 0; therm < NUM_THERMS_PER_CHIP; therm++) { | ||
/* finds out the maximum cell temp and location */ | ||
|
@@ -310,10 +298,13 @@ void calc_pack_voltage_stats(acc_data_t *bmsdata) | |
for (uint8_t c = 0; c < NUM_CHIPS; c++) { | ||
for (uint8_t cell = 0; cell < NUM_CELLS_PER_CHIP; cell++) { | ||
/* fings out the maximum cell voltage and location */ | ||
if (bmsdata->chip_data[c].voltage[cell] > | ||
if (getVoltage(bmsdata->chip_data[c].voltage[cell]) * | ||
10000 > | ||
bmsdata->max_voltage.val) { | ||
bmsdata->max_voltage.val = | ||
bmsdata->chip_data[c].voltage[cell]; | ||
getVoltage(bmsdata->chip_data[c] | ||
.voltage[cell]) * | ||
10000; | ||
bmsdata->max_voltage.chipIndex = c; | ||
bmsdata->max_voltage.cellNum = cell; | ||
} | ||
|
@@ -328,10 +319,13 @@ void calc_pack_voltage_stats(acc_data_t *bmsdata) | |
} | ||
|
||
/* finds out the minimum cell voltage and location */ | ||
if (bmsdata->chip_data[c].voltage[cell] < | ||
if (getVoltage(bmsdata->chip_data[c].voltage[cell]) * | ||
10000 < | ||
bmsdata->min_voltage.val) { | ||
bmsdata->min_voltage.val = | ||
bmsdata->chip_data[c].voltage[cell]; | ||
getVoltage(bmsdata->chip_data[c] | ||
.voltage[cell]) * | ||
10000; | ||
bmsdata->min_voltage.chipIndex = c; | ||
bmsdata->min_voltage.cellNum = cell; | ||
} | ||
|
@@ -351,9 +345,21 @@ void calc_pack_voltage_stats(acc_data_t *bmsdata) | |
} | ||
} | ||
|
||
float real_total_volt = 0; | ||
for (int chip = 0; chip < NUM_CHIPS; chip++) { | ||
for (int i = 0; i < NUM_CELLS_PER_CHIP; i++) { | ||
real_total_volt += | ||
getVoltage(bmsdata->chip_data[chip].voltage[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my questions in slack about chip_data. We shouldnt call getVoltage on a struct field outside of adbms, that feels wierd and takes their specific register format to the rest of the code. Imo we should either remove chipdata_t and call stuff on cell_asic or store the cell_asic stuff as floats post-conversion. |
||
} | ||
} | ||
|
||
/* calculate some voltage stats */ | ||
bmsdata->avg_voltage = total_volt / (NUM_CELLS_PER_CHIP * NUM_CHIPS); | ||
bmsdata->pack_voltage = total_volt / 1000; /* convert to voltage * 10 */ | ||
bmsdata->avg_voltage = | ||
10000 * (real_total_volt / (NUM_CELLS_PER_CHIP * NUM_CHIPS)); | ||
|
||
bmsdata->pack_voltage = | ||
real_total_volt * 10; /* convert to voltage * 10 */ | ||
|
||
bmsdata->delt_voltage = | ||
bmsdata->max_voltage.val - bmsdata->min_voltage.val; | ||
|
||
|
@@ -618,29 +624,29 @@ uint8_t analyzer_calc_fan_pwm(acc_data_t *bmsdata) | |
(2 * 5); | ||
} | ||
|
||
void disable_therms(acc_data_t *bmsdata) | ||
{ | ||
int8_t tmp_temp = | ||
25; /* Iniitalize to room temp (necessary to stabilize when the BMS first boots up/has null values) */ | ||
if (!is_first_reading_) | ||
tmp_temp = | ||
bmsdata->avg_temp; /* Set to actual average temp of the pack */ | ||
|
||
for (uint8_t c = 0; c < NUM_CHIPS; c++) { | ||
for (uint8_t therm = 0; therm < NUM_THERMS_PER_CHIP; therm++) { | ||
/* If 2D LUT shows therm should be disable */ | ||
if (THERM_DISABLE[c][therm]) { | ||
/* Nullify thermistor by setting to pack average */ | ||
bmsdata->chip_data[c].thermistor_value[therm] = | ||
tmp_temp; | ||
} else { | ||
bmsdata->chip_data[c].thermistor_value[therm] = | ||
bmsdata->chip_data[c] | ||
.thermistor_reading[therm]; | ||
} | ||
} | ||
} | ||
} | ||
// void disable_therms(acc_data_t *bmsdata) | ||
// { | ||
// int8_t tmp_temp = | ||
// 25; /* Iniitalize to room temp (necessary to stabilize when the BMS first boots up/has null values) */ | ||
// if (!is_first_reading_) | ||
// tmp_temp = | ||
// bmsdata->avg_temp; /* Set to actual average temp of the pack */ | ||
|
||
// for (uint8_t c = 0; c < NUM_CHIPS; c++) { | ||
// for (uint8_t therm = 0; therm < NUM_THERMS_PER_CHIP; therm++) { | ||
// /* If 2D LUT shows therm should be disable */ | ||
// if (THERM_DISABLE[c][therm]) { | ||
// /* Nullify thermistor by setting to pack average */ | ||
// bmsdata->chip_data[c].thermistor_value[therm] = | ||
// tmp_temp; | ||
// } else { | ||
// bmsdata->chip_data[c].thermistor_value[therm] = | ||
// bmsdata->chip_data[c] | ||
// .thermistor_reading[therm]; | ||
// } | ||
// } | ||
// } | ||
// } | ||
|
||
void calc_state_of_charge(acc_data_t *bmsdata) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its the number of therms that we actually wanted to read on a segment. I think we'll be getting rid of this but i think its outside the scope of this.