mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-27 00:05:06 +02:00
Fix VFD speed change from ISR (#811)
* Motion control calls set_rpm frequently from an ISR. Unfortunately the last change added some debug information in there, which can cause the ESP32 to crash in boundary cases. * Update Grbl.h Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com> Co-authored-by: bdring <barton.dring@gmail.com>
This commit is contained in:
@@ -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 <sdkconfig.h>
|
||||
#include <Arduino.h>
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user