From 1a46f444fed512d86b2178f428d5ba411be5ef22 Mon Sep 17 00:00:00 2001 From: Scott Bezek Date: Mon, 14 Dec 2020 10:00:26 -0800 Subject: [PATCH] Fix a few issues with VFDSpindle critical error handling (#705) If a command is critical and fails to receive a response, it should trigger an Alarm. However, because the critical check was only evaluated if the spindle was not already unresponsive, it meant that a critical command failure would be silently ignored if a non-critical command failed before it (putting the VFDSpindle in unresponsive state). Therefore, I've moved the critical check to occur regardless of whether the spindle was already unresponsive. Second, I believe that setting `sys_rt_exec_alarm` is not sufficient to stop the machine and put it into alarm state. Other alarm conditions (such as hard limits) also run an `mc_reset()` to stop motion first. It appears that without this, motion will not be stopped, and in fact, the alarm appears to get cleared if it occurs during motion! --- Grbl_Esp32/src/Spindles/VFDSpindle.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Grbl_Esp32/src/Spindles/VFDSpindle.cpp b/Grbl_Esp32/src/Spindles/VFDSpindle.cpp index 5ac0f630..512e243a 100644 --- a/Grbl_Esp32/src/Spindles/VFDSpindle.cpp +++ b/Grbl_Esp32/src/Spindles/VFDSpindle.cpp @@ -194,12 +194,13 @@ namespace Spindles { if (retry_count == MAX_RETRIES) { if (!unresponsive) { grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Spindle RS485 Unresponsive %d", next_cmd.rx_length); - if (next_cmd.critical) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Critical Spindle RS485 Unresponsive"); - sys_rt_exec_alarm = ExecAlarm::SpindleControl; - } unresponsive = true; } + if (next_cmd.critical) { + grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Critical Spindle RS485 Unresponsive"); + mc_reset(); + sys_rt_exec_alarm = ExecAlarm::SpindleControl; + } } vTaskDelay(VFD_RS485_POLL_RATE); // TODO: What is the best value here?