Progress in error handling
This commit is contained in:
parent
62a3e06baa
commit
78417e0c8c
@ -45,7 +45,7 @@ struct oven_pid_errors {
|
||||
|
||||
struct oven_pid_status {
|
||||
bool active;
|
||||
bool aborted;
|
||||
bool error_set;
|
||||
struct oven_pid_errors error_flags;
|
||||
float target_temp;
|
||||
float current_temp;
|
||||
@ -58,6 +58,8 @@ void oven_driver_set_power(uint8_t power);
|
||||
|
||||
void oven_driver_disable(void);
|
||||
|
||||
void oven_pid_ack_errors(void);
|
||||
|
||||
void oven_pid_init(struct pid_controller *controller_to_copy);
|
||||
|
||||
void oven_pid_handle(float target_temp);
|
||||
|
@ -244,12 +244,12 @@ int main(void)
|
||||
}
|
||||
|
||||
pt1000_status = adc_pt1000_check_error();
|
||||
global_error_state = pid_status->aborted || !!safety_adc_get_errors() || !!pt1000_status;
|
||||
global_error_state = pid_status->error_set || !!safety_adc_get_errors() || !!pt1000_status;
|
||||
|
||||
menu_wait_request = reflow_menu_handle();
|
||||
|
||||
/* Deactivate oven output in case of error! */
|
||||
if (!pid_status->active || pid_status->aborted || global_error_state)
|
||||
if (!pid_status->active || global_error_state)
|
||||
oven_driver_set_power(0U);
|
||||
|
||||
handle_shell_uart_input(shell_handle);
|
||||
|
@ -29,7 +29,7 @@ static struct pid_controller oven_pid;
|
||||
|
||||
static struct oven_pid_status oven_pid_current_status = {
|
||||
.active = false,
|
||||
.aborted = false,
|
||||
.error_set = false,
|
||||
.target_temp = 0.0f,
|
||||
.current_temp = 0.0f,
|
||||
.timestamp_last_run = 0ULL
|
||||
@ -71,6 +71,17 @@ void oven_driver_disable()
|
||||
rcc_manager_disable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_TIM_RCC_MASK));
|
||||
}
|
||||
|
||||
void oven_pid_ack_errors(void)
|
||||
{
|
||||
oven_pid_current_status.error_set = false;
|
||||
oven_pid_current_status.error_flags.vref_tol = false;
|
||||
oven_pid_current_status.error_flags.pt1000_other = false;
|
||||
oven_pid_current_status.error_flags.generic_error = false;
|
||||
oven_pid_current_status.error_flags.pt1000_adc_off = false;
|
||||
oven_pid_current_status.error_flags.controller_overtemp = false;
|
||||
oven_pid_current_status.error_flags.pt1000_adc_watchdog = false;
|
||||
}
|
||||
|
||||
void oven_pid_init(struct pid_controller *controller_to_copy)
|
||||
{
|
||||
pid_copy(&oven_pid, controller_to_copy);
|
||||
@ -78,12 +89,7 @@ void oven_pid_init(struct pid_controller *controller_to_copy)
|
||||
oven_pid.output_sat_max = 100.0f;
|
||||
oven_pid_current_status.timestamp_last_run = 0ULL;
|
||||
oven_pid_current_status.active = true;
|
||||
oven_pid_current_status.error_flags.vref_tol = false;
|
||||
oven_pid_current_status.error_flags.pt1000_other = false;
|
||||
oven_pid_current_status.error_flags.generic_error = false;
|
||||
oven_pid_current_status.error_flags.pt1000_adc_off = false;
|
||||
oven_pid_current_status.error_flags.controller_overtemp = false;
|
||||
oven_pid_current_status.error_flags.pt1000_adc_watchdog = false;
|
||||
oven_pid_ack_errors();
|
||||
}
|
||||
|
||||
void oven_pid_handle(float target_temp)
|
||||
@ -93,7 +99,7 @@ void oven_pid_handle(float target_temp)
|
||||
int resistance_status;
|
||||
enum adc_pt1000_error pt1000_error;
|
||||
|
||||
if (oven_pid_current_status.active && !oven_pid_current_status.aborted) {
|
||||
if (oven_pid_current_status.active && !oven_pid_current_status.error_set) {
|
||||
if (systick_ticks_have_passed(oven_pid_current_status.timestamp_last_run,
|
||||
(uint64_t)(oven_pid.sample_period * 1000))) {
|
||||
|
||||
@ -127,7 +133,7 @@ void oven_pid_report_error(enum oven_pid_error_report report)
|
||||
struct oven_pid_errors *e = &oven_pid_current_status.error_flags;
|
||||
|
||||
oven_pid_current_status.active = false;
|
||||
oven_pid_current_status.aborted = true;
|
||||
oven_pid_current_status.error_set = true;
|
||||
|
||||
if (report == 0) {
|
||||
e->generic_error = true;
|
||||
|
@ -361,6 +361,20 @@ static shellmatta_retCode_t shell_cmd_safety_adc(const shellmatta_handle_t handl
|
||||
shellmatta_printf(handle, "VREF:\t%8.2f\tmV\r\n", safety_adc_get_vref());
|
||||
shellmatta_printf(handle, "TEMP:\t%8.2f\tdeg. Celsius\r\n", safety_adc_get_temp());
|
||||
|
||||
shellmatta_printf(handle, "Errors:\t%X", safety_adc_get_errors());
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_safety_adc_clear_error(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)length;
|
||||
(void)arguments;
|
||||
(void)handle;
|
||||
|
||||
safety_adc_clear_errors();
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
@ -374,7 +388,7 @@ static shellmatta_retCode_t shell_cmd_safety_adc(const shellmatta_handle_t handl
|
||||
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
||||
//} shellmatta_cmd_t;
|
||||
|
||||
static shellmatta_cmd_t cmd[14] = {
|
||||
static shellmatta_cmd_t cmd[15] = {
|
||||
{
|
||||
.cmd = "version",
|
||||
.cmdAlias = "ver",
|
||||
@ -485,6 +499,14 @@ static shellmatta_cmd_t cmd[14] = {
|
||||
.helpText = "",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_safety_adc,
|
||||
.next = &cmd[14],
|
||||
},
|
||||
{
|
||||
.cmd = "safety-adc-clear-error",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_safety_adc_clear_error,
|
||||
.next = NULL,
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user