Skip to content

Commit

Permalink
Merge pull request #153 from UBC-Solar/user/mjohal67/comp_array_bms_f…
Browse files Browse the repository at this point in the history
…aults

Fix: ECU-BMS FLT GPIO Checking for Array Faulting
  • Loading branch information
AarjavJain101 authored Aug 8, 2024
2 parents 9a209c4 + fa2c75d commit 96d53a8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
5 changes: 3 additions & 2 deletions components/bms/bms_master/Core/Src/bms_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,17 @@ void BMS_MAIN_driveOutputs(Pack_t *pack)
if (PACK_ANY_FAULTS_SET(pack->status) || ecu_data.status.bits.estop == true)
{
CONT_FLT_switch(true);
CONT_BAL_switch(false); // complement of above

CONT_COM_switch(pack->status.bits.fault_communications);
CONT_OT_switch(pack->status.bits.fault_over_temperature);
stopBalancing(pack);
CONT_BAL_switch(pack->status.bits.balancing_active);
CONT_FAN_PWM_set(FAN_FULL);
}
else // no fault; balance modules, drive control signals and fans
{
BAL_updateBalancing(pack); // write bal settings, send bal commands
CONT_BAL_switch(pack->status.bits.balancing_active);
// CONT_BAL_switch(pack->status.bits.balancing_active);

// HLIM active if TRIP_HLIM or TRIP_CHARGE_OT are active
CONT_HLIM_switch(pack->status.bits.hlim || pack->status.bits.charge_over_temperature_limit);
Expand Down
2 changes: 1 addition & 1 deletion components/bms/bms_master/Core/Src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void CONT_init(TIM_HandleTypeDef *timer_handle, uint32_t timer_pwm_channel)
CONT_data.timer_handle = timer_handle;
CONT_data.timer_pwm_channel = timer_pwm_channel;

CONT_BAL_switch(false);
CONT_BAL_switch(true); // high when no fault
CONT_COM_switch(false);
CONT_FLT_switch(false); // ECU expects it to be HIGH on startup
CONT_HLIM_switch(false);
Expand Down
4 changes: 1 addition & 3 deletions components/ecu/ecu_firmware/Core/Src/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,7 @@ void ECU_monitor()
/*************************
BMS Fault Checking
**************************/
if (HAL_GPIO_ReadPin(FLT_BMS_GPIO_Port, FLT_BMS_Pin) == HIGH ||
HAL_GPIO_ReadPin(COM_BMS_GPIO_Port, COM_BMS_Pin) == HIGH ||
HAL_GPIO_ReadPin(OT_BMS_GPIO_Port, OT_BMS_Pin) == HIGH)
if (HAL_GPIO_ReadPin(FLT_BMS_GPIO_Port, FLT_BMS_Pin) == HIGH && HAL_GPIO_ReadPin(BAL_BMS_GPIO_Port, BAL_BMS_Pin) == LOW)
{
FSM_state = FAULT;
return;
Expand Down
14 changes: 10 additions & 4 deletions components/ecu/ecu_firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(ESTOP_STATUS_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : BOOT1_Pin LLIM_BMS_Pin FLT_BMS_Pin COM_BMS_Pin
BAL_BMS_Pin OT_BMS_Pin */
GPIO_InitStruct.Pin = BOOT1_Pin|LLIM_BMS_Pin|FLT_BMS_Pin|COM_BMS_Pin
|BAL_BMS_Pin|OT_BMS_Pin;
/*Configure GPIO pins : BOOT1_Pin LLIM_BMS_Pin COM_BMS_Pin BAL_BMS_Pin
OT_BMS_Pin */
GPIO_InitStruct.Pin = BOOT1_Pin|LLIM_BMS_Pin|COM_BMS_Pin|BAL_BMS_Pin
|OT_BMS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
Expand All @@ -652,6 +652,12 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DOC_COC_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : FLT_BMS_Pin */
GPIO_InitStruct.Pin = FLT_BMS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(FLT_BMS_GPIO_Port, &GPIO_InitStruct);

/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
Expand Down
3 changes: 2 additions & 1 deletion components/ecu/ecu_firmware/ecu_firmware.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=LLIM_BMS
PB3.Locked=true
PB3.Signal=GPIO_Input
PB4.GPIOParameters=GPIO_Label
PB4.GPIOParameters=GPIO_PuPd,GPIO_Label
PB4.GPIO_Label=FLT_BMS
PB4.GPIO_PuPd=GPIO_PULLDOWN
PB4.Locked=true
PB4.Signal=GPIO_Input
PB5.GPIOParameters=GPIO_Label
Expand Down

0 comments on commit 96d53a8

Please sign in to comment.