Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Inc/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Core/Inc/pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
5 changes: 2 additions & 3 deletions Core/Src/bms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
13 changes: 11 additions & 2 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Core/Src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down