From e60915d916a7d8f177ee25d75fdeb4bf29e95402 Mon Sep 17 00:00:00 2001 From: nwdepatie Date: Sat, 13 Apr 2024 22:32:33 -0400 Subject: [PATCH] Changes for getting car running --- Core/Src/analyzer.c | 7 ++++--- Core/Src/main.c | 24 ++++++++++++------------ Core/Src/segment.c | 4 +++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Core/Src/analyzer.c b/Core/Src/analyzer.c index 6745f4c..9ac42b0 100644 --- a/Core/Src/analyzer.c +++ b/Core/Src/analyzer.c @@ -153,13 +153,14 @@ void calc_state_of_charge(); void calc_cell_temps() { for (uint8_t c = 0; c < NUM_CHIPS; c++) { - const uint8_t **therm_map = (c % 2 == 0) ? RELEVANT_THERM_MAP_L : RELEVANT_THERM_MAP_H; + const uint8_t (*therm_map)[NUM_RELEVANT_THERMS] = (c % 2 == 0) ? RELEVANT_THERM_MAP_L : RELEVANT_THERM_MAP_H; for (uint8_t cell = 0; cell < NUM_CELLS_PER_CHIP; cell++) { int temp_sum = 0; for (uint8_t therm = 0; therm < NUM_RELEVANT_THERMS; therm++) { uint8_t thermNum = therm_map[cell][therm]; - temp_sum += bmsdata->chip_data[c].thermistor_value[thermNum]; + if (thermNum != THERM_DISABLE) + temp_sum += bmsdata->chip_data[c].thermistor_value[thermNum]; } /* Takes the average temperature of all the relevant thermistors */ @@ -486,7 +487,7 @@ void analyzer_push(acc_data_t* data) prevbmsdata = bmsdata; bmsdata = data; - disable_therms(); + //disable_therms(); high_curr_therm_check(); /* = prev if curr > 50 */ // diff_curr_therm_check(); /* = prev if curr - prevcurr > 10 */ diff --git a/Core/Src/main.c b/Core/Src/main.c index 6368783..bd50613 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -166,7 +166,7 @@ const void print_bms_stats(acc_data_t *acc_data) printf("Cell Temps:\r\n"); for(uint8_t c = 0; c < NUM_CHIPS; c++) { - for(uint8_t cell = 17; cell < 28; cell++) + for(uint8_t cell = 0; cell < 15; cell++) { printf("%d\t", acc_data->chip_data[c].thermistor_reading[cell]); } @@ -176,7 +176,7 @@ const void print_bms_stats(acc_data_t *acc_data) printf("Avg Cell Temps:\r\n"); for(uint8_t c = 0; c < NUM_CHIPS; c++) { - for(uint8_t cell = 17; cell < 28; cell++) + for(uint8_t cell = 0; cell < 15; cell++) { printf("%d\t", acc_data->chip_data[c].thermistor_value[cell]); } @@ -232,16 +232,16 @@ int main(void) MX_TIM8_Init(); MX_ADC1_Init(); /* USER CODE BEGIN 2 */ - for (int i = 0; i < 58; i++) - { - HAL_GPIO_WritePin(Debug_LEDB11_GPIO_Port, Debug_LEDB11_Pin, GPIO_PIN_SET); - HAL_Delay(58-i); - HAL_GPIO_WritePin(Debug_LEDB11_GPIO_Port, Debug_LEDB11_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(Debug_LED_GPIO_Port, Debug_LED_Pin, GPIO_PIN_SET); - HAL_Delay(58-i); - HAL_GPIO_WritePin(Debug_LED_GPIO_Port, Debug_LED_Pin, GPIO_PIN_RESET); - -} + //for (int i = 0; i < 58; i++) + //{ + // HAL_GPIO_WritePin(Debug_LEDB11_GPIO_Port, Debug_LEDB11_Pin, GPIO_PIN_SET); + // HAL_Delay(58-i); + // HAL_GPIO_WritePin(Debug_LEDB11_GPIO_Port, Debug_LEDB11_Pin, GPIO_PIN_RESET); + // HAL_GPIO_WritePin(Debug_LED_GPIO_Port, Debug_LED_Pin, GPIO_PIN_SET); + // HAL_Delay(58-i); + // HAL_GPIO_WritePin(Debug_LED_GPIO_Port, Debug_LED_Pin, GPIO_PIN_RESET); + // + //} //watchdog_init(); diff --git a/Core/Src/segment.c b/Core/Src/segment.c index e5fb1e0..286e884 100644 --- a/Core/Src/segment.c +++ b/Core/Src/segment.c @@ -75,6 +75,9 @@ void segment_init() local_config[c][5] = 0x00; } push_chip_configuration(); + + start_timer(&voltage_reading_timer, VOLTAGE_WAIT_TIME); + start_timer(&therm_timer, THERM_WAIT_TIME); } void select_therm(uint8_t therm){ @@ -161,7 +164,6 @@ int pull_voltages() dest_index++; } - }