Skip to content

Commit

Permalink
tmu temps and faults (#94)
Browse files Browse the repository at this point in the history
* tmu logic and faults

* updates and fixes for PR

* fixes for PR comments

* more fixes for PR
  • Loading branch information
finncorc1 authored Mar 1, 2024
1 parent e17948e commit 852cdd3
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 227 deletions.
9 changes: 9 additions & 0 deletions common/faults/fault_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,15 @@
"time_to_latch": 100,
"time_to_unlatch": 5000,
"lcd_message": "IMD Isolation Fault"
},
{
"fault_name": "tmu_power_lost",
"max": 5,
"min": 3,
"priority": "error",
"time_to_latch": 100,
"time_to_unlatch": 5000,
"lcd_message": "Poopy! TMU Power Lost!"
}

]
Expand Down
18 changes: 10 additions & 8 deletions common/faults/faults.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ uint16_t faultLatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_LATCH_TIME, PCHG
SOFTWARE_LATCH_TIME, MAX_CELLV_HIGH_LATCH_TIME, MIN_CELLV_LOW_LATCH_TIME, PACK_OVERHEAT_ORION_LATCH_TIME, INTERNAL_COMMS_LATCH_TIME, CELL_BALANCING_FOFF_LATCH_TIME, WEAK_CELL_LATCH_TIME,
LOW_CELLV_LATCH_TIME, OPEN_WIRE_LATCH_TIME, CURRENT_SENSOR_LATCH_TIME, MAX_CELLV_O5V_LATCH_TIME, CELL_ASIC_LATCH_TIME, WEAK_PACK_LATCH_TIME, FAN_MONITOR_LATCH_TIME,
THERMISTOR_LATCH_TIME, EXTERNAL_COMMS_LATCH_TIME, REDUNDANT_PSU_LATCH_TIME, HV_ISOLATION_LATCH_TIME, INPUT_PSU_LATCH_TIME, CHARGE_LIMIT_ENFORCE_LATCH_TIME, PACK_TEMP_LATCH_TIME,
PACK_TEMP_EXCEEDED_LATCH_TIME, MIN_PACK_TEMP_LATCH_TIME, IMD_LATCH_TIME, TEST_FAULT_1_LATCH_TIME, TEST_FAULT_2_LATCH_TIME, TEST_FAULT_3_LATCH_TIME, TEST_FAULT_4_LATCH_TIME,
};
PACK_TEMP_EXCEEDED_LATCH_TIME, MIN_PACK_TEMP_LATCH_TIME, IMD_LATCH_TIME, TMU_POWER_LOST_LATCH_TIME, TEST_FAULT_1_LATCH_TIME, TEST_FAULT_2_LATCH_TIME, TEST_FAULT_3_LATCH_TIME,
TEST_FAULT_4_LATCH_TIME,};
uint16_t faultULatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_UNLATCH_TIME, PCHG_IMPLAUS_UNLATCH_TIME, RTD_EXIT_UNLATCH_TIME, LEFT_MC_CONN_UNLATCH_TIME, RIGHT_MC_CONN_UNLATCH_TIME, MCU_TEMP_HIGH_UNLATCH_TIME,
LV_BAT_LOW_UNLATCH_TIME, LV_BAT_VERY_LOW_UNLATCH_TIME, LV_BAT_BMS_UNLATCH_TIME, DRIVE_FLOW_UNLATCH_TIME, APPS_WIRING_T1_UNLATCH_TIME, APPS_WIRING_T2_UNLATCH_TIME, BSE_UNLATCH_TIME,
BSPD_UNLATCH_TIME, IMPLAUS_DETECTED_UNLATCH_TIME, APPS_BRAKE_UNLATCH_TIME, DISCHARGE_LIMIT_ENFORCE_UNLATCH_TIME, CHARGER_SAFETY_RELAY_UNLATCH_TIME, INTERNAL_HARDWARE_UNLATCH_TIME, HEATSINK_THERMISTOR_UNLATCH_TIME,
SOFTWARE_UNLATCH_TIME, MAX_CELLV_HIGH_UNLATCH_TIME, MIN_CELLV_LOW_UNLATCH_TIME, PACK_OVERHEAT_ORION_UNLATCH_TIME, INTERNAL_COMMS_UNLATCH_TIME, CELL_BALANCING_FOFF_UNLATCH_TIME, WEAK_CELL_UNLATCH_TIME,
LOW_CELLV_UNLATCH_TIME, OPEN_WIRE_UNLATCH_TIME, CURRENT_SENSOR_UNLATCH_TIME, MAX_CELLV_O5V_UNLATCH_TIME, CELL_ASIC_UNLATCH_TIME, WEAK_PACK_UNLATCH_TIME, FAN_MONITOR_UNLATCH_TIME,
THERMISTOR_UNLATCH_TIME, EXTERNAL_COMMS_UNLATCH_TIME, REDUNDANT_PSU_UNLATCH_TIME, HV_ISOLATION_UNLATCH_TIME, INPUT_PSU_UNLATCH_TIME, CHARGE_LIMIT_ENFORCE_UNLATCH_TIME, PACK_TEMP_UNLATCH_TIME,
PACK_TEMP_EXCEEDED_UNLATCH_TIME, MIN_PACK_TEMP_UNLATCH_TIME, IMD_UNLATCH_TIME, TEST_FAULT_1_UNLATCH_TIME, TEST_FAULT_2_UNLATCH_TIME, TEST_FAULT_3_UNLATCH_TIME, TEST_FAULT_4_UNLATCH_TIME,
};
PACK_TEMP_EXCEEDED_UNLATCH_TIME, MIN_PACK_TEMP_UNLATCH_TIME, IMD_UNLATCH_TIME, TMU_POWER_LOST_UNLATCH_TIME, TEST_FAULT_1_UNLATCH_TIME, TEST_FAULT_2_UNLATCH_TIME, TEST_FAULT_3_UNLATCH_TIME,
TEST_FAULT_4_UNLATCH_TIME,};
//Global arrays with all faults
fault_status_t statusArray[TOTAL_NUM_FAULTS] = {
(fault_status_t){false, ID_PDU_MCU_TEMP_HIGH_FAULT},
Expand Down Expand Up @@ -81,6 +81,7 @@ fault_status_t statusArray[TOTAL_NUM_FAULTS] = {
(fault_status_t){false, ID_PACK_TEMP_EXCEEDED_FAULT},
(fault_status_t){false, ID_MIN_PACK_TEMP_FAULT},
(fault_status_t){false, ID_IMD_FAULT},
(fault_status_t){false, ID_TMU_POWER_LOST_FAULT},
(fault_status_t){false, ID_TEST_FAULT_1_FAULT},
(fault_status_t){false, ID_TEST_FAULT_2_FAULT},
(fault_status_t){false, ID_TEST_FAULT_3_FAULT},
Expand Down Expand Up @@ -131,10 +132,11 @@ fault_attributes_t faultArray[TOTAL_NUM_FAULTS] = {
(fault_attributes_t){false, false, PACK_TEMP_EXCEEDED_PRIORITY, 0, 0, PACK_TEMP_EXCEEDED_MAX, PACK_TEMP_EXCEEDED_MIN, &statusArray[41], 0, PACK_TEMP_EXCEEDED_MSG},
(fault_attributes_t){false, false, MIN_PACK_TEMP_PRIORITY, 0, 0, MIN_PACK_TEMP_MAX, MIN_PACK_TEMP_MIN, &statusArray[42], 0, MIN_PACK_TEMP_MSG},
(fault_attributes_t){false, false, IMD_PRIORITY, 0, 0, IMD_MAX, IMD_MIN, &statusArray[43], 0, IMD_MSG},
(fault_attributes_t){false, false, TEST_FAULT_1_PRIORITY, 0, 0, TEST_FAULT_1_MAX, TEST_FAULT_1_MIN, &statusArray[44], 0, TEST_FAULT_1_MSG},
(fault_attributes_t){false, false, TEST_FAULT_2_PRIORITY, 0, 0, TEST_FAULT_2_MAX, TEST_FAULT_2_MIN, &statusArray[45], 0, TEST_FAULT_2_MSG},
(fault_attributes_t){false, false, TEST_FAULT_3_PRIORITY, 0, 0, TEST_FAULT_3_MAX, TEST_FAULT_3_MIN, &statusArray[46], 0, TEST_FAULT_3_MSG},
(fault_attributes_t){false, false, TEST_FAULT_4_PRIORITY, 0, 0, TEST_FAULT_4_MAX, TEST_FAULT_4_MIN, &statusArray[47], 0, TEST_FAULT_4_MSG},
(fault_attributes_t){false, false, TMU_POWER_LOST_PRIORITY, 0, 0, TMU_POWER_LOST_MAX, TMU_POWER_LOST_MIN, &statusArray[44], 0, TMU_POWER_LOST_MSG},
(fault_attributes_t){false, false, TEST_FAULT_1_PRIORITY, 0, 0, TEST_FAULT_1_MAX, TEST_FAULT_1_MIN, &statusArray[45], 0, TEST_FAULT_1_MSG},
(fault_attributes_t){false, false, TEST_FAULT_2_PRIORITY, 0, 0, TEST_FAULT_2_MAX, TEST_FAULT_2_MIN, &statusArray[46], 0, TEST_FAULT_2_MSG},
(fault_attributes_t){false, false, TEST_FAULT_3_PRIORITY, 0, 0, TEST_FAULT_3_MAX, TEST_FAULT_3_MIN, &statusArray[47], 0, TEST_FAULT_3_MSG},
(fault_attributes_t){false, false, TEST_FAULT_4_PRIORITY, 0, 0, TEST_FAULT_4_MAX, TEST_FAULT_4_MIN, &statusArray[48], 0, TEST_FAULT_4_MSG},
};
//END AUTO FAULT INFO ARRAY DEFS

Expand Down
19 changes: 13 additions & 6 deletions common/faults/faults.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#define TOTAL_PDU_FAULTS 1
#define TOTAL_MAIN_MODULE_FAULTS 9
#define TOTAL_DASHBOARD_FAULTS 6
#define TOTAL_A_BOX_FAULTS 28
#define TOTAL_A_BOX_FAULTS 29
#define TOTAL_TEST_FAULTS 4
#define TOTAL_MCU_NUM 5
#define TOTAL_NUM_FAULTS 48
#define TOTAL_NUM_FAULTS 49
//END AUTO TOTAL DEFS

//BEGIN AUTO ID DEFS
Expand Down Expand Up @@ -74,10 +74,11 @@
#define ID_PACK_TEMP_EXCEEDED_FAULT 0x3029
#define ID_MIN_PACK_TEMP_FAULT 0x302a
#define ID_IMD_FAULT 0x302b
#define ID_TEST_FAULT_1_FAULT 0x402c
#define ID_TEST_FAULT_2_FAULT 0x402d
#define ID_TEST_FAULT_3_FAULT 0x402e
#define ID_TEST_FAULT_4_FAULT 0x402f
#define ID_TMU_POWER_LOST_FAULT 0x302c
#define ID_TEST_FAULT_1_FAULT 0x402d
#define ID_TEST_FAULT_2_FAULT 0x402e
#define ID_TEST_FAULT_3_FAULT 0x402f
#define ID_TEST_FAULT_4_FAULT 0x4030
//END AUTO ID DEFS

//Macro defs for accessing aspects of id
Expand Down Expand Up @@ -133,6 +134,7 @@
#define PACK_TEMP_EXCEEDED_PRIORITY 1
#define MIN_PACK_TEMP_PRIORITY 1
#define IMD_PRIORITY 2
#define TMU_POWER_LOST_PRIORITY 1
#define TEST_FAULT_1_PRIORITY 0
#define TEST_FAULT_2_PRIORITY 1
#define TEST_FAULT_3_PRIORITY 2
Expand Down Expand Up @@ -184,6 +186,7 @@
#define PACK_TEMP_EXCEEDED_MAX 6000
#define MIN_PACK_TEMP_MAX 10000
#define IMD_MAX 1
#define TMU_POWER_LOST_MAX 5
#define TEST_FAULT_1_MAX 1
#define TEST_FAULT_2_MAX 1
#define TEST_FAULT_3_MAX 1
Expand Down Expand Up @@ -235,6 +238,7 @@
#define PACK_TEMP_EXCEEDED_MIN 0
#define MIN_PACK_TEMP_MIN 10
#define IMD_MIN 0
#define TMU_POWER_LOST_MIN 3
#define TEST_FAULT_1_MIN 0
#define TEST_FAULT_2_MIN 0
#define TEST_FAULT_3_MIN 0
Expand Down Expand Up @@ -286,6 +290,7 @@
#define PACK_TEMP_EXCEEDED_LATCH_TIME 2000
#define MIN_PACK_TEMP_LATCH_TIME 2000
#define IMD_LATCH_TIME 100
#define TMU_POWER_LOST_LATCH_TIME 100
#define TEST_FAULT_1_LATCH_TIME 10
#define TEST_FAULT_2_LATCH_TIME 10
#define TEST_FAULT_3_LATCH_TIME 10
Expand Down Expand Up @@ -337,6 +342,7 @@
#define PACK_TEMP_EXCEEDED_UNLATCH_TIME 10000
#define MIN_PACK_TEMP_UNLATCH_TIME 10000
#define IMD_UNLATCH_TIME 5000
#define TMU_POWER_LOST_UNLATCH_TIME 5000
#define TEST_FAULT_1_UNLATCH_TIME 10
#define TEST_FAULT_2_UNLATCH_TIME 10
#define TEST_FAULT_3_UNLATCH_TIME 10
Expand Down Expand Up @@ -388,6 +394,7 @@
#define PACK_TEMP_EXCEEDED_MSG "Pack Overheating\0"
#define MIN_PACK_TEMP_MSG "Pack Minimum temp < 10\0"
#define IMD_MSG "IMD Isolation Fault\0"
#define TMU_POWER_LOST_MSG "Poopy! TMU Power Lost!\0"
#define TEST_FAULT_1_MSG "Test fault 1\0"
#define TEST_FAULT_2_MSG "Test fault 2\0"
#define TEST_FAULT_3_MSG "Test fault 3\0"
Expand Down
29 changes: 3 additions & 26 deletions source/a_box/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ extern void HardFault_Handler();
void canTxUpdate();
void heartBeatLED();
void monitorStatus();
void sendIMUData();
void imuConfigureAccel();
void preflightChecks();
void preflightAnimation();
void updateTherm();
Expand Down Expand Up @@ -199,9 +197,7 @@ int main (void)
taskCreate(monitorStatus, 50);
taskCreate(orionChargePeriodic, 50);
taskCreate(heartBeatTask, 100);
// taskCreate(updateFaults, 1);
// taskCreate(sendIMUData, 10);
taskCreate(daqPeriodic, DAQ_UPDATE_PERIOD);
taskCreate(daqPeriodic, DAQ_UPDATE_PERIOD);


taskCreateBackground(canTxUpdate);
Expand All @@ -227,11 +223,8 @@ void preflightChecks(void)
switch (state++)
{
case 0 :
if (initTMU(&tmu)) {
PHAL_FaultHandler();
}

break;
initTMU(&tmu);
break;
case 1:
initFaultLibrary(FAULT_NODE_NAME, &q_tx_can, ID_FAULT_SYNC_A_BOX);
break;
Expand Down Expand Up @@ -313,22 +306,6 @@ void monitorStatus()
PHAL_writeGPIO(BMS_STATUS_GPIO_Port, BMS_STATUS_Pin, stat);
}

void monitorTherm() {
uint8_t tmu_err;

}





// void sendIMUData()
// {
// imu_periodic(&imu_h);
// }




// *** Compulsory CAN Tx/Rx callbacks ***
void canTxUpdate()
Expand Down
Loading

0 comments on commit 852cdd3

Please sign in to comment.