diff --git a/Grbl_Esp32/src/Grbl.h b/Grbl_Esp32/src/Grbl.h index 7c191801..e17bbfff 100644 --- a/Grbl_Esp32/src/Grbl.h +++ b/Grbl_Esp32/src/Grbl.h @@ -22,7 +22,7 @@ // Grbl versioning system const char* const GRBL_VERSION = "1.3a"; -const char* const GRBL_VERSION_BUILD = "20210308"; +const char* const GRBL_VERSION_BUILD = "20210311"; //#include #include diff --git a/Grbl_Esp32/src/Spindles/VFDSpindle.cpp b/Grbl_Esp32/src/Spindles/VFDSpindle.cpp index a332d0fd..29c575c7 100644 --- a/Grbl_Esp32/src/Spindles/VFDSpindle.cpp +++ b/Grbl_Esp32/src/Spindles/VFDSpindle.cpp @@ -406,6 +406,11 @@ namespace Spindles { if (_current_state != state) { // already at the desired state. This function gets called a lot. set_mode(state, critical); // critical if we are in a job + + if (rpm != 0 && (rpm < _min_rpm || rpm > _max_rpm)) { + grbl_msg_sendf(CLIENT_ALL, MsgLevel::Info, "VFD: Requested speed %d outside range:(%d,%d)", rpm, _min_rpm, _max_rpm); + } + set_rpm(rpm); if (state == SpindleState::Disable) { @@ -422,6 +427,10 @@ namespace Spindles { } } else { if (_current_rpm != rpm) { + if (rpm != 0 && (rpm < _min_rpm || rpm > _max_rpm)) { + grbl_msg_sendf(CLIENT_ALL, MsgLevel::Info, "VFD: Requested speed %d outside range:(%d,%d)", rpm, _min_rpm, _max_rpm); + } + set_rpm(rpm); if (rpm > _current_rpm) { @@ -524,10 +533,11 @@ namespace Spindles { // apply override rpm = rpm * sys.spindle_speed_ovr / 100; // Scale by spindle speed override value (uint8_t percent) - if (rpm < _min_rpm || rpm > _max_rpm) { - grbl_msg_sendf(CLIENT_ALL, MsgLevel::Info, "VFD: Requested speed %d outside range:(%d,%d)", rpm, _min_rpm, _max_rpm); + if (rpm != 0 && (rpm < _min_rpm || rpm > _max_rpm)) { + // NOTE: Don't add a info message here; this method is called from the stepper_pulse_func ISR method, so + // emitting debug information could crash the ESP32. + rpm = constrain(rpm, _min_rpm, _max_rpm); - grbl_msg_sendf(CLIENT_ALL, MsgLevel::Info, "VFD: Requested speed changed to %d", rpm); } // apply limits @@ -554,7 +564,6 @@ namespace Spindles { ModbusCommand rpm_cmd; rpm_cmd.msg[0] = VFD_RS485_ADDR; - set_speed_command(rpm, rpm_cmd); rpm_cmd.critical = (rpm == 0);