-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Thermal Mgr Task #285
base: main
Are you sure you want to change the base?
Changes from all commits
c2caffd
d13a987
72b7235
38111b7
19bd58c
fb02de2
83d5389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
#define TASK_PAYLOAD_MGR_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_TIMEKEEPER_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_ALARM_MGR_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_HEALTH_COLLECTOR_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_THERMAL_MGR_WATCHDOG_TIMEOUT pdMS_TO_TICKS(1000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update this with changed tick delay There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. watchdog timeout shouldl generally be 2x task rate |
||
#define TASK_STATS_COLLECTOR_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_LOGGER_WATCHDOG_TIMEOUT portMAX_DELAY | ||
#define TASK_DIGITAL_WATCHDOG_MGR_WATCHDOG_TIMEOUT portMAX_DELAY | ||
|
@@ -75,9 +75,9 @@ static watchdog_task_info_t watchdogTaskArray[] = { | |
{ | ||
.taskTimeoutTicks = TASK_ALARM_MGR_WATCHDOG_TIMEOUT, | ||
}, | ||
[OBC_SCHEDULER_CONFIG_ID_HEALTH_COLLECTOR] = | ||
[OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR] = | ||
{ | ||
.taskTimeoutTicks = TASK_HEALTH_COLLECTOR_WATCHDOG_TIMEOUT, | ||
.taskTimeoutTicks = TASK_THERMAL_MGR_WATCHDOG_TIMEOUT, | ||
}, | ||
[OBC_SCHEDULER_CONFIG_ID_LOGGER] = | ||
{ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "thermal_mgr.h" | ||
|
||
// sensor imports for telemetry | ||
#include "lm75bd.h" | ||
#include "cc1120.h" | ||
#include "cc1120_defs.h" | ||
#include "ds3232_mz.h" | ||
// bd621x, fm25V025A, MAX5360, and RFFM6404 doesn't have a temperature sensors | ||
|
||
#include "obc_time.h" | ||
#include "telemetry_manager.h" | ||
#include "obc_errors.h" | ||
#include "obc_logging.h" | ||
#include "obc_scheduler_config.h" | ||
#include <obc_digital_watchdog.h> | ||
#include "digital_watchdog_mgr.h" | ||
|
||
#include <FreeRTOS.h> | ||
#include <os_portmacro.h> | ||
#include <os_task.h> | ||
#include <os_queue.h> | ||
|
||
#define THERMAL_MGR_PERIOD_MS 1000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on our telemetry sheet, it should take the temperature once every minute, not once a sec. Also add U to the end |
||
|
||
void obcTaskInitThermalMgr() {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This task should init the lm75bd |
||
static obc_error_code_t collectObcLm75bdTemp(void); | ||
static obc_error_code_t collectObcDs3232Temp(void); | ||
static obc_error_code_t collectObcCC1120Temp(void); | ||
static obc_error_code_t collectBMSTemp(void); | ||
|
||
void obcTaskFunctionThermalMgr(void* pvParameters) { | ||
obc_error_code_t errCode; | ||
TickType_t xLastWakeTime; | ||
|
||
xLastWakeTime = xTaskGetTickCount(); | ||
|
||
while (1) { | ||
LOG_IF_ERROR_CODE(collectObcLm75bdTemp()); | ||
LOG_IF_ERROR_CODE(collectObcCC1120Temp()); | ||
LOG_IF_ERROR_CODE(collectObcDs3232Temp()); // RTC | ||
LOG_IF_ERROR_CODE(collectBMSTemp()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BMS driver code does not exist; still in PR #187 |
||
digitalWatchdogTaskCheckIn(OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR); | ||
|
||
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(THERMAL_MGR_PERIOD_MS)); | ||
} | ||
} | ||
|
||
static obc_error_code_t collectObcLm75bdTemp(void) { | ||
obc_error_code_t errCode; | ||
|
||
float temp = 0.0f; | ||
RETURN_IF_ERROR_CODE(readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp)); | ||
|
||
telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_LM75BD_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
||
static obc_error_code_t collectObcCC1120Temp(void) { | ||
// function commented out due to cc1120 driver function being implemented in a different PR | ||
// obc_error_code_t errCode; | ||
|
||
// float temp = 0.0f; | ||
// RETURN_IF_ERROR_CODE(readTempCC1120(&temp)); | ||
|
||
// telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_CC1120_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
// RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
||
static obc_error_code_t collectObcDs3232Temp(void) { | ||
obc_error_code_t errCode; | ||
|
||
float temp = 0.0f; | ||
RETURN_IF_ERROR_CODE(getTemperatureRTC(&temp)); | ||
|
||
telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_DS3232_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make telem a flag that is passed in since we may want to just read the value sometimes to make sure we are safe without adding that as telemetry |
||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
||
static obc_error_code_t collectBMSTemp(void) { | ||
// obc_error_code_t errCode; | ||
|
||
// BMS in pr https://github.com/UWOrbital/OBC-firmware/pull/187 | ||
// float temp = 0.0f; | ||
// RETURN_IF_ERROR_CODE(getTempBMS(&temp)); //this function should get the temperature from the BMS/MAX17320 | ||
|
||
// telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_BMS_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
// RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://discord.com/channels/831191521595621387/1124186460866740314/1301569668242472980
Adding common interface into the header file