From 3ad66d2e9fe89a9dc0b5aff75552ccb4a6800064 Mon Sep 17 00:00:00 2001 From: Aditya Anand <90068582+AdityaAsGithub@users.noreply.github.com> Date: Fri, 1 Mar 2024 23:52:49 -0500 Subject: [PATCH] Feature/anand89/main thermistor mux cleanup (#98) * Luke's stuff and some code * wip * Cooling loop complete * Luke's fixes --------- Co-authored-by: AdityaAsGithub --- common/daq/can_config.json | 16 +- common/daq/daq_config.json | 9 +- common/daq/per_dbc.dbc | 12 +- common/faults/fault_config.json | 104 +++++++--- common/faults/faults.c | 136 +++++++------ common/faults/faults.h | 180 ++++++++++------- source/dashboard/can/can_parse.c | 26 ++- source/dashboard/can/can_parse.h | 18 +- source/main_module/can/can_parse.c | 42 +--- source/main_module/can/can_parse.h | 61 +----- source/main_module/car/car.c | 41 ++-- source/main_module/car/car.h | 32 +-- source/main_module/cooling/cooling.c | 285 ++++++--------------------- source/main_module/cooling/cooling.h | 111 +++++------ source/main_module/daq/daq.c | 5 +- source/main_module/daq/daq.h | 37 ++-- source/main_module/main.c | 39 ++-- source/main_module/main.h | 14 +- 18 files changed, 497 insertions(+), 671 deletions(-) diff --git a/common/daq/can_config.json b/common/daq/can_config.json index a7f54140..3bbf6a32 100644 --- a/common/daq/can_config.json +++ b/common/daq/can_config.json @@ -32,17 +32,13 @@ "msg_pgn":1 }, { - "msg_name": "flowrate_temps", - "msg_desc": "Flowrate and Water temp of cooling loops", + "msg_name": "coolant_temps", + "msg_desc": "Water temp of cooling loops", "signals": [ {"sig_name": "battery_in_temp", "sig_desc":"In flow temperature of battery coolant loop", "type":"int8_t", "unit":"C"}, {"sig_name": "battery_out_temp", "sig_desc":"Out flow temperature of battery coolant loop", "type":"int8_t", "unit":"C"}, {"sig_name": "drivetrain_in_temp", "sig_desc":"In flow temperature of drivetrain coolant loop", "type":"int8_t", "unit":"C"}, - {"sig_name": "drivetrain_out_temp", "sig_desc":"Out flow temperature of drivetrain coolant loop", "type":"int8_t", "unit":"C"}, - {"sig_name": "battery_flowrate", "sig_desc": "Flow rate for battery coolant loop", "type": "uint8_t", "scale": 0.1, "unit":"LPM"}, - {"sig_name": "drivetrain_flowrate", "sig_desc": "Flow rate for drivetrain coolant loop", "type": "uint8_t", "scale": 0.1, "unit":"LPM"}, - {"sig_name": "battery_fan_speed", "sig_desc": "Speed of battery fan", "type": "uint8_t", "scale":100, "unit":"RPM"}, - {"sig_name": "drivetrain_fan_speed", "sig_desc": "Speed of drivetrain fan", "type": "uint8_t", "scale":100, "unit":"RPM"} + {"sig_name": "drivetrain_out_temp", "sig_desc":"Out flow temperature of drivetrain coolant loop", "type":"int8_t", "unit":"C"} ], "msg_period":200, "msg_hlp":1, @@ -229,9 +225,7 @@ {"msg_name": "max_cell_temp"}, {"msg_name": "LWS_Standard"}, {"msg_name": "main_module_bl_cmd" , "callback": true}, - {"msg_name": "cooling_driver_request", "callback": true}, - {"msg_name": "throttle_remapped"}, - {"msg_name": "pdu_test"} + {"msg_name": "throttle_remapped"} ] }, { @@ -708,7 +702,7 @@ {"msg_name": "precharge_hb"}, {"msg_name": "torque_request_main"}, {"msg_name": "rear_wheel_speeds"}, - {"msg_name": "flowrate_temps"}, + {"msg_name": "coolant_temps"}, {"msg_name": "coolant_out", "callback": true}, {"msg_name": "gearbox"}, {"msg_name": "dashboard_bl_cmd" , "callback": true} diff --git a/common/daq/daq_config.json b/common/daq/daq_config.json index 93fabe91..31d3fb3d 100644 --- a/common/daq/daq_config.json +++ b/common/daq/daq_config.json @@ -10,10 +10,7 @@ "node_name":"Main_Module", "includes":"#include \"cooling.h\"\n#include\"main.h\"\n#include\"car.h\"", "variables": [ - {"var_name":"dt_temp_error", "access_phrase":"cooling.dt_temp_error", "read_only": true, "type":"uint8_t", "length": 1}, - {"var_name":"bat_temp_error", "access_phrase":"cooling.bat_temp_error", "read_only": true, "type":"uint8_t", "length": 1}, {"var_name":"cal_steer_angle", "access_phrase": "calibrateSteeringAngle", "has_read_func":true, "read_only":true, "type":"uint8_t", "length": 1}, - {"var_name":"cooling_daq_override", "access_phrase": "cooling.daq_override", "read_only": false, "type":"uint8_t", "length": 1}, {"var_name":"sdc_main_status", "access_phrase": "sdc_mux.main_stat", "read_only": true, "type":"uint8_t", "length": 1}, {"var_name":"sdc_center_stop_status", "access_phrase": "sdc_mux.c_stop_stat", "read_only": true, "type":"uint8_t", "length": 1}, {"var_name":"sdc_inertia_sw_status", "access_phrase": "sdc_mux.inertia_stat", "read_only": true, "type":"uint8_t", "length": 1}, @@ -27,7 +24,11 @@ {"var_name":"sdc_rear_hub_stat", "access_phrase": "sdc_mux.r_hub_stat", "read_only": true, "type":"uint8_t", "length": 1}, {"var_name":"sdc_tsms_stat", "access_phrase": "sdc_mux.tsms_stat", "read_only": true, "type":"uint8_t", "length": 1}, {"var_name":"sdc_pchg_out_stat", "access_phrase": "sdc_mux.pchg_out_stat", "read_only": true, "type":"uint8_t", "length": 1}, - {"var_name":"daq_buzzer", "access_phrase": "daq_buzzer", "read_only": false, "type": "uint8_t", "length": 1, "unit": "%"} + {"var_name":"daq_buzzer", "access_phrase": "daq_buzzer", "read_only": false, "type": "uint8_t", "length": 1}, + {"var_name":"daq_brake", "access_phrase": "daq_brake", "read_only": false, "type": "uint8_t", "length": 1}, + {"var_name":"daq_buzzer_brake_status", "access_phrase": "buzzer_brake_fault", "read_only": false, "type": "uint8_t", "length": 1} + + ], "files":[] }, diff --git a/common/daq/per_dbc.dbc b/common/daq/per_dbc.dbc index 34544dd3..f39f0d95 100644 --- a/common/daq/per_dbc.dbc +++ b/common/daq/per_dbc.dbc @@ -46,11 +46,7 @@ BO_ 2214592577 torque_request_main: 8 Main_Module SG_ front_right : 16|16@1- (1,0) [0|0] "" Vector__XXX SG_ front_left : 0|16@1- (1,0) [0|0] "" Vector__XXX -BO_ 2214594689 flowrate_temps: 8 Main_Module - SG_ drivetrain_fan_speed : 56|8@1+ (100,0) [0|0] "RPM" Vector__XXX - SG_ battery_fan_speed : 48|8@1+ (100,0) [0|0] "RPM" Vector__XXX - SG_ drivetrain_flowrate : 40|8@1+ (0.1,0) [0|0] "LPM" Vector__XXX - SG_ battery_flowrate : 32|8@1+ (0.1,0) [0|0] "LPM" Vector__XXX +BO_ 2214594689 coolant_temps: 4 Main_Module SG_ drivetrain_out_temp : 24|8@1- (1,0) [0|0] "C" Vector__XXX SG_ drivetrain_in_temp : 16|8@1- (1,0) [0|0] "C" Vector__XXX SG_ battery_out_temp : 8|8@1- (1,0) [0|0] "C" Vector__XXX @@ -595,11 +591,7 @@ CM_ SG_ 2214592577 rear_right "torque request. -4095-4095"; CM_ SG_ 2214592577 rear_left "torque request. -4095-4095"; CM_ SG_ 2214592577 front_right "torque request. -4095-4095"; CM_ SG_ 2214592577 front_left "torque request. -4095-4095"; -CM_ BO_ 2214594689 "Flowrate and Water temp of cooling loops"; -CM_ SG_ 2214594689 drivetrain_fan_speed "Speed of drivetrain fan"; -CM_ SG_ 2214594689 battery_fan_speed "Speed of battery fan"; -CM_ SG_ 2214594689 drivetrain_flowrate "Flow rate for drivetrain coolant loop"; -CM_ SG_ 2214594689 battery_flowrate "Flow rate for battery coolant loop"; +CM_ BO_ 2214594689 "Water temp of cooling loops"; CM_ SG_ 2214594689 drivetrain_out_temp "Out flow temperature of drivetrain coolant loop"; CM_ SG_ 2214594689 drivetrain_in_temp "In flow temperature of drivetrain coolant loop"; CM_ SG_ 2214594689 battery_out_temp "Out flow temperature of battery coolant loop"; diff --git a/common/faults/fault_config.json b/common/faults/fault_config.json index 733fe71c..4a5a79a7 100644 --- a/common/faults/fault_config.json +++ b/common/faults/fault_config.json @@ -64,40 +64,94 @@ "lcd_message": "HIGH PDU MCU TEMP" }, { - "fault_name": "lv_bat_low", - "max": 34, - "min": 24, + "fault_name": "dt_l_temp_ot", + "max": 90, + "min":-100, "priority": "warning", "time_to_latch": 1000, - "time_to_unlatch": 2000, - "lcd_message": "LV Bat Getting Low" + "time_to_unlatch": 1000, + "lcd_message": "Left Gearbox Overheating" }, { - "fault_name": "lv_bat_very_low", - "max": 34, - "min": 22, - "priority": "error", + "fault_name": "dt_r_temp_ot", + "max": 90, + "min":-100, + "priority": "warning", "time_to_latch": 1000, - "time_to_unlatch": 2000, - "lcd_message": "LV Bat Very Low" + "time_to_unlatch": 1000, + "lcd_message": "Right Gearbox Overheating" }, { - "fault_name": "lv_bat_bms", - "max": 1, - "min": 0, - "priority": "error", - "time_to_latch": 50, - "time_to_unlatch": 2000, - "lcd_message": "LV Bat BMS Fault" + "fault_name": "dt_l_temp_high", + "max": 80, + "min":-100, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Left Gearbox High (>80C)" }, { - "fault_name": "drive_flow", - "max": 63, - "min": 46, - "priority": "error", - "time_to_latch": 10, - "time_to_unlatch": 10, - "lcd_message": "battery pump flow brokey" + "fault_name": "dt_r_temp_high", + "max": 80, + "min":-100, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Right Gearbox High (>80C)" + }, + { + "fault_name": "bat_cool_loop_high", + "max": 50, + "min":-100, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Batt Coolant Loop Temp High" + }, + { + "fault_name": "dt_cool_loop_high", + "max": 90, + "min":-100, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "DT Coolant Loop Temp High" + }, + { + "fault_name": "dt_r_therm_disc", + "max": 200, + "min":-30, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Right DT Therm Disconnect" + }, + { + "fault_name": "dt_l_therm_disc", + "max": 200, + "min":-30, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Left DT Therm Disconnect" + }, + { + "fault_name": "batt_cl_disc", + "max": 200, + "min":-30, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "Batt CL Therm Disc" + }, + { + "fault_name": "dt_cl_disc", + "max": 200, + "min":-30, + "priority": "warning", + "time_to_latch": 1000, + "time_to_unlatch": 1000, + "lcd_message": "DT CL Therm Disc" } ] }, diff --git a/common/faults/faults.c b/common/faults/faults.c index 80abb7a1..d8d8eef7 100644 --- a/common/faults/faults.c +++ b/common/faults/faults.c @@ -20,21 +20,23 @@ //BEGIN AUTO FAULT INFO ARRAY DEFS uint16_t faultLatchTime[TOTAL_NUM_FAULTS] = { PDU_MCU_TEMP_HIGH_LATCH_TIME, PCHG_IMPLAUS_LATCH_TIME, RTD_EXIT_LATCH_TIME, LEFT_MC_CONN_LATCH_TIME, RIGHT_MC_CONN_LATCH_TIME, MCU_TEMP_HIGH_LATCH_TIME, - LV_BAT_LOW_LATCH_TIME, LV_BAT_VERY_LOW_LATCH_TIME, LV_BAT_BMS_LATCH_TIME, DRIVE_FLOW_LATCH_TIME, APPS_WIRING_T1_LATCH_TIME, APPS_WIRING_T2_LATCH_TIME, BSE_LATCH_TIME, - BSPD_LATCH_TIME, IMPLAUS_DETECTED_LATCH_TIME, APPS_BRAKE_LATCH_TIME, DISCHARGE_LIMIT_ENFORCE_LATCH_TIME, CHARGER_SAFETY_RELAY_LATCH_TIME, INTERNAL_HARDWARE_LATCH_TIME, HEATSINK_THERMISTOR_LATCH_TIME, - 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, 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,}; + DT_L_TEMP_OT_LATCH_TIME, DT_R_TEMP_OT_LATCH_TIME, DT_L_TEMP_HIGH_LATCH_TIME, DT_R_TEMP_HIGH_LATCH_TIME, BAT_COOL_LOOP_HIGH_LATCH_TIME, DT_COOL_LOOP_HIGH_LATCH_TIME, DT_R_THERM_DISC_LATCH_TIME, + DT_L_THERM_DISC_LATCH_TIME, BATT_CL_DISC_LATCH_TIME, DT_CL_DISC_LATCH_TIME, APPS_WIRING_T1_LATCH_TIME, APPS_WIRING_T2_LATCH_TIME, BSE_LATCH_TIME, BSPD_LATCH_TIME, + IMPLAUS_DETECTED_LATCH_TIME, APPS_BRAKE_LATCH_TIME, DISCHARGE_LIMIT_ENFORCE_LATCH_TIME, CHARGER_SAFETY_RELAY_LATCH_TIME, INTERNAL_HARDWARE_LATCH_TIME, HEATSINK_THERMISTOR_LATCH_TIME, 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, 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, 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,}; + DT_L_TEMP_OT_UNLATCH_TIME, DT_R_TEMP_OT_UNLATCH_TIME, DT_L_TEMP_HIGH_UNLATCH_TIME, DT_R_TEMP_HIGH_UNLATCH_TIME, BAT_COOL_LOOP_HIGH_UNLATCH_TIME, DT_COOL_LOOP_HIGH_UNLATCH_TIME, DT_R_THERM_DISC_UNLATCH_TIME, + DT_L_THERM_DISC_UNLATCH_TIME, BATT_CL_DISC_UNLATCH_TIME, DT_CL_DISC_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, 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}, @@ -43,10 +45,16 @@ fault_status_t statusArray[TOTAL_NUM_FAULTS] = { (fault_status_t){false, ID_LEFT_MC_CONN_FAULT}, (fault_status_t){false, ID_RIGHT_MC_CONN_FAULT}, (fault_status_t){false, ID_MCU_TEMP_HIGH_FAULT}, - (fault_status_t){false, ID_LV_BAT_LOW_FAULT}, - (fault_status_t){false, ID_LV_BAT_VERY_LOW_FAULT}, - (fault_status_t){false, ID_LV_BAT_BMS_FAULT}, - (fault_status_t){false, ID_DRIVE_FLOW_FAULT}, + (fault_status_t){false, ID_DT_L_TEMP_OT_FAULT}, + (fault_status_t){false, ID_DT_R_TEMP_OT_FAULT}, + (fault_status_t){false, ID_DT_L_TEMP_HIGH_FAULT}, + (fault_status_t){false, ID_DT_R_TEMP_HIGH_FAULT}, + (fault_status_t){false, ID_BAT_COOL_LOOP_HIGH_FAULT}, + (fault_status_t){false, ID_DT_COOL_LOOP_HIGH_FAULT}, + (fault_status_t){false, ID_DT_R_THERM_DISC_FAULT}, + (fault_status_t){false, ID_DT_L_THERM_DISC_FAULT}, + (fault_status_t){false, ID_BATT_CL_DISC_FAULT}, + (fault_status_t){false, ID_DT_CL_DISC_FAULT}, (fault_status_t){false, ID_APPS_WIRING_T1_FAULT}, (fault_status_t){false, ID_APPS_WIRING_T2_FAULT}, (fault_status_t){false, ID_BSE_FAULT}, @@ -94,49 +102,55 @@ fault_attributes_t faultArray[TOTAL_NUM_FAULTS] = { (fault_attributes_t){false, false, LEFT_MC_CONN_PRIORITY, 0, 0, LEFT_MC_CONN_MAX, LEFT_MC_CONN_MIN, &statusArray[3], 0, LEFT_MC_CONN_MSG}, (fault_attributes_t){false, false, RIGHT_MC_CONN_PRIORITY, 0, 0, RIGHT_MC_CONN_MAX, RIGHT_MC_CONN_MIN, &statusArray[4], 0, RIGHT_MC_CONN_MSG}, (fault_attributes_t){false, false, MCU_TEMP_HIGH_PRIORITY, 0, 0, MCU_TEMP_HIGH_MAX, MCU_TEMP_HIGH_MIN, &statusArray[5], 0, MCU_TEMP_HIGH_MSG}, - (fault_attributes_t){false, false, LV_BAT_LOW_PRIORITY, 0, 0, LV_BAT_LOW_MAX, LV_BAT_LOW_MIN, &statusArray[6], 0, LV_BAT_LOW_MSG}, - (fault_attributes_t){false, false, LV_BAT_VERY_LOW_PRIORITY, 0, 0, LV_BAT_VERY_LOW_MAX, LV_BAT_VERY_LOW_MIN, &statusArray[7], 0, LV_BAT_VERY_LOW_MSG}, - (fault_attributes_t){false, false, LV_BAT_BMS_PRIORITY, 0, 0, LV_BAT_BMS_MAX, LV_BAT_BMS_MIN, &statusArray[8], 0, LV_BAT_BMS_MSG}, - (fault_attributes_t){false, false, DRIVE_FLOW_PRIORITY, 0, 0, DRIVE_FLOW_MAX, DRIVE_FLOW_MIN, &statusArray[9], 0, DRIVE_FLOW_MSG}, - (fault_attributes_t){false, false, APPS_WIRING_T1_PRIORITY, 0, 0, APPS_WIRING_T1_MAX, APPS_WIRING_T1_MIN, &statusArray[10], 0, APPS_WIRING_T1_MSG}, - (fault_attributes_t){false, false, APPS_WIRING_T2_PRIORITY, 0, 0, APPS_WIRING_T2_MAX, APPS_WIRING_T2_MIN, &statusArray[11], 0, APPS_WIRING_T2_MSG}, - (fault_attributes_t){false, false, BSE_PRIORITY, 0, 0, BSE_MAX, BSE_MIN, &statusArray[12], 0, BSE_MSG}, - (fault_attributes_t){false, false, BSPD_PRIORITY, 0, 0, BSPD_MAX, BSPD_MIN, &statusArray[13], 0, BSPD_MSG}, - (fault_attributes_t){false, false, IMPLAUS_DETECTED_PRIORITY, 0, 0, IMPLAUS_DETECTED_MAX, IMPLAUS_DETECTED_MIN, &statusArray[14], 0, IMPLAUS_DETECTED_MSG}, - (fault_attributes_t){false, false, APPS_BRAKE_PRIORITY, 0, 0, APPS_BRAKE_MAX, APPS_BRAKE_MIN, &statusArray[15], 0, APPS_BRAKE_MSG}, - (fault_attributes_t){false, false, DISCHARGE_LIMIT_ENFORCE_PRIORITY, 0, 0, DISCHARGE_LIMIT_ENFORCE_MAX, DISCHARGE_LIMIT_ENFORCE_MIN, &statusArray[16], 0, DISCHARGE_LIMIT_ENFORCE_MSG}, - (fault_attributes_t){false, false, CHARGER_SAFETY_RELAY_PRIORITY, 0, 0, CHARGER_SAFETY_RELAY_MAX, CHARGER_SAFETY_RELAY_MIN, &statusArray[17], 0, CHARGER_SAFETY_RELAY_MSG}, - (fault_attributes_t){false, false, INTERNAL_HARDWARE_PRIORITY, 0, 0, INTERNAL_HARDWARE_MAX, INTERNAL_HARDWARE_MIN, &statusArray[18], 0, INTERNAL_HARDWARE_MSG}, - (fault_attributes_t){false, false, HEATSINK_THERMISTOR_PRIORITY, 0, 0, HEATSINK_THERMISTOR_MAX, HEATSINK_THERMISTOR_MIN, &statusArray[19], 0, HEATSINK_THERMISTOR_MSG}, - (fault_attributes_t){false, false, SOFTWARE_PRIORITY, 0, 0, SOFTWARE_MAX, SOFTWARE_MIN, &statusArray[20], 0, SOFTWARE_MSG}, - (fault_attributes_t){false, false, MAX_CELLV_HIGH_PRIORITY, 0, 0, MAX_CELLV_HIGH_MAX, MAX_CELLV_HIGH_MIN, &statusArray[21], 0, MAX_CELLV_HIGH_MSG}, - (fault_attributes_t){false, false, MIN_CELLV_LOW_PRIORITY, 0, 0, MIN_CELLV_LOW_MAX, MIN_CELLV_LOW_MIN, &statusArray[22], 0, MIN_CELLV_LOW_MSG}, - (fault_attributes_t){false, false, PACK_OVERHEAT_ORION_PRIORITY, 0, 0, PACK_OVERHEAT_ORION_MAX, PACK_OVERHEAT_ORION_MIN, &statusArray[23], 0, PACK_OVERHEAT_ORION_MSG}, - (fault_attributes_t){false, false, INTERNAL_COMMS_PRIORITY, 0, 0, INTERNAL_COMMS_MAX, INTERNAL_COMMS_MIN, &statusArray[24], 0, INTERNAL_COMMS_MSG}, - (fault_attributes_t){false, false, CELL_BALANCING_FOFF_PRIORITY, 0, 0, CELL_BALANCING_FOFF_MAX, CELL_BALANCING_FOFF_MIN, &statusArray[25], 0, CELL_BALANCING_FOFF_MSG}, - (fault_attributes_t){false, false, WEAK_CELL_PRIORITY, 0, 0, WEAK_CELL_MAX, WEAK_CELL_MIN, &statusArray[26], 0, WEAK_CELL_MSG}, - (fault_attributes_t){false, false, LOW_CELLV_PRIORITY, 0, 0, LOW_CELLV_MAX, LOW_CELLV_MIN, &statusArray[27], 0, LOW_CELLV_MSG}, - (fault_attributes_t){false, false, OPEN_WIRE_PRIORITY, 0, 0, OPEN_WIRE_MAX, OPEN_WIRE_MIN, &statusArray[28], 0, OPEN_WIRE_MSG}, - (fault_attributes_t){false, false, CURRENT_SENSOR_PRIORITY, 0, 0, CURRENT_SENSOR_MAX, CURRENT_SENSOR_MIN, &statusArray[29], 0, CURRENT_SENSOR_MSG}, - (fault_attributes_t){false, false, MAX_CELLV_O5V_PRIORITY, 0, 0, MAX_CELLV_O5V_MAX, MAX_CELLV_O5V_MIN, &statusArray[30], 0, MAX_CELLV_O5V_MSG}, - (fault_attributes_t){false, false, CELL_ASIC_PRIORITY, 0, 0, CELL_ASIC_MAX, CELL_ASIC_MIN, &statusArray[31], 0, CELL_ASIC_MSG}, - (fault_attributes_t){false, false, WEAK_PACK_PRIORITY, 0, 0, WEAK_PACK_MAX, WEAK_PACK_MIN, &statusArray[32], 0, WEAK_PACK_MSG}, - (fault_attributes_t){false, false, FAN_MONITOR_PRIORITY, 0, 0, FAN_MONITOR_MAX, FAN_MONITOR_MIN, &statusArray[33], 0, FAN_MONITOR_MSG}, - (fault_attributes_t){false, false, THERMISTOR_PRIORITY, 0, 0, THERMISTOR_MAX, THERMISTOR_MIN, &statusArray[34], 0, THERMISTOR_MSG}, - (fault_attributes_t){false, false, EXTERNAL_COMMS_PRIORITY, 0, 0, EXTERNAL_COMMS_MAX, EXTERNAL_COMMS_MIN, &statusArray[35], 0, EXTERNAL_COMMS_MSG}, - (fault_attributes_t){false, false, REDUNDANT_PSU_PRIORITY, 0, 0, REDUNDANT_PSU_MAX, REDUNDANT_PSU_MIN, &statusArray[36], 0, REDUNDANT_PSU_MSG}, - (fault_attributes_t){false, false, HV_ISOLATION_PRIORITY, 0, 0, HV_ISOLATION_MAX, HV_ISOLATION_MIN, &statusArray[37], 0, HV_ISOLATION_MSG}, - (fault_attributes_t){false, false, INPUT_PSU_PRIORITY, 0, 0, INPUT_PSU_MAX, INPUT_PSU_MIN, &statusArray[38], 0, INPUT_PSU_MSG}, - (fault_attributes_t){false, false, CHARGE_LIMIT_ENFORCE_PRIORITY, 0, 0, CHARGE_LIMIT_ENFORCE_MAX, CHARGE_LIMIT_ENFORCE_MIN, &statusArray[39], 0, CHARGE_LIMIT_ENFORCE_MSG}, - (fault_attributes_t){false, false, PACK_TEMP_PRIORITY, 0, 0, PACK_TEMP_MAX, PACK_TEMP_MIN, &statusArray[40], 0, PACK_TEMP_MSG}, - (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, 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}, + (fault_attributes_t){false, false, DT_L_TEMP_OT_PRIORITY, 0, 0, DT_L_TEMP_OT_MAX, DT_L_TEMP_OT_MIN, &statusArray[6], 0, DT_L_TEMP_OT_MSG}, + (fault_attributes_t){false, false, DT_R_TEMP_OT_PRIORITY, 0, 0, DT_R_TEMP_OT_MAX, DT_R_TEMP_OT_MIN, &statusArray[7], 0, DT_R_TEMP_OT_MSG}, + (fault_attributes_t){false, false, DT_L_TEMP_HIGH_PRIORITY, 0, 0, DT_L_TEMP_HIGH_MAX, DT_L_TEMP_HIGH_MIN, &statusArray[8], 0, DT_L_TEMP_HIGH_MSG}, + (fault_attributes_t){false, false, DT_R_TEMP_HIGH_PRIORITY, 0, 0, DT_R_TEMP_HIGH_MAX, DT_R_TEMP_HIGH_MIN, &statusArray[9], 0, DT_R_TEMP_HIGH_MSG}, + (fault_attributes_t){false, false, BAT_COOL_LOOP_HIGH_PRIORITY, 0, 0, BAT_COOL_LOOP_HIGH_MAX, BAT_COOL_LOOP_HIGH_MIN, &statusArray[10], 0, BAT_COOL_LOOP_HIGH_MSG}, + (fault_attributes_t){false, false, DT_COOL_LOOP_HIGH_PRIORITY, 0, 0, DT_COOL_LOOP_HIGH_MAX, DT_COOL_LOOP_HIGH_MIN, &statusArray[11], 0, DT_COOL_LOOP_HIGH_MSG}, + (fault_attributes_t){false, false, DT_R_THERM_DISC_PRIORITY, 0, 0, DT_R_THERM_DISC_MAX, DT_R_THERM_DISC_MIN, &statusArray[12], 0, DT_R_THERM_DISC_MSG}, + (fault_attributes_t){false, false, DT_L_THERM_DISC_PRIORITY, 0, 0, DT_L_THERM_DISC_MAX, DT_L_THERM_DISC_MIN, &statusArray[13], 0, DT_L_THERM_DISC_MSG}, + (fault_attributes_t){false, false, BATT_CL_DISC_PRIORITY, 0, 0, BATT_CL_DISC_MAX, BATT_CL_DISC_MIN, &statusArray[14], 0, BATT_CL_DISC_MSG}, + (fault_attributes_t){false, false, DT_CL_DISC_PRIORITY, 0, 0, DT_CL_DISC_MAX, DT_CL_DISC_MIN, &statusArray[15], 0, DT_CL_DISC_MSG}, + (fault_attributes_t){false, false, APPS_WIRING_T1_PRIORITY, 0, 0, APPS_WIRING_T1_MAX, APPS_WIRING_T1_MIN, &statusArray[16], 0, APPS_WIRING_T1_MSG}, + (fault_attributes_t){false, false, APPS_WIRING_T2_PRIORITY, 0, 0, APPS_WIRING_T2_MAX, APPS_WIRING_T2_MIN, &statusArray[17], 0, APPS_WIRING_T2_MSG}, + (fault_attributes_t){false, false, BSE_PRIORITY, 0, 0, BSE_MAX, BSE_MIN, &statusArray[18], 0, BSE_MSG}, + (fault_attributes_t){false, false, BSPD_PRIORITY, 0, 0, BSPD_MAX, BSPD_MIN, &statusArray[19], 0, BSPD_MSG}, + (fault_attributes_t){false, false, IMPLAUS_DETECTED_PRIORITY, 0, 0, IMPLAUS_DETECTED_MAX, IMPLAUS_DETECTED_MIN, &statusArray[20], 0, IMPLAUS_DETECTED_MSG}, + (fault_attributes_t){false, false, APPS_BRAKE_PRIORITY, 0, 0, APPS_BRAKE_MAX, APPS_BRAKE_MIN, &statusArray[21], 0, APPS_BRAKE_MSG}, + (fault_attributes_t){false, false, DISCHARGE_LIMIT_ENFORCE_PRIORITY, 0, 0, DISCHARGE_LIMIT_ENFORCE_MAX, DISCHARGE_LIMIT_ENFORCE_MIN, &statusArray[22], 0, DISCHARGE_LIMIT_ENFORCE_MSG}, + (fault_attributes_t){false, false, CHARGER_SAFETY_RELAY_PRIORITY, 0, 0, CHARGER_SAFETY_RELAY_MAX, CHARGER_SAFETY_RELAY_MIN, &statusArray[23], 0, CHARGER_SAFETY_RELAY_MSG}, + (fault_attributes_t){false, false, INTERNAL_HARDWARE_PRIORITY, 0, 0, INTERNAL_HARDWARE_MAX, INTERNAL_HARDWARE_MIN, &statusArray[24], 0, INTERNAL_HARDWARE_MSG}, + (fault_attributes_t){false, false, HEATSINK_THERMISTOR_PRIORITY, 0, 0, HEATSINK_THERMISTOR_MAX, HEATSINK_THERMISTOR_MIN, &statusArray[25], 0, HEATSINK_THERMISTOR_MSG}, + (fault_attributes_t){false, false, SOFTWARE_PRIORITY, 0, 0, SOFTWARE_MAX, SOFTWARE_MIN, &statusArray[26], 0, SOFTWARE_MSG}, + (fault_attributes_t){false, false, MAX_CELLV_HIGH_PRIORITY, 0, 0, MAX_CELLV_HIGH_MAX, MAX_CELLV_HIGH_MIN, &statusArray[27], 0, MAX_CELLV_HIGH_MSG}, + (fault_attributes_t){false, false, MIN_CELLV_LOW_PRIORITY, 0, 0, MIN_CELLV_LOW_MAX, MIN_CELLV_LOW_MIN, &statusArray[28], 0, MIN_CELLV_LOW_MSG}, + (fault_attributes_t){false, false, PACK_OVERHEAT_ORION_PRIORITY, 0, 0, PACK_OVERHEAT_ORION_MAX, PACK_OVERHEAT_ORION_MIN, &statusArray[29], 0, PACK_OVERHEAT_ORION_MSG}, + (fault_attributes_t){false, false, INTERNAL_COMMS_PRIORITY, 0, 0, INTERNAL_COMMS_MAX, INTERNAL_COMMS_MIN, &statusArray[30], 0, INTERNAL_COMMS_MSG}, + (fault_attributes_t){false, false, CELL_BALANCING_FOFF_PRIORITY, 0, 0, CELL_BALANCING_FOFF_MAX, CELL_BALANCING_FOFF_MIN, &statusArray[31], 0, CELL_BALANCING_FOFF_MSG}, + (fault_attributes_t){false, false, WEAK_CELL_PRIORITY, 0, 0, WEAK_CELL_MAX, WEAK_CELL_MIN, &statusArray[32], 0, WEAK_CELL_MSG}, + (fault_attributes_t){false, false, LOW_CELLV_PRIORITY, 0, 0, LOW_CELLV_MAX, LOW_CELLV_MIN, &statusArray[33], 0, LOW_CELLV_MSG}, + (fault_attributes_t){false, false, OPEN_WIRE_PRIORITY, 0, 0, OPEN_WIRE_MAX, OPEN_WIRE_MIN, &statusArray[34], 0, OPEN_WIRE_MSG}, + (fault_attributes_t){false, false, CURRENT_SENSOR_PRIORITY, 0, 0, CURRENT_SENSOR_MAX, CURRENT_SENSOR_MIN, &statusArray[35], 0, CURRENT_SENSOR_MSG}, + (fault_attributes_t){false, false, MAX_CELLV_O5V_PRIORITY, 0, 0, MAX_CELLV_O5V_MAX, MAX_CELLV_O5V_MIN, &statusArray[36], 0, MAX_CELLV_O5V_MSG}, + (fault_attributes_t){false, false, CELL_ASIC_PRIORITY, 0, 0, CELL_ASIC_MAX, CELL_ASIC_MIN, &statusArray[37], 0, CELL_ASIC_MSG}, + (fault_attributes_t){false, false, WEAK_PACK_PRIORITY, 0, 0, WEAK_PACK_MAX, WEAK_PACK_MIN, &statusArray[38], 0, WEAK_PACK_MSG}, + (fault_attributes_t){false, false, FAN_MONITOR_PRIORITY, 0, 0, FAN_MONITOR_MAX, FAN_MONITOR_MIN, &statusArray[39], 0, FAN_MONITOR_MSG}, + (fault_attributes_t){false, false, THERMISTOR_PRIORITY, 0, 0, THERMISTOR_MAX, THERMISTOR_MIN, &statusArray[40], 0, THERMISTOR_MSG}, + (fault_attributes_t){false, false, EXTERNAL_COMMS_PRIORITY, 0, 0, EXTERNAL_COMMS_MAX, EXTERNAL_COMMS_MIN, &statusArray[41], 0, EXTERNAL_COMMS_MSG}, + (fault_attributes_t){false, false, REDUNDANT_PSU_PRIORITY, 0, 0, REDUNDANT_PSU_MAX, REDUNDANT_PSU_MIN, &statusArray[42], 0, REDUNDANT_PSU_MSG}, + (fault_attributes_t){false, false, HV_ISOLATION_PRIORITY, 0, 0, HV_ISOLATION_MAX, HV_ISOLATION_MIN, &statusArray[43], 0, HV_ISOLATION_MSG}, + (fault_attributes_t){false, false, INPUT_PSU_PRIORITY, 0, 0, INPUT_PSU_MAX, INPUT_PSU_MIN, &statusArray[44], 0, INPUT_PSU_MSG}, + (fault_attributes_t){false, false, CHARGE_LIMIT_ENFORCE_PRIORITY, 0, 0, CHARGE_LIMIT_ENFORCE_MAX, CHARGE_LIMIT_ENFORCE_MIN, &statusArray[45], 0, CHARGE_LIMIT_ENFORCE_MSG}, + (fault_attributes_t){false, false, PACK_TEMP_PRIORITY, 0, 0, PACK_TEMP_MAX, PACK_TEMP_MIN, &statusArray[46], 0, PACK_TEMP_MSG}, + (fault_attributes_t){false, false, PACK_TEMP_EXCEEDED_PRIORITY, 0, 0, PACK_TEMP_EXCEEDED_MAX, PACK_TEMP_EXCEEDED_MIN, &statusArray[47], 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[48], 0, MIN_PACK_TEMP_MSG}, + (fault_attributes_t){false, false, IMD_PRIORITY, 0, 0, IMD_MAX, IMD_MIN, &statusArray[49], 0, IMD_MSG}, + (fault_attributes_t){false, false, TMU_POWER_LOST_PRIORITY, 0, 0, TMU_POWER_LOST_MAX, TMU_POWER_LOST_MIN, &statusArray[50], 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[51], 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[52], 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[53], 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[54], 0, TEST_FAULT_4_MSG}, }; //END AUTO FAULT INFO ARRAY DEFS diff --git a/common/faults/faults.h b/common/faults/faults.h index 1934cb8d..9947387b 100644 --- a/common/faults/faults.h +++ b/common/faults/faults.h @@ -21,12 +21,12 @@ //BEGIN AUTO TOTAL DEFS #define TOTAL_PDU_FAULTS 1 -#define TOTAL_MAIN_MODULE_FAULTS 9 +#define TOTAL_MAIN_MODULE_FAULTS 15 #define TOTAL_DASHBOARD_FAULTS 6 #define TOTAL_A_BOX_FAULTS 29 #define TOTAL_TEST_FAULTS 4 #define TOTAL_MCU_NUM 5 -#define TOTAL_NUM_FAULTS 49 +#define TOTAL_NUM_FAULTS 55 //END AUTO TOTAL DEFS //BEGIN AUTO ID DEFS @@ -36,49 +36,55 @@ #define ID_LEFT_MC_CONN_FAULT 0x1003 #define ID_RIGHT_MC_CONN_FAULT 0x1004 #define ID_MCU_TEMP_HIGH_FAULT 0x1005 -#define ID_LV_BAT_LOW_FAULT 0x1006 -#define ID_LV_BAT_VERY_LOW_FAULT 0x1007 -#define ID_LV_BAT_BMS_FAULT 0x1008 -#define ID_DRIVE_FLOW_FAULT 0x1009 -#define ID_APPS_WIRING_T1_FAULT 0x200a -#define ID_APPS_WIRING_T2_FAULT 0x200b -#define ID_BSE_FAULT 0x200c -#define ID_BSPD_FAULT 0x200d -#define ID_IMPLAUS_DETECTED_FAULT 0x200e -#define ID_APPS_BRAKE_FAULT 0x200f -#define ID_DISCHARGE_LIMIT_ENFORCE_FAULT 0x3010 -#define ID_CHARGER_SAFETY_RELAY_FAULT 0x3011 -#define ID_INTERNAL_HARDWARE_FAULT 0x3012 -#define ID_HEATSINK_THERMISTOR_FAULT 0x3013 -#define ID_SOFTWARE_FAULT 0x3014 -#define ID_MAX_CELLV_HIGH_FAULT 0x3015 -#define ID_MIN_CELLV_LOW_FAULT 0x3016 -#define ID_PACK_OVERHEAT_ORION_FAULT 0x3017 -#define ID_INTERNAL_COMMS_FAULT 0x3018 -#define ID_CELL_BALANCING_FOFF_FAULT 0x3019 -#define ID_WEAK_CELL_FAULT 0x301a -#define ID_LOW_CELLV_FAULT 0x301b -#define ID_OPEN_WIRE_FAULT 0x301c -#define ID_CURRENT_SENSOR_FAULT 0x301d -#define ID_MAX_CELLV_O5V_FAULT 0x301e -#define ID_CELL_ASIC_FAULT 0x301f -#define ID_WEAK_PACK_FAULT 0x3020 -#define ID_FAN_MONITOR_FAULT 0x3021 -#define ID_THERMISTOR_FAULT 0x3022 -#define ID_EXTERNAL_COMMS_FAULT 0x3023 -#define ID_REDUNDANT_PSU_FAULT 0x3024 -#define ID_HV_ISOLATION_FAULT 0x3025 -#define ID_INPUT_PSU_FAULT 0x3026 -#define ID_CHARGE_LIMIT_ENFORCE_FAULT 0x3027 -#define ID_PACK_TEMP_FAULT 0x3028 -#define ID_PACK_TEMP_EXCEEDED_FAULT 0x3029 -#define ID_MIN_PACK_TEMP_FAULT 0x302a -#define ID_IMD_FAULT 0x302b -#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 +#define ID_DT_L_TEMP_OT_FAULT 0x1006 +#define ID_DT_R_TEMP_OT_FAULT 0x1007 +#define ID_DT_L_TEMP_HIGH_FAULT 0x1008 +#define ID_DT_R_TEMP_HIGH_FAULT 0x1009 +#define ID_BAT_COOL_LOOP_HIGH_FAULT 0x100a +#define ID_DT_COOL_LOOP_HIGH_FAULT 0x100b +#define ID_DT_R_THERM_DISC_FAULT 0x100c +#define ID_DT_L_THERM_DISC_FAULT 0x100d +#define ID_BATT_CL_DISC_FAULT 0x100e +#define ID_DT_CL_DISC_FAULT 0x100f +#define ID_APPS_WIRING_T1_FAULT 0x2010 +#define ID_APPS_WIRING_T2_FAULT 0x2011 +#define ID_BSE_FAULT 0x2012 +#define ID_BSPD_FAULT 0x2013 +#define ID_IMPLAUS_DETECTED_FAULT 0x2014 +#define ID_APPS_BRAKE_FAULT 0x2015 +#define ID_DISCHARGE_LIMIT_ENFORCE_FAULT 0x3016 +#define ID_CHARGER_SAFETY_RELAY_FAULT 0x3017 +#define ID_INTERNAL_HARDWARE_FAULT 0x3018 +#define ID_HEATSINK_THERMISTOR_FAULT 0x3019 +#define ID_SOFTWARE_FAULT 0x301a +#define ID_MAX_CELLV_HIGH_FAULT 0x301b +#define ID_MIN_CELLV_LOW_FAULT 0x301c +#define ID_PACK_OVERHEAT_ORION_FAULT 0x301d +#define ID_INTERNAL_COMMS_FAULT 0x301e +#define ID_CELL_BALANCING_FOFF_FAULT 0x301f +#define ID_WEAK_CELL_FAULT 0x3020 +#define ID_LOW_CELLV_FAULT 0x3021 +#define ID_OPEN_WIRE_FAULT 0x3022 +#define ID_CURRENT_SENSOR_FAULT 0x3023 +#define ID_MAX_CELLV_O5V_FAULT 0x3024 +#define ID_CELL_ASIC_FAULT 0x3025 +#define ID_WEAK_PACK_FAULT 0x3026 +#define ID_FAN_MONITOR_FAULT 0x3027 +#define ID_THERMISTOR_FAULT 0x3028 +#define ID_EXTERNAL_COMMS_FAULT 0x3029 +#define ID_REDUNDANT_PSU_FAULT 0x302a +#define ID_HV_ISOLATION_FAULT 0x302b +#define ID_INPUT_PSU_FAULT 0x302c +#define ID_CHARGE_LIMIT_ENFORCE_FAULT 0x302d +#define ID_PACK_TEMP_FAULT 0x302e +#define ID_PACK_TEMP_EXCEEDED_FAULT 0x302f +#define ID_MIN_PACK_TEMP_FAULT 0x3030 +#define ID_IMD_FAULT 0x3031 +#define ID_TMU_POWER_LOST_FAULT 0x3032 +#define ID_TEST_FAULT_1_FAULT 0x4033 +#define ID_TEST_FAULT_2_FAULT 0x4034 +#define ID_TEST_FAULT_3_FAULT 0x4035 +#define ID_TEST_FAULT_4_FAULT 0x4036 //END AUTO ID DEFS //Macro defs for accessing aspects of id @@ -96,10 +102,16 @@ #define LEFT_MC_CONN_PRIORITY 1 #define RIGHT_MC_CONN_PRIORITY 1 #define MCU_TEMP_HIGH_PRIORITY 0 -#define LV_BAT_LOW_PRIORITY 0 -#define LV_BAT_VERY_LOW_PRIORITY 1 -#define LV_BAT_BMS_PRIORITY 1 -#define DRIVE_FLOW_PRIORITY 1 +#define DT_L_TEMP_OT_PRIORITY 0 +#define DT_R_TEMP_OT_PRIORITY 0 +#define DT_L_TEMP_HIGH_PRIORITY 0 +#define DT_R_TEMP_HIGH_PRIORITY 0 +#define BAT_COOL_LOOP_HIGH_PRIORITY 0 +#define DT_COOL_LOOP_HIGH_PRIORITY 0 +#define DT_R_THERM_DISC_PRIORITY 0 +#define DT_L_THERM_DISC_PRIORITY 0 +#define BATT_CL_DISC_PRIORITY 0 +#define DT_CL_DISC_PRIORITY 0 #define APPS_WIRING_T1_PRIORITY 1 #define APPS_WIRING_T2_PRIORITY 1 #define BSE_PRIORITY 1 @@ -148,10 +160,16 @@ #define LEFT_MC_CONN_MAX 1 #define RIGHT_MC_CONN_MAX 1 #define MCU_TEMP_HIGH_MAX 50 -#define LV_BAT_LOW_MAX 34 -#define LV_BAT_VERY_LOW_MAX 34 -#define LV_BAT_BMS_MAX 1 -#define DRIVE_FLOW_MAX 63 +#define DT_L_TEMP_OT_MAX 90 +#define DT_R_TEMP_OT_MAX 90 +#define DT_L_TEMP_HIGH_MAX 80 +#define DT_R_TEMP_HIGH_MAX 80 +#define BAT_COOL_LOOP_HIGH_MAX 50 +#define DT_COOL_LOOP_HIGH_MAX 90 +#define DT_R_THERM_DISC_MAX 200 +#define DT_L_THERM_DISC_MAX 200 +#define BATT_CL_DISC_MAX 200 +#define DT_CL_DISC_MAX 200 #define APPS_WIRING_T1_MAX 3000 #define APPS_WIRING_T2_MAX 3000 #define BSE_MAX 1 @@ -200,10 +218,16 @@ #define LEFT_MC_CONN_MIN 0 #define RIGHT_MC_CONN_MIN 0 #define MCU_TEMP_HIGH_MIN 0 -#define LV_BAT_LOW_MIN 24 -#define LV_BAT_VERY_LOW_MIN 22 -#define LV_BAT_BMS_MIN 0 -#define DRIVE_FLOW_MIN 46 +#define DT_L_TEMP_OT_MIN -100 +#define DT_R_TEMP_OT_MIN -100 +#define DT_L_TEMP_HIGH_MIN -100 +#define DT_R_TEMP_HIGH_MIN -100 +#define BAT_COOL_LOOP_HIGH_MIN -100 +#define DT_COOL_LOOP_HIGH_MIN -100 +#define DT_R_THERM_DISC_MIN -30 +#define DT_L_THERM_DISC_MIN -30 +#define BATT_CL_DISC_MIN -30 +#define DT_CL_DISC_MIN -30 #define APPS_WIRING_T1_MIN 200 #define APPS_WIRING_T2_MIN 200 #define BSE_MIN 0 @@ -252,10 +276,16 @@ #define LEFT_MC_CONN_LATCH_TIME 3000 #define RIGHT_MC_CONN_LATCH_TIME 3000 #define MCU_TEMP_HIGH_LATCH_TIME 1000 -#define LV_BAT_LOW_LATCH_TIME 1000 -#define LV_BAT_VERY_LOW_LATCH_TIME 1000 -#define LV_BAT_BMS_LATCH_TIME 50 -#define DRIVE_FLOW_LATCH_TIME 10 +#define DT_L_TEMP_OT_LATCH_TIME 1000 +#define DT_R_TEMP_OT_LATCH_TIME 1000 +#define DT_L_TEMP_HIGH_LATCH_TIME 1000 +#define DT_R_TEMP_HIGH_LATCH_TIME 1000 +#define BAT_COOL_LOOP_HIGH_LATCH_TIME 1000 +#define DT_COOL_LOOP_HIGH_LATCH_TIME 1000 +#define DT_R_THERM_DISC_LATCH_TIME 1000 +#define DT_L_THERM_DISC_LATCH_TIME 1000 +#define BATT_CL_DISC_LATCH_TIME 1000 +#define DT_CL_DISC_LATCH_TIME 1000 #define APPS_WIRING_T1_LATCH_TIME 10 #define APPS_WIRING_T2_LATCH_TIME 10 #define BSE_LATCH_TIME 100 @@ -304,10 +334,16 @@ #define LEFT_MC_CONN_UNLATCH_TIME 1000 #define RIGHT_MC_CONN_UNLATCH_TIME 1000 #define MCU_TEMP_HIGH_UNLATCH_TIME 2000 -#define LV_BAT_LOW_UNLATCH_TIME 2000 -#define LV_BAT_VERY_LOW_UNLATCH_TIME 2000 -#define LV_BAT_BMS_UNLATCH_TIME 2000 -#define DRIVE_FLOW_UNLATCH_TIME 10 +#define DT_L_TEMP_OT_UNLATCH_TIME 1000 +#define DT_R_TEMP_OT_UNLATCH_TIME 1000 +#define DT_L_TEMP_HIGH_UNLATCH_TIME 1000 +#define DT_R_TEMP_HIGH_UNLATCH_TIME 1000 +#define BAT_COOL_LOOP_HIGH_UNLATCH_TIME 1000 +#define DT_COOL_LOOP_HIGH_UNLATCH_TIME 1000 +#define DT_R_THERM_DISC_UNLATCH_TIME 1000 +#define DT_L_THERM_DISC_UNLATCH_TIME 1000 +#define BATT_CL_DISC_UNLATCH_TIME 1000 +#define DT_CL_DISC_UNLATCH_TIME 1000 #define APPS_WIRING_T1_UNLATCH_TIME 1000 #define APPS_WIRING_T2_UNLATCH_TIME 1000 #define BSE_UNLATCH_TIME 1000 @@ -356,10 +392,16 @@ #define LEFT_MC_CONN_MSG "LEFT MC CONN FAIL\0" #define RIGHT_MC_CONN_MSG "RIGHT MC CONN FAIL\0" #define MCU_TEMP_HIGH_MSG "HIGH PDU MCU TEMP\0" -#define LV_BAT_LOW_MSG "LV Bat Getting Low\0" -#define LV_BAT_VERY_LOW_MSG "LV Bat Very Low\0" -#define LV_BAT_BMS_MSG "LV Bat BMS Fault\0" -#define DRIVE_FLOW_MSG "battery pump flow brokey\0" +#define DT_L_TEMP_OT_MSG "Left Gearbox Overheating\0" +#define DT_R_TEMP_OT_MSG "Right Gearbox Overheating\0" +#define DT_L_TEMP_HIGH_MSG "Left Gearbox High (>80C)\0" +#define DT_R_TEMP_HIGH_MSG "Right Gearbox High (>80C)\0" +#define BAT_COOL_LOOP_HIGH_MSG "Batt Coolant Loop Temp High\0" +#define DT_COOL_LOOP_HIGH_MSG "DT Coolant Loop Temp High\0" +#define DT_R_THERM_DISC_MSG "Right DT Therm Disconnect\0" +#define DT_L_THERM_DISC_MSG "Left DT Therm Disconnect\0" +#define BATT_CL_DISC_MSG "Batt CL Therm Disc\0" +#define DT_CL_DISC_MSG "DT CL Therm Disc\0" #define APPS_WIRING_T1_MSG "APPS Wiring Fail T1\0" #define APPS_WIRING_T2_MSG "APPS Wiring Fail T2\0" #define BSE_MSG "Brake Wiring Fail (BSE)\0" diff --git a/source/dashboard/can/can_parse.c b/source/dashboard/can/can_parse.c index 2e004524..1c8595b2 100644 --- a/source/dashboard/can/can_parse.c +++ b/source/dashboard/can/can_parse.c @@ -148,17 +148,13 @@ void canRxUpdate() can_data.rear_wheel_speeds.stale = 0; can_data.rear_wheel_speeds.last_rx = sched.os_ticks; break; - case ID_FLOWRATE_TEMPS: - can_data.flowrate_temps.battery_in_temp = (int8_t) msg_data_a->flowrate_temps.battery_in_temp; - can_data.flowrate_temps.battery_out_temp = (int8_t) msg_data_a->flowrate_temps.battery_out_temp; - can_data.flowrate_temps.drivetrain_in_temp = (int8_t) msg_data_a->flowrate_temps.drivetrain_in_temp; - can_data.flowrate_temps.drivetrain_out_temp = (int8_t) msg_data_a->flowrate_temps.drivetrain_out_temp; - can_data.flowrate_temps.battery_flowrate = msg_data_a->flowrate_temps.battery_flowrate; - can_data.flowrate_temps.drivetrain_flowrate = msg_data_a->flowrate_temps.drivetrain_flowrate; - can_data.flowrate_temps.battery_fan_speed = msg_data_a->flowrate_temps.battery_fan_speed; - can_data.flowrate_temps.drivetrain_fan_speed = msg_data_a->flowrate_temps.drivetrain_fan_speed; - can_data.flowrate_temps.stale = 0; - can_data.flowrate_temps.last_rx = sched.os_ticks; + case ID_COOLANT_TEMPS: + can_data.coolant_temps.battery_in_temp = (int8_t) msg_data_a->coolant_temps.battery_in_temp; + can_data.coolant_temps.battery_out_temp = (int8_t) msg_data_a->coolant_temps.battery_out_temp; + can_data.coolant_temps.drivetrain_in_temp = (int8_t) msg_data_a->coolant_temps.drivetrain_in_temp; + can_data.coolant_temps.drivetrain_out_temp = (int8_t) msg_data_a->coolant_temps.drivetrain_out_temp; + can_data.coolant_temps.stale = 0; + can_data.coolant_temps.last_rx = sched.os_ticks; break; case ID_COOLANT_OUT: can_data.coolant_out.bat_fan = msg_data_a->coolant_out.bat_fan; @@ -251,9 +247,9 @@ void canRxUpdate() CHECK_STALE(can_data.rear_wheel_speeds.stale, sched.os_ticks, can_data.rear_wheel_speeds.last_rx, UP_REAR_WHEEL_SPEEDS); - CHECK_STALE(can_data.flowrate_temps.stale, - sched.os_ticks, can_data.flowrate_temps.last_rx, - UP_FLOWRATE_TEMPS); + CHECK_STALE(can_data.coolant_temps.stale, + sched.os_ticks, can_data.coolant_temps.last_rx, + UP_COOLANT_TEMPS); CHECK_STALE(can_data.coolant_out.stale, sched.os_ticks, can_data.coolant_out.last_rx, UP_COOLANT_OUT); @@ -293,7 +289,7 @@ bool initCANFilter() CAN1->sFilterRegister[4].FR1 = (ID_TORQUE_REQUEST_MAIN << 3) | 4; CAN1->sFilterRegister[4].FR2 = (ID_REAR_WHEEL_SPEEDS << 3) | 4; CAN1->FA1R |= (1 << 5); // configure bank 5 - CAN1->sFilterRegister[5].FR1 = (ID_FLOWRATE_TEMPS << 3) | 4; + CAN1->sFilterRegister[5].FR1 = (ID_COOLANT_TEMPS << 3) | 4; CAN1->sFilterRegister[5].FR2 = (ID_COOLANT_OUT << 3) | 4; CAN1->FA1R |= (1 << 6); // configure bank 6 CAN1->sFilterRegister[6].FR1 = (ID_GEARBOX << 3) | 4; diff --git a/source/dashboard/can/can_parse.h b/source/dashboard/can/can_parse.h index a26de27b..6f5b79cd 100644 --- a/source/dashboard/can/can_parse.h +++ b/source/dashboard/can/can_parse.h @@ -38,7 +38,7 @@ #define ID_PRECHARGE_HB 0x4001944 #define ID_TORQUE_REQUEST_MAIN 0x4000041 #define ID_REAR_WHEEL_SPEEDS 0x8000381 -#define ID_FLOWRATE_TEMPS 0x4000881 +#define ID_COOLANT_TEMPS 0x4000881 #define ID_COOLANT_OUT 0x40008c1 #define ID_GEARBOX 0x10000901 #define ID_DASHBOARD_BL_CMD 0x409c47e @@ -71,7 +71,7 @@ #define DLC_PRECHARGE_HB 2 #define DLC_TORQUE_REQUEST_MAIN 8 #define DLC_REAR_WHEEL_SPEEDS 8 -#define DLC_FLOWRATE_TEMPS 8 +#define DLC_COOLANT_TEMPS 4 #define DLC_COOLANT_OUT 3 #define DLC_GEARBOX 2 #define DLC_DASHBOARD_BL_CMD 5 @@ -163,7 +163,7 @@ #define UP_PRECHARGE_HB 100 #define UP_TORQUE_REQUEST_MAIN 15 #define UP_REAR_WHEEL_SPEEDS 15 -#define UP_FLOWRATE_TEMPS 200 +#define UP_COOLANT_TEMPS 200 #define UP_COOLANT_OUT 1000 #define UP_GEARBOX 2000 /* END AUTO UP DEFS */ @@ -324,11 +324,7 @@ typedef union { uint64_t battery_out_temp: 8; uint64_t drivetrain_in_temp: 8; uint64_t drivetrain_out_temp: 8; - uint64_t battery_flowrate: 8; - uint64_t drivetrain_flowrate: 8; - uint64_t battery_fan_speed: 8; - uint64_t drivetrain_fan_speed: 8; - } flowrate_temps; + } coolant_temps; struct { uint64_t bat_fan: 8; uint64_t dt_fan: 8; @@ -496,13 +492,9 @@ typedef struct { int8_t battery_out_temp; int8_t drivetrain_in_temp; int8_t drivetrain_out_temp; - uint8_t battery_flowrate; - uint8_t drivetrain_flowrate; - uint8_t battery_fan_speed; - uint8_t drivetrain_fan_speed; uint8_t stale; uint32_t last_rx; - } flowrate_temps; + } coolant_temps; struct { uint8_t bat_fan; uint8_t dt_fan; diff --git a/source/main_module/can/can_parse.c b/source/main_module/can/can_parse.c index de917d09..bdf9501d 100644 --- a/source/main_module/can/can_parse.c +++ b/source/main_module/can/can_parse.c @@ -97,29 +97,12 @@ void canRxUpdate() can_data.main_module_bl_cmd.data = msg_data_a->main_module_bl_cmd.data; main_module_bl_cmd_CALLBACK(msg_data_a); break; - case ID_COOLING_DRIVER_REQUEST: - can_data.cooling_driver_request.dt_pump = msg_data_a->cooling_driver_request.dt_pump; - can_data.cooling_driver_request.dt_fan = msg_data_a->cooling_driver_request.dt_fan; - can_data.cooling_driver_request.batt_pump = msg_data_a->cooling_driver_request.batt_pump; - can_data.cooling_driver_request.batt_pump2 = msg_data_a->cooling_driver_request.batt_pump2; - can_data.cooling_driver_request.batt_fan = msg_data_a->cooling_driver_request.batt_fan; - can_data.cooling_driver_request.stale = 0; - can_data.cooling_driver_request.last_rx = sched.os_ticks; - cooling_driver_request_CALLBACK(msg_data_a); - break; case ID_THROTTLE_REMAPPED: can_data.throttle_remapped.remap_k_rl = (int16_t) msg_data_a->throttle_remapped.remap_k_rl; can_data.throttle_remapped.remap_k_rr = (int16_t) msg_data_a->throttle_remapped.remap_k_rr; can_data.throttle_remapped.stale = 0; can_data.throttle_remapped.last_rx = sched.os_ticks; break; - case ID_PDU_TEST: - can_data.pdu_test.test_1 = msg_data_a->pdu_test.test_1; - can_data.pdu_test.test_2 = msg_data_a->pdu_test.test_2; - can_data.pdu_test.test_3 = msg_data_a->pdu_test.test_3; - can_data.pdu_test.stale = 0; - can_data.pdu_test.last_rx = sched.os_ticks; - break; case ID_FAULT_SYNC_PDU: can_data.fault_sync_pdu.idx = msg_data_a->fault_sync_pdu.idx; can_data.fault_sync_pdu.latched = msg_data_a->fault_sync_pdu.latched; @@ -176,15 +159,9 @@ void canRxUpdate() CHECK_STALE(can_data.LWS_Standard.stale, sched.os_ticks, can_data.LWS_Standard.last_rx, UP_LWS_STANDARD); - CHECK_STALE(can_data.cooling_driver_request.stale, - sched.os_ticks, can_data.cooling_driver_request.last_rx, - UP_COOLING_DRIVER_REQUEST); CHECK_STALE(can_data.throttle_remapped.stale, sched.os_ticks, can_data.throttle_remapped.last_rx, UP_THROTTLE_REMAPPED); - CHECK_STALE(can_data.pdu_test.stale, - sched.os_ticks, can_data.pdu_test.last_rx, - UP_PDU_TEST); /* END AUTO STALE CHECKS */ } @@ -213,21 +190,18 @@ bool initCANFilter() CAN1->sFilterRegister[2].FR2 = (ID_LWS_STANDARD << 3) | 4; CAN1->FA1R |= (1 << 3); // configure bank 3 CAN1->sFilterRegister[3].FR1 = (ID_MAIN_MODULE_BL_CMD << 3) | 4; - CAN1->sFilterRegister[3].FR2 = (ID_COOLING_DRIVER_REQUEST << 3) | 4; + CAN1->sFilterRegister[3].FR2 = (ID_THROTTLE_REMAPPED << 3) | 4; CAN1->FA1R |= (1 << 4); // configure bank 4 - CAN1->sFilterRegister[4].FR1 = (ID_THROTTLE_REMAPPED << 3) | 4; - CAN1->sFilterRegister[4].FR2 = (ID_PDU_TEST << 3) | 4; + CAN1->sFilterRegister[4].FR1 = (ID_FAULT_SYNC_PDU << 3) | 4; + CAN1->sFilterRegister[4].FR2 = (ID_FAULT_SYNC_DASHBOARD << 3) | 4; CAN1->FA1R |= (1 << 5); // configure bank 5 - CAN1->sFilterRegister[5].FR1 = (ID_FAULT_SYNC_PDU << 3) | 4; - CAN1->sFilterRegister[5].FR2 = (ID_FAULT_SYNC_DASHBOARD << 3) | 4; + CAN1->sFilterRegister[5].FR1 = (ID_FAULT_SYNC_A_BOX << 3) | 4; + CAN1->sFilterRegister[5].FR2 = (ID_FAULT_SYNC_TEST_NODE << 3) | 4; CAN1->FA1R |= (1 << 6); // configure bank 6 - CAN1->sFilterRegister[6].FR1 = (ID_FAULT_SYNC_A_BOX << 3) | 4; - CAN1->sFilterRegister[6].FR2 = (ID_FAULT_SYNC_TEST_NODE << 3) | 4; + CAN1->sFilterRegister[6].FR1 = (ID_SET_FAULT << 3) | 4; + CAN1->sFilterRegister[6].FR2 = (ID_RETURN_FAULT_CONTROL << 3) | 4; CAN1->FA1R |= (1 << 7); // configure bank 7 - CAN1->sFilterRegister[7].FR1 = (ID_SET_FAULT << 3) | 4; - CAN1->sFilterRegister[7].FR2 = (ID_RETURN_FAULT_CONTROL << 3) | 4; - CAN1->FA1R |= (1 << 8); // configure bank 8 - CAN1->sFilterRegister[8].FR1 = (ID_DAQ_COMMAND_MAIN_MODULE << 3) | 4; + CAN1->sFilterRegister[7].FR1 = (ID_DAQ_COMMAND_MAIN_MODULE << 3) | 4; /* END AUTO FILTER */ CAN1->FA1R |= (1 << 6); // configure bank 6 CAN1->sFilterRegister[6].FR1 = (ID_LWS_STANDARD << 21); diff --git a/source/main_module/can/can_parse.h b/source/main_module/can/can_parse.h index 18888949..e8721ebb 100644 --- a/source/main_module/can/can_parse.h +++ b/source/main_module/can/can_parse.h @@ -22,7 +22,7 @@ /* BEGIN AUTO ID DEFS */ #define ID_MAIN_HB 0x4001901 #define ID_TORQUE_REQUEST_MAIN 0x4000041 -#define ID_FLOWRATE_TEMPS 0x4000881 +#define ID_COOLANT_TEMPS 0x4000881 #define ID_COOLANT_OUT 0x40008c1 #define ID_GEARBOX 0x10000901 #define ID_LWS_CONFIG 0x7c0 @@ -44,9 +44,7 @@ #define ID_MAX_CELL_TEMP 0x404e604 #define ID_LWS_STANDARD 0x2b0 #define ID_MAIN_MODULE_BL_CMD 0x409c43e -#define ID_COOLING_DRIVER_REQUEST 0xc0002c5 #define ID_THROTTLE_REMAPPED 0xc0025b7 -#define ID_PDU_TEST 0x401041f #define ID_FAULT_SYNC_PDU 0x8cadf #define ID_FAULT_SYNC_DASHBOARD 0x8ca85 #define ID_FAULT_SYNC_A_BOX 0x8ca44 @@ -60,7 +58,7 @@ /* BEGIN AUTO DLC DEFS */ #define DLC_MAIN_HB 2 #define DLC_TORQUE_REQUEST_MAIN 8 -#define DLC_FLOWRATE_TEMPS 8 +#define DLC_COOLANT_TEMPS 4 #define DLC_COOLANT_OUT 3 #define DLC_GEARBOX 2 #define DLC_LWS_CONFIG 2 @@ -82,9 +80,7 @@ #define DLC_MAX_CELL_TEMP 2 #define DLC_LWS_STANDARD 5 #define DLC_MAIN_MODULE_BL_CMD 5 -#define DLC_COOLING_DRIVER_REQUEST 5 #define DLC_THROTTLE_REMAPPED 4 -#define DLC_PDU_TEST 3 #define DLC_FAULT_SYNC_PDU 3 #define DLC_FAULT_SYNC_DASHBOARD 3 #define DLC_FAULT_SYNC_A_BOX 3 @@ -112,17 +108,13 @@ data_a->torque_request_main.rear_right = rear_right_;\ qSendToBack(&queue, &msg);\ } while(0) -#define SEND_FLOWRATE_TEMPS(queue, battery_in_temp_, battery_out_temp_, drivetrain_in_temp_, drivetrain_out_temp_, battery_flowrate_, drivetrain_flowrate_, battery_fan_speed_, drivetrain_fan_speed_) do {\ - CanMsgTypeDef_t msg = {.Bus=CAN1, .ExtId=ID_FLOWRATE_TEMPS, .DLC=DLC_FLOWRATE_TEMPS, .IDE=1};\ +#define SEND_COOLANT_TEMPS(queue, battery_in_temp_, battery_out_temp_, drivetrain_in_temp_, drivetrain_out_temp_) do {\ + CanMsgTypeDef_t msg = {.Bus=CAN1, .ExtId=ID_COOLANT_TEMPS, .DLC=DLC_COOLANT_TEMPS, .IDE=1};\ CanParsedData_t* data_a = (CanParsedData_t *) &msg.Data;\ - data_a->flowrate_temps.battery_in_temp = battery_in_temp_;\ - data_a->flowrate_temps.battery_out_temp = battery_out_temp_;\ - data_a->flowrate_temps.drivetrain_in_temp = drivetrain_in_temp_;\ - data_a->flowrate_temps.drivetrain_out_temp = drivetrain_out_temp_;\ - data_a->flowrate_temps.battery_flowrate = battery_flowrate_;\ - data_a->flowrate_temps.drivetrain_flowrate = drivetrain_flowrate_;\ - data_a->flowrate_temps.battery_fan_speed = battery_fan_speed_;\ - data_a->flowrate_temps.drivetrain_fan_speed = drivetrain_fan_speed_;\ + data_a->coolant_temps.battery_in_temp = battery_in_temp_;\ + data_a->coolant_temps.battery_out_temp = battery_out_temp_;\ + data_a->coolant_temps.drivetrain_in_temp = drivetrain_in_temp_;\ + data_a->coolant_temps.drivetrain_out_temp = drivetrain_out_temp_;\ qSendToBack(&queue, &msg);\ } while(0) #define SEND_COOLANT_OUT(queue, bat_fan_, dt_fan_, bat_pump_, bat_pump_aux_, dt_pump_) do {\ @@ -265,9 +257,7 @@ #define UP_DASHBOARD_HB 100 #define UP_MAX_CELL_TEMP 500 #define UP_LWS_STANDARD 15 -#define UP_COOLING_DRIVER_REQUEST 5 #define UP_THROTTLE_REMAPPED 15 -#define UP_PDU_TEST 15 /* END AUTO UP DEFS */ #define CHECK_STALE(stale, curr, last, period) if(!stale && \ @@ -351,11 +341,7 @@ typedef union { uint64_t battery_out_temp: 8; uint64_t drivetrain_in_temp: 8; uint64_t drivetrain_out_temp: 8; - uint64_t battery_flowrate: 8; - uint64_t drivetrain_flowrate: 8; - uint64_t battery_fan_speed: 8; - uint64_t drivetrain_fan_speed: 8; - } flowrate_temps; + } coolant_temps; struct { uint64_t bat_fan: 8; uint64_t dt_fan: 8; @@ -479,22 +465,10 @@ typedef union { uint64_t cmd: 8; uint64_t data: 32; } main_module_bl_cmd; - struct { - uint64_t dt_pump: 8; - uint64_t dt_fan: 8; - uint64_t batt_pump: 8; - uint64_t batt_pump2: 8; - uint64_t batt_fan: 8; - } cooling_driver_request; struct { uint64_t remap_k_rl: 16; uint64_t remap_k_rr: 16; } throttle_remapped; - struct { - uint64_t test_1: 8; - uint64_t test_2: 8; - uint64_t test_3: 8; - } pdu_test; struct { uint64_t idx: 16; uint64_t latched: 1; @@ -574,28 +548,12 @@ typedef struct { uint8_t cmd; uint32_t data; } main_module_bl_cmd; - struct { - uint8_t dt_pump; - uint8_t dt_fan; - uint8_t batt_pump; - uint8_t batt_pump2; - uint8_t batt_fan; - uint8_t stale; - uint32_t last_rx; - } cooling_driver_request; struct { int16_t remap_k_rl; int16_t remap_k_rr; uint8_t stale; uint32_t last_rx; } throttle_remapped; - struct { - uint8_t test_1; - uint8_t test_2; - uint8_t test_3; - uint8_t stale; - uint32_t last_rx; - } pdu_test; struct { uint16_t idx; uint8_t latched; @@ -631,7 +589,6 @@ extern volatile uint32_t last_can_rx_time_ms; /* BEGIN AUTO EXTERN CALLBACK */ extern void daq_command_MAIN_MODULE_CALLBACK(CanMsgTypeDef_t* msg_header_a); extern void main_module_bl_cmd_CALLBACK(CanParsedData_t* msg_data_a); -extern void cooling_driver_request_CALLBACK(CanParsedData_t* msg_data_a); extern void handleCallbacks(uint16_t id, bool latched); extern void set_fault_daq(uint16_t id, bool value); extern void return_fault_control(uint16_t id); diff --git a/source/main_module/car/car.c b/source/main_module/car/car.c index a10b5cbd..637f995c 100644 --- a/source/main_module/car/car.c +++ b/source/main_module/car/car.c @@ -8,6 +8,8 @@ extern q_handle_t q_tx_usart_l, q_tx_usart_r; // TODO: Just to remove errors for now usart_rx_buf_t huart_l_rx_buf, huart_r_rx_buf; uint8_t daq_buzzer; +uint8_t daq_brake; +uint8_t buzzer_brake_fault; sdc_nodes_t sdc_mux; /* Wheel Speed Config */ @@ -23,8 +25,9 @@ bool carInit() /* Set initial states */ car = (Car_t) {0}; // Everything to zero car.state = CAR_STATE_IDLE; - car.torque_src = CAR_TORQUE_TV; + car.torque_src = CAR_TORQUE_RAW; car.regen_enabled = false; + car.sdc_close = true; // We want to initialize SDC as "good" PHAL_writeGPIO(SDC_CTRL_GPIO_Port, SDC_CTRL_Pin, car.sdc_close); PHAL_writeGPIO(BRK_LIGHT_GPIO_Port, BRK_LIGHT_Pin, car.brake_light); PHAL_writeGPIO(BUZZER_GPIO_Port, BUZZER_Pin, car.buzzer); @@ -32,8 +35,8 @@ bool carInit() daq_buzzer = 0; /* Motor Controller Initialization */ - mcInit(&car.motor_l, MC_L_INVERT, &q_tx_usart_l, &huart_l_rx_buf, &car.pchg.pchg_complete); - mcInit(&car.motor_r, MC_R_INVERT, &q_tx_usart_r, &huart_r_rx_buf, &car.pchg.pchg_complete); + // mcInit(&car.motor_l, MC_L_INVERT, &q_tx_usart_l, &huart_l_rx_buf, &car.pchg.pchg_complete); + // mcInit(&car.motor_r, MC_R_INVERT, &q_tx_usart_r, &huart_r_rx_buf, &car.pchg.pchg_complete); PHAL_writeGPIO(SDC_MUX_S0_GPIO_Port, SDC_MUX_S0_Pin, 0); @@ -70,21 +73,21 @@ void carPeriodic() /* Set Default Outputs */ // Set Outputs that are purely combinational (do not depend on previous events) // Default values will typically reflect those in the IDLE state - car.torque_r.torque_left = 0.0f; - car.torque_r.torque_right = 0.0f; - car.buzzer = false; - car.sdc_close = true; + // car.torque_r.torque_left = 0.0f; + // car.torque_r.torque_right = 0.0f; + // car.buzzer = false; + // car.sdc_close = true; - /* Process Inputs */ + // /* Process Inputs */ - // Start button debounce (only want rising edge) - car.start_btn_debounced = can_data.start_button.start; - can_data.start_button.start = false; + // // Start button debounce (only want rising edge) + // car.start_btn_debounced = can_data.start_button.start; + // can_data.start_button.start = false; /* State Independent Operations */ - validatePrecharge(); - setFault(ID_PCHG_IMPLAUS_FAULT, car.pchg.pchg_error); + // validatePrecharge(); + // setFault(ID_PCHG_IMPLAUS_FAULT, car.pchg.pchg_error); // setFault(ID_RTD_EXIT_FAULT, !car.pchg.pchg_complete && car.state == CAR_STATE_READY2DRIVE); /** @@ -257,8 +260,9 @@ void carPeriodic() /* Update System Outputs */ car.buzzer = car.state == CAR_STATE_BUZZING || daq_buzzer; + buzzer_brake_fault = PHAL_readGPIO(BRK_BUZZER_STAT_GPIO_Port, BRK_BUZZER_STAT_Pin); PHAL_writeGPIO(SDC_CTRL_GPIO_Port, SDC_CTRL_Pin, car.sdc_close); - PHAL_writeGPIO(BRK_LIGHT_GPIO_Port, BRK_LIGHT_Pin, car.brake_light); + PHAL_writeGPIO(BRK_LIGHT_GPIO_Port, BRK_LIGHT_Pin, car.brake_light | daq_brake); PHAL_writeGPIO(BUZZER_GPIO_Port, BUZZER_Pin, car.buzzer); mcSetPower(car.torque_r.torque_left, &car.motor_l); mcSetPower(car.torque_r.torque_right, &car.motor_r); @@ -479,14 +483,15 @@ bool validatePrecharge() void monitorSDCPeriodic() { static uint8_t index = 0; - bool *nodes = (bool *) &sdc_mux; - - *(nodes+index++) = PHAL_readGPIO(SDC_MUX_DATA_GPIO_Port, SDC_MUX_DATA_Pin);; + static sdc_nodes_t sdc_nodes_raw; + bool *nodes = (bool *) &sdc_nodes_raw; - index = (index == 4) ? (index + 1) : index; + uint8_t stat = (uint8_t) PHAL_readGPIO(SDC_MUX_DATA_GPIO_Port, SDC_MUX_DATA_Pin); + *(nodes+index++) = stat; if (index == SDC_MUX_HIGH_IDX) { + sdc_mux = sdc_nodes_raw; index = 0; SEND_SDC_STATUS(q_tx_can, sdc_mux.imd_stat, sdc_mux.bms_stat, sdc_mux.bspd_stat, sdc_mux.bots_stat, sdc_mux.inertia_stat, sdc_mux.c_stop_stat, sdc_mux.main_stat, sdc_mux.r_stop_stat, sdc_mux.l_stop_stat, diff --git a/source/main_module/car/car.h b/source/main_module/car/car.h index 327685ab..8af3c165 100644 --- a/source/main_module/car/car.h +++ b/source/main_module/car/car.h @@ -78,6 +78,8 @@ typedef struct extern Car_t car; extern uint8_t daq_buzzer; +extern uint8_t daq_brake; +extern uint8_t buzzer_brake_fault; bool carInit(); void carHeartbeat(); @@ -88,22 +90,22 @@ void monitorSDCPeriodic(void); #define SDC_MUX_HIGH_IDX 14 -typedef struct +typedef struct __attribute__((packed)) { - bool main_stat; //y0 - bool c_stop_stat; //y1 - bool inertia_stat; //y2 - bool bots_stat; //y3 - bool nc; //y4 - bool bspd_stat; //y5 - bool bms_stat; //y6 - bool imd_stat; //y7 - bool r_stop_stat; //y8 - bool l_stop_stat; //y9 - bool hvd_stat; //y10 - bool r_hub_stat; //y11 - bool tsms_stat; //y12 - bool pchg_out_stat; //y13 + uint8_t main_stat; //y0 + uint8_t c_stop_stat; //y1 + uint8_t inertia_stat; //y2 + uint8_t bots_stat; //y3 + uint8_t nc; //y4 + uint8_t bspd_stat; //y5 + uint8_t bms_stat; //y6 + uint8_t imd_stat; //y7 + uint8_t r_stop_stat; //y8 + uint8_t l_stop_stat; //y9 + uint8_t hvd_stat; //y10 + uint8_t r_hub_stat; //y11 + uint8_t tsms_stat; //y12 + uint8_t pchg_out_stat; //y13 } sdc_nodes_t; diff --git a/source/main_module/cooling/cooling.c b/source/main_module/cooling/cooling.c index ef4ed894..b4fe5968 100644 --- a/source/main_module/cooling/cooling.c +++ b/source/main_module/cooling/cooling.c @@ -1,267 +1,104 @@ #include "cooling.h" - -const float adc_to_ln[] = {0.0f, 3.66932195489841f, 4.36639937878818f, 4.77581023800821f, 5.06745369221869f, 5.2945743802692f, 5.4808889545972f, 5.63904866008963f, 5.77660521538147f, 5.89842968114079f, 6.00784802635851f, 6.1072325688147f, 6.19833497682335f, 6.28248552082528f, 6.36071827325357f, 6.43385300932074f, 6.50255062145495f, 6.56735170457577f, 6.62870409572963f, 6.68698295786607f, 6.74250570608683f, 6.79554328837521f, 6.84632883966985f, 6.89506441066586f, 6.94192626350331f, 6.98706908570186f, 7.03062937713267f, 7.07272819744148f, 7.11347341358249f, 7.1529615527881f, 7.19127934128525f, 7.22850499062208f, 7.26470927971074f, 7.29995647032355f, 7.33430508588904f, 7.3678085773747f, 7.40051589535049f, 7.4324719836627f, 7.4637182072667f, 7.49429272448382f, 7.52423081212813f, 7.55356515048801f, 7.58232607396915f, 7.61054179224856f, 7.63823858600859f, 7.66544098067965f, 7.69217190109277f, 7.71845280950592f, 7.74430382910538f, 7.76974385477934f, 7.7947906527075f, 7.81946095009564f, 7.84377051620407f, 7.86773423566524f, 7.89136617495574f, 7.91467964277671f, 7.9376872450016f, 7.96040093476842f, 7.98283205822374f, 8.00499139636441f, 8.02688920337104f, 8.04853524178147f, 8.06993881481267f, 8.09110879610534f, 8.11205365713481f, 8.13278149250591f, 8.1533000433256f, 8.17361671882747f, 8.19373861640354f, 8.21367254018327f, 8.23342501828559f, 8.25300231885707f, 8.27241046499855f, 8.29165524867247f, 8.31074224367451f, 8.32967681774518f, 8.34846414389012f, 8.36710921097153f, 8.38561683362752f, 8.40399166157109f, 8.42223818831605f, 8.44036075937295f, 8.45836357995433f, 8.47625072222564f, 8.4940261321347f, 8.5116936358502f, 8.529256945837f, 8.5467196665941f, 8.56408530007868f, 8.58135725083814f, 8.59853883087019f, 8.61563326422949f, 8.63264369139813f, 8.64957317343572f, 8.66642469592386f, 8.68320117271867f, 8.69990544952401f, 8.71654030729723f, 8.73310846549834f, 8.74961258519297f, 8.76605527201844f, 8.78243907902203f, 8.7987665093797f, 8.81504001900293f, 8.83126201904121f, 8.84743487828681f, 8.86356092548834f, 8.87964245157913f, 8.8956817118262f, 8.91168092790504f, 8.92764228990538f, 8.94356795827277f, 8.95946006569037f, 8.97532071890552f, 8.9911520005049f, 9.00695597064244f, 9.02273466872357f, 9.03849011504952f, 9.05422431242489f, 9.06993924773203f, 9.08563689347523f, 9.1013192092979f, 9.11698814347564f, 9.13264563438814f, 9.14829361197268f, 9.16393399916203f, 9.17956871330943f, 9.1951996676033f, 9.21082877247429f, 9.22645793699725f, 9.24208907029076f, 9.25772408291671f, 9.27336488828254f, 9.28901340404866f, 9.30467155354376f, 9.32034126719051f, 9.33602448394432f, 9.35172315274794f, 9.36743923400462f, 9.38317470107257f, 9.39893154178373f, 9.41471175998981f, 9.43051737713856f, 9.44635043388364f, 9.46221299173125f, 9.47810713472702f, 9.49403497118674f, 9.50999863547468f, 9.5260002898334f, 9.54204212626923f, 9.55812636849767f, 9.57425527395335f, 9.59043113586931f, 9.60665628543076f, 9.62293309400858f, 9.63926397547845f, 9.65565138863155f, 9.67209783968326f, 9.68860588488691f, 9.70517813325966f, 9.72181724942849f, 9.73852595660465f, 9.75530703969537f, 9.77216334856257f, 9.78909780143873f, 9.80611338851095f, 9.82321317568514f, 9.84040030854287f, 9.85767801650483f, 9.87504961721559f, 9.89251852116555f, 9.91008823656748f, 9.92776237450618f, 9.94554465438154f, 9.96343890966679f, 9.98144909400584f, 9.99957928767527f, 10.0178337044393f, 10.036216698828f, 10.0547327738723f, 10.0733865893315f, 10.0921829704543f, 10.1111269173144f, 10.1302236147708f, 10.1494784431031f, 10.1688969893788f, 10.1884850596172f, 10.208248691817f, 10.2281941699247f, 10.2483280388279f, 10.2686571204663f, 10.2891885311634f, 10.3099297002921f, 10.3308883904023f, 10.3520727189493f, 10.3734911817819f, 10.395152678563f, 10.4170665403205f, 10.4392425593446f, 10.4616910216805f, 10.4844227424891f, 10.5074491045899f, 10.5307821005337f, 10.5544343786057f, 10.5784192932047f, 10.6027509601135f, 10.6274443172393f, 10.6525151914905f, 10.67798037255f, 10.7038576944166f, 10.7301661257206f, 10.756925869971f, 10.7841584770773f, 10.811886967703f, 10.8401359722661f, 10.8689318867084f, 10.8983030475226f, 10.928279928969f, 10.9588953659456f, 10.9901848066264f, 11.022186599771f, 11.0549423225786f, 11.0884971561543f, 11.1229003171347f, 11.1582055558673f, 11.1944717338517f, 11.2317634960773f, 11.2701520576111f, 11.3097161285568f, 11.3505430076665f, 11.3927298829085f, 11.4363853878479f, 11.4816314767016f, 11.5286056997271f, 11.5774639861078f, 11.6283840765351f, 11.6815697964567f, 11.7372564298417f, 11.7957175521278f, 11.8572738252678f, 11.9223044723995f, 11.9912624757751f, 12.0646950489125f, 12.1432717442911f, 12.2278238914625f, 12.3194013308372f, 12.4193564279281f, 12.529472800584f, 12.6521707539224f, 12.7908517893683f, 12.9505131204777f, 13.1389341808807f, 13.3692234553359f, 13.6661709812334f, 14.0862761567494f, 14.8161424382722f -}; +#include "common_defs.h" Cooling_t cooling; extern q_handle_t q_tx_can; -extern uint32_t APB1ClockRateHz; - - -uint8_t lowpass(uint8_t new, uint8_t *old, uint8_t curr); bool coolingInit() { cooling = (Cooling_t) {0}; - /* Configure GPIO Interrupts */ - // // enable syscfg clock - // RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; - // // set exti gpio source through syscfg (0b0010 means GPIOC) - // SYSCFG->EXTICR[1] |= (((uint16_t)0b0010) << (DT_FLOW_RATE_PWM_Pin - 4) * 4) | - // (((uint16_t)0b0010) << (BAT_FLOW_RATE_PWM_Pin - 4) * 4); - // // unmask the interrupt - // EXTI->IMR1 |= /*(0b1 << DT_FLOW_RATE_PWM_Pin) | */ - // (0b1 << BAT_FLOW_RATE_PWM_Pin); - // // set trigger to rising edge - // EXTI->RTSR1 |= (0b1 << DT_FLOW_RATE_PWM_Pin) | - // (0b1 << BAT_FLOW_RATE_PWM_Pin); - // // enable the interrupt handlers - // NVIC_EnableIRQ(EXTI9_5_IRQn); - // RCC -> APB1ENR1 |= RCC_APB1ENR1_TIM4EN; //0b100; - // TIM4 -> CR1 &= ~TIM_CR1_CEN; //Turning off counter - // TIM4 -> PSC = (APB1ClockRateHz / (PWM_FREQUENCY * 100)) - 1; - // TIM4 -> ARR = 100 - 1; //setting it to 99 so it's easier to use it with Duty Cycle - // //Enabling the MOE bit of the dead-time register - // // TIM4 -> BDTR |= TIM_BDTR_MOE; - // //Set Channels 1 and 2 to 110 (Mode 1 up counter) -> (active while CNT <= CCR) - // TIM4 -> CCMR1 &= ~(TIM_CCMR1_OC1M_0); - // TIM4 -> CCMR1 &= ~(TIM_CCMR1_OC2M_0); - // TIM4 -> CCMR1 |= TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1; - // TIM4 -> CCMR1 |= TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1; - // //Setting the preload register - // TIM4 -> CCMR1 |= TIM_CCMR1_OC1PE | TIM_CCMR1_OC2PE; - // // TIM1 -> CR1 |= TIM_CR1_ARPE; - // //Enable Channels 1 and 2 outputs - // TIM4 -> CCER |= TIM_CCER_CC1E | TIM_CCER_CC2E; - // //Setting pwm to 0 - // TIM4 -> CCR1 = 100; // inverted - // TIM4 -> CCR2 = 100; - // //Enable counter as long as ccrs are 0 - // TIM4 -> CR1 |= TIM_CR1_CEN; // turning on counter - - // Default pin configurations + // Select Thermistor 0 on mux to begin checking thermistors + PHAL_writeGPIO(THERM_MUX_S0_GPIO_Port, THERM_MUX_S0_Pin, 0); + PHAL_writeGPIO(THERM_MUX_S1_GPIO_Port, THERM_MUX_S1_Pin, 0); + PHAL_writeGPIO(THERM_MUX_S2_GPIO_Port, THERM_MUX_S2_Pin, 0); return true; } -uint8_t lowpass(uint8_t new, uint8_t *old, uint8_t curr) { - uint8_t i; - float average = 0; - - old[curr] = new; - - for (i = 0; i < AVG_WINDOW_SIZE; i++) { - average += (float) old[i]; - } - - return (uint8_t) (average / AVG_WINDOW_SIZE); -} - void coolingPeriodic() { /* WATER TEMP CALCULATIONS */ static uint8_t curr_therm; - float temp; + int8_t temp; // TODO: test signed temps // 568 594 - // Since ADC readings happen ~2ms, the next measurement should be ready - // temp = rawThermtoCelcius(adc_readings.therm_mux_d); - // temp = THERM_A * adc_to_ln[(adc_readings.therm_mux_d / 16)] + THERM_B; - // switch(curr_therm) - // { - // case THERM_MUX_BAT_IN: - // cooling.bat_therm_in_C = temp; - // break; - // case THERM_MUX_BAT_OUT: - // cooling.bat_therm_out_C = temp; - // break; - // case THERM_MUX_DT_IN: - // cooling.dt_therm_in_C = temp; - // break; - // case THERM_MUX_DT_OUT: - // cooling.dt_therm_out_C = temp; - // break; - // } - // curr_therm = (curr_therm + 1) & 0x03; - // PHAL_writeGPIO(THERM_MUX_S0_GPIO_Port, THERM_MUX_S0_Pin, curr_therm & 0x01); - // PHAL_writeGPIO(THERM_MUX_S1_GPIO_Port, THERM_MUX_S1_Pin, curr_therm & 0x02); - - // int8_t drivetrain_right_temp = (DT_THERM_A * adc_to_ln[adc_readings.dt_gb_r/16] + DT_THERM_B); - // int8_t drivetrain_left_temp = (DT_THERM_A * adc_to_ln[adc_readings.dt_gb_l/16] + DT_THERM_B); - - // // Update outputs - // if (cooling.daq_override) - // { - // cooling.out = cooling.out_daq_req; - // } - - // SEND_FLOWRATE_TEMPS(q_tx_can, cooling.bat_therm_in_C, cooling.bat_therm_out_C, - // cooling.dt_therm_in_C, cooling.dt_therm_out_C, - // cooling.bat_liters_p_min_x10, cooling.dt_liters_p_min_x10, - // 0, 0); - // SEND_COOLANT_OUT(q_tx_can, cooling.out.bat_fan_power, cooling.out.dt_fan_power, - // cooling.out.bat_pump, cooling.out.bat_pump_aux, - // cooling.out.dt_pump); - // SEND_GEARBOX(q_tx_can, drivetrain_left_temp, drivetrain_right_temp); - - return; - /* - FLOW CALCULATIONS - // Convert ticks and time delta to liters per minute - if (cooling.dt_delta_t == 0) - cooling.dt_liters_p_min_x10 = 0; - else - cooling.dt_liters_p_min_x10 = ((1000 / (float) (cooling.dt_delta_t * 7.5))) * 10; - if (cooling.bat_delta_t == 0) - cooling.bat_delta_t = 0; - else - cooling.bat_liters_p_min_x10 = ((1000 / (float) (cooling.bat_delta_t * 7.5))) * 10; - - static uint8_t dt_old[AVG_WINDOW_SIZE]; - static uint8_t bat_old[AVG_WINDOW_SIZE]; - static uint8_t curr; - cooling.dt_liters_p_min_x10 = lowpass(cooling.dt_liters_p_min_x10, dt_old, curr); - cooling.bat_liters_p_min_x10 = lowpass(cooling.bat_liters_p_min_x10, bat_old, curr); - ++curr; - curr = (curr == AVG_WINDOW_SIZE) ? 0 : curr; - - //Send CAN messages with flowrates - // SEND_FLOWRATE_TEMPS(q_tx_can, cooling.bat_liters_p_min_x10, cooling.bat_therm_in_C, cooling.dt_therm_2_C, - // adc_readings.dt_therm_1, adc_readings.dt_therm_2); - DT COOLANT SYSTEM - - // Find max motor temperature (CELSIUS) - uint8_t max_motor_temp = MAX(car.motor_l.motor_temp, - car.motor_r.motor_temp); - - // Determine if temp error - // TODO: add in stale checking for temperatures - cooling.dt_temp_error = 0;//(car.pch car.motor_l.data_stale || - //max_motor_temp >= DT_ERROR_TEMP_C; - // Check flow rate - if (cooling.dt_pump && !cooling.dt_rose && - ((sched.os_ticks - dt_pump_start_time_ms) / 1000) > DT_FLOW_STARTUP_TIME_S) - cooling.dt_rose = 1; - if (cooling.dt_pump && cooling.dt_rose && - cooling.dt_liters_p_min_x10 < DT_MIN_FLOW_L_M * 10) + // Since ADC readin/gs happen ~2ms, the next measurement should be ready + // Send temps, passing in different thermistor constants for the different thermistors + if (curr_therm < COOL_LOOP_START_IDX) { - cooling.dt_flow_error = 1; + // Get temp + temp = rawThermtoCelcius(adc_readings.therm_mux_d, DT_THERM_A, DT_THERM_B, DT_THERM_R1); } else { - // TODO: how to reset error? - //cooling.dt_flow_error = 0; + // Get temp + if (curr_therm == B_THERM_IDX) + temp = rawThermtoCelcius(adc_readings.therm_mux_d, W_THERM_A, W_THERM_B, B_THERM_R1); + else + temp = rawThermtoCelcius(adc_readings.therm_mux_d, W_THERM_A, W_THERM_B, W_THERM_R1); } + // Because the select lines are in order, we can just update coolant struct by treating it as an array + *((int8_t *)(&cooling) + curr_therm) = temp; - max_motor_temp = 0; - // Determine if system should be on + // Update current thermistor + curr_therm = (curr_therm == THERM_MUX_END_IDX) ? 0 : (curr_therm + 1); - if ((!cooling.dt_flow_error || DT_FLOW_CHECK_OVERRIDE) && - (max_motor_temp > DT_PUMP_ON_TEMP_C || ((prchg_set) && - (cooling.dt_temp_error || DT_ALWAYS_COOL)))) - { - if (!cooling.dt_pump) - { - setDtCooling(true); - } - } - // Determine if system should be off - else if (cooling.dt_pump) - { - setDtCooling(false); - } - setDtCooling(true); - - BAT COOLANT SYSTEM - // TODO: replace with CAN frame - uint8_t max_bat_temp = 0; + // Set mux for next value + PHAL_writeGPIO(THERM_MUX_S0_GPIO_Port, THERM_MUX_S0_Pin, (curr_therm & 0x01)); + PHAL_writeGPIO(THERM_MUX_S1_GPIO_Port, THERM_MUX_S1_Pin, (curr_therm & 0x02)); + PHAL_writeGPIO(THERM_MUX_S2_GPIO_Port, THERM_MUX_S2_Pin, (curr_therm & 0x04)); - cooling.bat_temp_error = 1||// TODO: replace with CAN frame can_data.bat_temp.stale || - max_bat_temp >= BAT_ERROR_TEMP_C; - - // Check flow rate - if (cooling.bat_pump && !cooling.bat_rose && - ((sched.os_ticks - bat_pump_start_time_ms) / 1000) > BAT_FLOW_STARTUP_TIME_S) - cooling.bat_rose = 1; - if (cooling.bat_pump && cooling.bat_rose && - cooling.bat_liters_p_min_x10 < BAT_MIN_FLOW_L_M * 10) + // Only send data once all new thermistors are updated to avoid clutter on CAN bus + if (curr_therm == 0) { - cooling.bat_flow_error = 1; - } - else - { - // TODO: how to reset error? - //cooling.bat_flow_error = 0; - } - - max_bat_temp = 0; + SEND_COOLANT_TEMPS(q_tx_can, cooling.bat_therm_in_C, cooling.bat_therm_out_C, cooling.dt_therm_in_C, cooling.dt_therm_out_C); - // Determine if system should be on - if ((!cooling.bat_flow_error || BAT_FLOW_CHECK_OVERRIDE) && - (max_bat_temp > BAT_PUMP_ON_TEMP_C || ((prchg_set) && - (cooling.bat_temp_error || BAT_ALWAYS_COOL)))) - { - if (!cooling.bat_pump) - { - setBatCooling(true); - } - } - // Determine if system should be off - else if (cooling.bat_pump) - { - setBatCooling(false); + SEND_GEARBOX(q_tx_can, cooling.gb_therm_l_c, cooling.gb_therm_r_c); } - setBatCooling(true); - */ -} -/*void setFanPWM(void) { - uint8_t set_dt = 0; - uint8_t set_bat = 0; - static uint16_t time_curr; - if (time_curr < cooling.dt_fan_power) { - set_dt = 1; - } + //TODO: After mc parse library, update these with actual faults + // Find max motor temperature (CELSIUS) + // uint8_t max_motor_temp = MAX(car.motor_l.motor_temp, + // car.motor_r.motor_temp); + // Determine if DT thermistors are disconnected - if (time_curr < cooling.bat_fan_power) { - set_bat = 1; - } - if (++time_curr == 10) { - time_curr = 0; - } + // Determine if dt/coolant temps are too high + // DT + setFault(ID_DT_L_TEMP_HIGH_FAULT, cooling.gb_therm_l_c); + setFault(ID_DT_L_TEMP_OT_FAULT, cooling.gb_therm_l_c); + setFault(ID_DT_R_TEMP_HIGH_FAULT, cooling.gb_therm_r_c); + setFault(ID_DT_R_TEMP_OT_FAULT, cooling.gb_therm_r_c); - // PHAL_writeGPIO(DT_RAD_FAN_CTRL_GPIO_Port, DT_RAD_FAN_CTRL_Pin, set_dt); - // PHAL_writeGPIO(BAT_RAD_FAN_CTRL_GPIO_Port, BAT_RAD_FAN_CTRL_Pin, set_bat); -}*/ + // Cooling Loop + setFault(ID_BAT_COOL_LOOP_HIGH_FAULT, MAX(cooling.bat_therm_in_C, cooling.bat_therm_out_C)); + setFault(ID_DT_COOL_LOOP_HIGH_FAULT, MAX(cooling.dt_therm_in_C, cooling.dt_therm_out_C)); + // Disconnect Faults + // DT + setFault(ID_DT_L_THERM_DISC_FAULT, cooling.gb_therm_l_c); + setFault(ID_DT_R_THERM_DISC_FAULT, cooling.gb_therm_r_c); + // Cooling Loop + setFault(ID_BATT_CL_DISC_FAULT, MIN(cooling.bat_therm_in_C, cooling.bat_therm_out_C)); + setFault(ID_DT_CL_DISC_FAULT, MIN(cooling.dt_therm_in_C, cooling.dt_therm_out_C)); -float rawThermtoCelcius(uint16_t t) +} + +float rawThermtoCelcius(uint16_t t, float a, float b, uint16_t r1) { float f; if (t == MAX_THERM) return -290; - f = t * 3.3f / MAX_THERM; // Signal voltage - f = THERM_R1 * f / (5 - f); // Resistance - // resistance = (t == MAX_THERM) ? FLT_MAX : THERM_R1 * (float) t / (MAX_THERM - t); - return (f >= 0) ? THERM_A * native_log_computation(f) + THERM_B : 0; + f = t * ADC_REF_fp / MAX_THERM; // Signal voltage + f = (f * r1) / (ADC_REF_fp - f); // Resistance + return a * native_log_computation(f) + b; } // https://stackoverflow.com/questions/9800636/calculating-natural-logarithm-and-exponent-by-core-c-for-embedded-system @@ -278,16 +115,4 @@ static double native_log_computation(const double n) { d += 2, c *= f; } else b = (n == 0) / 0.; return n < 1 ? -(a + b) : a + b; -} - -void cooling_driver_request_CALLBACK(CanParsedData_t* data) -{ - // if (!cooling.daq_override) - // { - // cooling.out.dt_fan_power = data->cooling_driver_request.dt_fan; - // cooling.out.bat_fan_power = data->cooling_driver_request.batt_fan; - // cooling.out.bat_pump = data->cooling_driver_request.batt_pump; - // cooling.out.bat_pump_aux = data->cooling_driver_request.batt_pump2; - // cooling.out.dt_pump = data->cooling_driver_request.dt_pump; - // } } \ No newline at end of file diff --git a/source/main_module/cooling/cooling.h b/source/main_module/cooling/cooling.h index 73eb35d7..c2ed2356 100644 --- a/source/main_module/cooling/cooling.h +++ b/source/main_module/cooling/cooling.h @@ -22,98 +22,75 @@ #include #include -//45 C (off fail state) bat -//90 C (drivetrain) -// temp exceeds, stop drive don't open sdc -// room temp based - -#define DT_ALWAYS_COOL 1 -#define BAT_ALWAYS_COOL 1 -#define DT_FLOW_CHECK_OVERRIDE 1 -#define BAT_FLOW_CHECK_OVERRIDE 1 - -/* DRIVETRAIN COOLANT SYSTEM */ -#define DT_PUMP_ON_TEMP_C (27) -#define DT_PUMP_OFF_TEMP_C (26) -#define DT_ERROR_TEMP_C (100) // temp to not drive - -// TODO: calibrate flow rates -// Flow checks -#define DT_MAX_FLOW_L_M (26) // average of 3.7 -#define DT_MIN_FLOW_L_M (DT_MAX_FLOW_L_M / 3) -#define DT_FLOW_STARTUP_TIME_S (5) - -/* BATTERY COOLANT SYSTEM */ -#define BAT_PUMP_ON_TEMP_C (27) -#define BAT_PUMP_OFF_TEMP_C (26) -#define BAT_ERROR_TEMP_C (60) // temp to not drive - -// Flow checks -#define BAT_MAX_FLOW_L_M (26) -#define BAT_MIN_FLOW_L_M (20) -#define BAT_FLOW_STARTUP_TIME_S (5) - -// Part 828 on Adafruit -#define PULSES_P_LITER (450) - -#define PWM_FREQUENCY 25000 //PWM frequency to be 25kHz -// Thermistor specifications -#define THERM_R1 10000 // Top resistor in voltage divider -#define MAX_THERM 4095 // 12-bit adc precision +#define THERM_MUX_END_IDX (6) +#define B_THERM_IDX (5) // Problem thermistor index + +// Cooling Loops + +#define COOL_LOOP_START_IDX (2) + // Temp (Celcius) = a * ln(resistance) + b -// Thermistor PN: GE-2102 -#define THERM_A (-25.16f) -#define THERM_B (260.93f) +#define MAX_THERM 4095 // 12-bit adc precision -// Thermistor PN: USP10981 -#define DT_THERM_A (-22.93f) -#define DT_THERM_B (241.39f) +// Thermistor specifications +#define W_THERM_R1 2200 // Top resistor in voltage divider +#define B_THERM_R1 2000 // There is an error in schematic so this is a software fix to correct for 200ohm difference in top resistor -#define AVG_WINDOW_SIZE 10 +// Thermistor PN: GE-2102 +#define W_THERM_A (-25.16f) +#define W_THERM_B (260.93f) +// Powertrain +// Thermistor PN: GE-1337 +#define DT_THERM_A (-23.12f) +#define DT_THERM_B (218.63f) +#define DT_THERM_R1 2200 typedef struct { - float dt_therm_out_C; - float dt_therm_in_C; - float bat_therm_out_C; - float bat_therm_in_C; + int8_t gb_therm_r_c; + int8_t gb_therm_l_c; + int8_t bat_therm_in_C; //therm 1 (These are drivetrain in altium) + int8_t bat_therm_out_C; //therm 2 + int8_t dt_therm_out_C; //therm 1 (These are Battery in altium) + int8_t dt_therm_in_C; //therm 2 uint32_t dt_delta_t; uint32_t bat_delta_t; - - bool daq_override; // Outputs controlled by DAQ - - uint8_t dt_temp_error; // DT either over temp or not receiving - - uint8_t bat_temp_error;// BAT either over temp or not receiving temps } Cooling_t; extern Cooling_t cooling; /** - * @brief Initializes gpio interrupts - * Sets default output states + * @brief Initializes Thermistor Mux * @return true Success * @return false Fail */ bool coolingInit(); /** - * @brief Determines - * if fans and pumps should be turned - * on and checks for faults + * @brief Checks temperature of various cooling loops/Powertrain periodically */ void coolingPeriodic(); + + /** - * @brief Converts from a raw thermistor reading to celcius - * Based on digikey sensor GE-2102 - * @param t Raw thermistor measurement - * @return Degrees Celcius + * @brief Converts Raw ADC values to Temperature + * + * @param t ADC Value + * @param a 'a' constant in thermistor equation above + * @param b 'b' constant in thermistor equation above + * @param r1 Top resistor value for thermistor + * @return float */ -float rawThermtoCelcius(uint16_t t); +float rawThermtoCelcius(uint16_t t, float a, float b, uint16_t r1); -void setFanPWM(void); -static double native_log_computation(const double); +/** + * @brief Natural log without including math library + * + * @param n Value to take natural log of + * @return double natural log of n + */ +static double native_log_computation(const double n); #endif \ No newline at end of file diff --git a/source/main_module/daq/daq.c b/source/main_module/daq/daq.c index 88ced317..38a09f71 100644 --- a/source/main_module/daq/daq.c +++ b/source/main_module/daq/daq.c @@ -21,10 +21,7 @@ // BEGIN AUTO VAR DEFS daq_variable_t tracked_vars[NUM_VARS] = { - {.is_read_only=1, .bit_length=1, .read_var_a=&cooling.dt_temp_error, .write_var_a=NULL, }, - {.is_read_only=1, .bit_length=1, .read_var_a=&cooling.bat_temp_error, .write_var_a=NULL, }, {.is_read_only=1, .bit_length=1, .has_read_func=1, .read_func_a=(read_func_ptr_t)calibrateSteeringAngle, .write_var_a=NULL, }, - {.is_read_only=0, .bit_length=1, .read_var_a=&cooling.daq_override, .write_var_a=&cooling.daq_override, }, {.is_read_only=1, .bit_length=1, .read_var_a=&sdc_mux.main_stat, .write_var_a=NULL, }, {.is_read_only=1, .bit_length=1, .read_var_a=&sdc_mux.c_stop_stat, .write_var_a=NULL, }, {.is_read_only=1, .bit_length=1, .read_var_a=&sdc_mux.inertia_stat, .write_var_a=NULL, }, @@ -39,6 +36,8 @@ daq_variable_t tracked_vars[NUM_VARS] = { {.is_read_only=1, .bit_length=1, .read_var_a=&sdc_mux.tsms_stat, .write_var_a=NULL, }, {.is_read_only=1, .bit_length=1, .read_var_a=&sdc_mux.pchg_out_stat, .write_var_a=NULL, }, {.is_read_only=0, .bit_length=1, .read_var_a=&daq_buzzer, .write_var_a=&daq_buzzer, }, + {.is_read_only=0, .bit_length=1, .read_var_a=&daq_brake, .write_var_a=&daq_brake, }, + {.is_read_only=0, .bit_length=1, .read_var_a=&buzzer_brake_fault, .write_var_a=&buzzer_brake_fault, }, }; // END AUTO VAR DEFS diff --git a/source/main_module/daq/daq.h b/source/main_module/daq/daq.h index 01d2eeb6..55985ded 100644 --- a/source/main_module/daq/daq.h +++ b/source/main_module/daq/daq.h @@ -19,28 +19,27 @@ #define DAQ_UPDATE_PERIOD 15 // ms // BEGIN AUTO VAR COUNT -#define NUM_VARS 18 +#define NUM_VARS 17 // END AUTO VAR COUNT // BEGIN AUTO VAR IDs -#define DAQ_ID_DT_TEMP_ERROR 0 -#define DAQ_ID_BAT_TEMP_ERROR 1 -#define DAQ_ID_CAL_STEER_ANGLE 2 -#define DAQ_ID_COOLING_DAQ_OVERRIDE 3 -#define DAQ_ID_SDC_MAIN_STATUS 4 -#define DAQ_ID_SDC_CENTER_STOP_STATUS 5 -#define DAQ_ID_SDC_INERTIA_SW_STATUS 6 -#define DAQ_ID_SDC_BOTS_STAT 7 -#define DAQ_ID_SDC_BSPD_STAT 8 -#define DAQ_ID_SDC_BMS_STAT 9 -#define DAQ_ID_SDC_IMD_STAT 10 -#define DAQ_ID_SDC_R_ESTOP_STAT 11 -#define DAQ_ID_SDC_L_ESTOP_STAT 12 -#define DAQ_ID_SDC_HVD_STAT 13 -#define DAQ_ID_SDC_REAR_HUB_STAT 14 -#define DAQ_ID_SDC_TSMS_STAT 15 -#define DAQ_ID_SDC_PCHG_OUT_STAT 16 -#define DAQ_ID_DAQ_BUZZER 17 +#define DAQ_ID_CAL_STEER_ANGLE 0 +#define DAQ_ID_SDC_MAIN_STATUS 1 +#define DAQ_ID_SDC_CENTER_STOP_STATUS 2 +#define DAQ_ID_SDC_INERTIA_SW_STATUS 3 +#define DAQ_ID_SDC_BOTS_STAT 4 +#define DAQ_ID_SDC_BSPD_STAT 5 +#define DAQ_ID_SDC_BMS_STAT 6 +#define DAQ_ID_SDC_IMD_STAT 7 +#define DAQ_ID_SDC_R_ESTOP_STAT 8 +#define DAQ_ID_SDC_L_ESTOP_STAT 9 +#define DAQ_ID_SDC_HVD_STAT 10 +#define DAQ_ID_SDC_REAR_HUB_STAT 11 +#define DAQ_ID_SDC_TSMS_STAT 12 +#define DAQ_ID_SDC_PCHG_OUT_STAT 13 +#define DAQ_ID_DAQ_BUZZER 14 +#define DAQ_ID_DAQ_BRAKE 15 +#define DAQ_ID_DAQ_BUZZER_BRAKE_STATUS 16 // END AUTO VAR IDs // BEGIN AUTO FILE STRUCTS diff --git a/source/main_module/main.c b/source/main_module/main.c index 43528ce0..6a3e2a83 100644 --- a/source/main_module/main.c +++ b/source/main_module/main.c @@ -153,9 +153,11 @@ ADCInitConfig_t adc_config = { .resolution = ADC_RES_12_BIT, .data_align = ADC_DATA_ALIGN_RIGHT, .cont_conv_mode = true, - .dma_mode = ADC_DMA_CIRCULAR + .dma_mode = ADC_DMA_CIRCULAR, + .adc_number = 1 }; +// TODO: Update this comment with the correct sample time /* With 11 items, 16 prescaler, and 640 sample time, each channel gets read every 1.4ms */ volatile ADCReadings_t adc_readings; ADCChannelConfig_t adc_channel_config[] = { @@ -163,11 +165,13 @@ ADCChannelConfig_t adc_channel_config[] = { {.channel=V_BAT_SENSE_ADC_CHNL, .rank=2, .sampling_time=ADC_CHN_SMP_CYCLES_480}, {.channel=SHOCK_POT_L_ADC_CHNL, .rank=3, .sampling_time=ADC_CHN_SMP_CYCLES_480}, {.channel=SHOCK_POT_R_ADC_CHNL, .rank=4, .sampling_time=ADC_CHN_SMP_CYCLES_480}, - {.channel=THERM_MUX_D_ADC_CHNL, .rank=11, .sampling_time=ADC_CHN_SMP_CYCLES_480}, - {.channel=INTERNAL_THERM_ADC_CHNL, .rank=14, .sampling_time=ADC_CHN_SMP_CYCLES_480}, + {.channel=THERM_MUX_D_ADC_CHNL, .rank=5, .sampling_time=ADC_CHN_SMP_CYCLES_480}, + {.channel=LOAD_L_ADC_CHNL, .rank=6, .sampling_time=ADC_CHN_SMP_CYCLES_480}, + {.channel=LOAD_R_ADC_CHNL, .rank=7, .sampling_time=ADC_CHN_SMP_CYCLES_480}, + {.channel=INTERNAL_THERM_ADC_CHNL, .rank=8, .sampling_time=ADC_CHN_SMP_CYCLES_480}, }; dma_init_t adc_dma_config = ADC1_DMA_CONT_CONFIG((uint32_t) &adc_readings, - sizeof(adc_readings) / sizeof(adc_readings.lv_3v3_v_sense), 0b01); + sizeof(adc_readings) / sizeof(adc_readings.v_mc), 0b01); /* SPI Configuration */ // dma_init_t spi_rx_dma_config = SPI1_RXDMA_CONT_CONFIG(NULL, 2); @@ -184,16 +188,17 @@ dma_init_t adc_dma_config = ADC1_DMA_CONT_CONFIG((uint32_t) &adc_readings, // }; + + /* Clock Configuration */ -#define TargetCoreClockrateHz 80000000 +#define TargetCoreClockrateHz 16000000 ClockRateConfig_t clock_config = { - .system_source =SYSTEM_CLOCK_SRC_PLL, - .pll_src =PLL_SRC_HSI16, + .system_source =SYSTEM_CLOCK_SRC_HSI, .vco_output_rate_target_hz =160000000, .system_clock_target_hz =TargetCoreClockrateHz, .ahb_clock_target_hz =(TargetCoreClockrateHz / 1), - .apb1_clock_target_hz =(TargetCoreClockrateHz / 4), - .apb2_clock_target_hz =(TargetCoreClockrateHz / 4), + .apb1_clock_target_hz =(TargetCoreClockrateHz / (1)), + .apb2_clock_target_hz =(TargetCoreClockrateHz / (1)), }; /* Locals for Clock Rates */ @@ -212,6 +217,8 @@ void canTxUpdate(void); void send_fault(uint16_t, bool); extern void HardFault_Handler(); +void brak_buzz_test(); + q_handle_t q_tx_can; q_handle_t q_rx_can; uint8_t can_tx_fails; // number of CAN messages that failed to transmit @@ -235,24 +242,24 @@ int main(void){ { HardFault_Handler(); } + PHAL_writeGPIO(SDC_CTRL_GPIO_Port, SDC_CTRL_Pin, 1); /* Task Creation */ schedInit(APB1ClockRateHz); configureAnim(preflightAnimation, preflightChecks, 60, 750); - // taskCreate(coolingPeriodic, 200); + taskCreate(coolingPeriodic, 100); taskCreate(heartBeatLED, 500); - taskCreate(monitorSDCPeriodic, 15); + taskCreate(monitorSDCPeriodic, 10); // taskCreate(carHeartbeat, 100); - // taskCreate(carPeriodic, 15); + taskCreate(carPeriodic, 15); // taskCreate(wheelSpeedsPeriodic, 15); // taskCreate(updatePowerMonitor, 100); - // taskCreate(heartBeatTask, 100); + taskCreate(heartBeatTask, 100); // taskCreate(parseMCDataPeriodic, MC_LOOP_DT); - // taskCreate(daqPeriodic, DAQ_UPDATE_PERIOD); + taskCreate(daqPeriodic, DAQ_UPDATE_PERIOD); // taskCreate(memFg, MEM_FG_TIME); - // // taskCreate(updateFaults, 1); taskCreateBackground(canTxUpdate); taskCreateBackground(canRxUpdate); // taskCreateBackground(usartTxUpdate); @@ -327,7 +334,7 @@ void preflightChecks(void) { case 4: /* Module Initialization */ carInit(); - // coolingInit(); + coolingInit(); break; case 5: initCANParse(&q_rx_can); diff --git a/source/main_module/main.h b/source/main_module/main.h index 089efd1b..adcb361c 100644 --- a/source/main_module/main.h +++ b/source/main_module/main.h @@ -142,7 +142,7 @@ #define LOAD_L_ADC_CHNL (11) // MCU Internal Thermistor -#define INTERNAL_THERM_ADC_CHNL (17) +#define INTERNAL_THERM_ADC_CHNL (16) // Thermistor Analog Multiplexer #define THERM_MUX_S0_GPIO_Port (GPIOE) @@ -161,6 +161,8 @@ #define THERM_MUX_DT_OUT (3) #define ADC_REF_mV (3300UL) // mV +#define ADC_REF_fp 3.3F +#define ADC_MAX 4095 typedef struct { // Do not modify this struct unless @@ -170,15 +172,9 @@ typedef struct uint16_t v_bat; uint16_t shock_l; uint16_t shock_r; - uint16_t lv_24_v_sense; - uint16_t lv_24_i_sense; - uint16_t lv_12_v_sense; - uint16_t lv_5_v_sense; - uint16_t lv_5_i_sense; - uint16_t lv_3v3_v_sense; uint16_t therm_mux_d; - uint16_t dt_gb_l; - uint16_t dt_gb_r; + uint16_t load_l; + uint16_t load_r; uint16_t therm_mcu; }__attribute__((packed)) ADCReadings_t; volatile extern ADCReadings_t adc_readings;