Skip to content

Commit

Permalink
Changes for getting car running
Browse files Browse the repository at this point in the history
  • Loading branch information
nwdepatie committed Apr 14, 2024
1 parent 5662b9c commit e60915d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
7 changes: 4 additions & 3 deletions Core/Src/analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
24 changes: 12 additions & 12 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion Core/Src/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -161,7 +164,6 @@ int pull_voltages()
dest_index++;
}


}


Expand Down

0 comments on commit e60915d

Please sign in to comment.