diff --git a/Core/Inc/control.h b/Core/Inc/control.h index 466ac785..c2832e72 100644 --- a/Core/Inc/control.h +++ b/Core/Inc/control.h @@ -23,7 +23,7 @@ /* Tempeature Constants for Devices */ #define PUMP_UPPER_MOTOR_TEMP 45 #define PUMP_LOWER_MOTOR_TEMP 35 -#define RADFAN_UPPER_MOTOR_TEMP 45 +#define RADFAN_UPPER_MOTOR_TEMP 65 #define RADFAN_LOWER_MOTOR_TEMP 35 #define PUMP_UPPER_CONTROLLER_TEMP 45 diff --git a/Core/Inc/pdu.h b/Core/Inc/pdu.h index 60070b91..9df0bf30 100644 --- a/Core/Inc/pdu.h +++ b/Core/Inc/pdu.h @@ -132,7 +132,7 @@ extern const osThreadAttr_t rtds_attributes; /* Misc */ #define MUTEX_TIMEOUT osWaitForever /* ms */ -#define RTDS_DURATION 1750 /* ms at 1kHz tick rate */ +#define RTDS_DURATION 30000 /* ms at 1kHz tick rate */ #define SOUND_RTDS_FLAG 1U /* Function that approximates the pump sensor temperature. Takes in resistance and outputs temperature. */ diff --git a/Core/Src/bms.c b/Core/Src/bms.c index b4b53cd2..ec550ed3 100644 --- a/Core/Src/bms.c +++ b/Core/Src/bms.c @@ -53,8 +53,7 @@ osStatus_t bms_get_battbox_temp(uint16_t *temp) void bms_record_battbox_temp(can_msg_t msg) { osMutexAcquire(bms.mutex, osWaitForever); - bms.battbox_temp = - (msg.data[0] << 8) + - msg.data[1]; // Get "BMS/Cells/Temp_High_Value" (first two bytes of the "Cell Temperatures" CAN message) + bms.battbox_temp = ((msg.data[6] << 8) | msg.data[7]) / + 100; // Get "BMS/Cells/Temp_Avg_Value" osMutexRelease(bms.mutex); } \ No newline at end of file diff --git a/Core/Src/can_handler.c b/Core/Src/can_handler.c index 655116bf..2641654c 100644 --- a/Core/Src/can_handler.c +++ b/Core/Src/can_handler.c @@ -33,7 +33,8 @@ static uint16_t id_list_1[4] = { static uint16_t id_list_2[4] = { DIAL_CANID_IO, CONTROL_CANID_FANBATTBOX, CONTROL_CANID_PUMP, CONTROL_CANID_RADFAN }; -static uint16_t id_list_3[4] = { BMS_CANID_CELL_TEMPS, DTI_CANID_CURRENTS }; +static uint16_t id_list_3[4] = { BMS_CANID_CELL_TEMPS, DTI_CANID_CURRENTS, + 0x49A }; void init_can1(CAN_HandleTypeDef *hcan) { @@ -150,8 +151,11 @@ const osThreadAttr_t can_receive_attributes = { void vCanReceive(void *pv_params) { - dti_t *mc = (dti_t *)pv_params; + control_args_t *args = (control_args_t *)pv_params; + dti_t *mc = args->mc; assert(mc); + pdu_t *pdu = args->pdu; + assert(pdu); can_msg_t msg; @@ -187,8 +191,13 @@ void vCanReceive(void *pv_params) break; case CONTROL_CANID_RADFAN: control_radfan_record(msg); + break; case DTI_CANID_CURRENTS: dti_record_currents(mc, msg); + break; + case 0x49A: + write_rtds(pdu, msg.data[0]); + break; default: break; } diff --git a/Core/Src/control.c b/Core/Src/control.c index 653f03bc..93455d4b 100644 --- a/Core/Src/control.c +++ b/Core/Src/control.c @@ -146,10 +146,10 @@ void vControl(void *params) // Determine device state control_device(&pump0, motor_temp); - control_device(&radfan0, motor_temp); control_device(&pump1, controller_temp); - control_device(&radfan1, controller_temp); control_device(&fan_battbox, battbox_temp); + control_device(&radfan0, motor_temp); + control_device(&radfan1, controller_temp); osDelay(1000); } diff --git a/Core/Src/main.c b/Core/Src/main.c index a2fd74f5..17a8ff62 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -241,7 +241,7 @@ int main(void) assert(can_dispatch_handle); can_receive_thread = - osThreadNew(vCanReceive, mc, &can_receive_attributes); + osThreadNew(vCanReceive, control_args, &can_receive_attributes); assert(can_receive_thread); /* Control Logic */