diff --git a/Grbl_Esp32/src/Grbl.h b/Grbl_Esp32/src/Grbl.h index 5a56918b..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 = "20210306"; +const char* const GRBL_VERSION_BUILD = "20210311"; //#include #include diff --git a/Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_v1.h b/Grbl_Esp32/src/Machines/6_pack_external_XYZ.h similarity index 57% rename from Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_v1.h rename to Grbl_Esp32/src/Machines/6_pack_external_XYZ.h index 5bc9da03..435e274c 100644 --- a/Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_v1.h +++ b/Grbl_Esp32/src/Machines/6_pack_external_XYZ.h @@ -2,15 +2,15 @@ // clang-format off /* - 6_pack_stepstick_XYZ_v1.h + 6_pack_external_XYZ.h Covers all V1 versions V1p0, V1p1, etc Part of Grbl_ESP32 Pin assignments for the ESP32 I2S 6-axis board - 2018 - Bart Dring - 2020 - Mitch Bradley - 2020 - Michiyasu Odaki + + 2021 - Bart Dring + Grbl_ESP32 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -21,8 +21,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grbl_ESP32. If not, see . + + + 6 Pack Jumpers for External Drivers + The only jumper you set is the Vcc on 5V + Stallguard jumpers must not be connected + MS/SPI Do not need to be installed. It is OK to put them oonm the MS side + TMC5160 Is does not matter if this is installed or not on any side. + + */ -#define MACHINE_NAME "6 Pack Controller StepStick XYZ" +#define MACHINE_NAME "6 Pack External XYZ" #define N_AXIS 3 @@ -32,10 +41,6 @@ #define USE_I2S_OUT #define USE_I2S_STEPS //#define DEFAULT_STEPPER ST_I2S_STATIC -// === Default settings -#define DEFAULT_STEP_PULSE_MICROSECONDS I2S_OUT_USEC_PER_PULSE - -#define USE_STEPSTICK // makes sure MS1,2,3 !reset and !sleep are set #define I2S_OUT_BCK GPIO_NUM_22 #define I2S_OUT_WS GPIO_NUM_17 @@ -46,19 +51,35 @@ #define X_DISABLE_PIN I2SO(0) #define X_DIRECTION_PIN I2SO(1) #define X_STEP_PIN I2SO(2) -#define X_STEPPER_MS3 I2SO(3) // Motor Socket #2 #define Y_DIRECTION_PIN I2SO(4) #define Y_STEP_PIN I2SO(5) -#define Y_STEPPER_MS3 I2SO(6) #define Y_DISABLE_PIN I2SO(7) // Motor Socket #3 #define Z_DISABLE_PIN I2SO(8) #define Z_DIRECTION_PIN I2SO(9) #define Z_STEP_PIN I2SO(10) -#define Z_STEPPER_MS3 I2SO(11) + +/* +// Motor Socket #4 +#define A_DIRECTION_PIN I2SO(12) +#define A_STEP_PIN I2SO(13) +#define A_DISABLE_PIN I2SO(15) + +// Motor Socket #5 +#define B_DISABLE_PIN I2SO(16) +#define B_DIRECTION_PIN I2SO(17) +#define B_STEP_PIN I2SO(18) + +// Motor Socket #5 +#define C_DIRECTION_PIN I2SO(20) +#define C_STEP_PIN I2SO(21) +#define C_DISABLE_PIN I2SO(23) +*/ + + /* Socket I/O reference @@ -107,39 +128,16 @@ Socket #5 - -// // 4x Input Module in Socket #2 -// // https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module -#define MACRO_BUTTON_0_PIN GPIO_NUM_2 -#define MACRO_BUTTON_1_PIN GPIO_NUM_25 -#define MACRO_BUTTON_2_PIN GPIO_NUM_39 -#define MACRO_BUTTON_3_PIN GPIO_NUM_36 - -// 5V output CNC module in socket #4 -// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-5V-Buffered-Output-Module -#define SPINDLE_TYPE SpindleType::PWM -#define SPINDLE_OUTPUT_PIN GPIO_NUM_14 -#define SPINDLE_ENABLE_PIN GPIO_NUM_13 // optional -#define LASER_OUTPUT_PIN GPIO_NUM_15 // optional -#define LASER_ENABLE_PIN GPIO_NUM_12 - - - - -// // RS485 Modbus In socket #3 -// // https://github.com/bdring/6-Pack_CNC_Controller/wiki/RS485-Modbus-Module -// #define VFD_RS485_TXD_PIN GPIO_NUM_26 -// #define VFD_RS485_RTS_PIN GPIO_NUM_4 -// #define VFD_RS485_RXD_PIN GPIO_NUM_16 - -// Example (4x) 5V Buffer Output on socket #5 -// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-5V-Buffered-Output-Module -#define USER_DIGITAL_PIN_0 I2SO(24) // No PWM -#define USER_DIGITAL_PIN_1 I2SO(25) -#define USER_DIGITAL_PIN_2 I2SO(26) // M7 on M9 Off -#define USER_DIGITAL_PIN_3 I2SO(27) // M8 on M9 Off - // ================= Setting Defaults ========================== -#define DEFAULT_X_STEPS_PER_MM 800 -#define DEFAULT_Y_STEPS_PER_MM 800 -#define DEFAULT_Z_STEPS_PER_MM 800 + +// see wiki https://github.com/bdring/Grbl_Esp32/wiki/External-Stepper-Drivers +#define DEFAULT_STEP_ENABLE_DELAY 5 // how long after enable do we wait for +#define DEFAULT_STEP_PULSE_MICROSECONDS 4 // length of step pulse. Must be greater than I2S_OUT_USEC_PER_PULSE (4) with I2S +#define STEP_PULSE_DELAY 6 // gap between enable and dir changes before step + +#define DEFAULT_STEPPING_INVERT_MASK (bit(X_AXIS) | bit(Y_AXIS) | bit(Z_AXIS)) +#define DEFAULT_DIRECTION_INVERT_MASK (bit(X_AXIS) | bit(Y_AXIS) | bit(Z_AXIS)) +#define DEFAULT_INVERT_ST_ENABLE false + + + diff --git a/Grbl_Esp32/src/Motors/StandardStepper.cpp b/Grbl_Esp32/src/Motors/StandardStepper.cpp index 3f5a91da..ab417919 100644 --- a/Grbl_Esp32/src/Motors/StandardStepper.cpp +++ b/Grbl_Esp32/src/Motors/StandardStepper.cpp @@ -124,7 +124,6 @@ namespace Motors { void StandardStepper::set_direction(bool dir) { digitalWrite(_dir_pin, dir ^ _invert_dir_pin); } void StandardStepper::set_disable(bool disable) { - disable ^= step_enable_invert->get(); digitalWrite(_disable_pin, disable); } } diff --git a/Grbl_Esp32/src/SettingsDefinitions.cpp b/Grbl_Esp32/src/SettingsDefinitions.cpp index 9d7ad8f6..340ecf1a 100644 --- a/Grbl_Esp32/src/SettingsDefinitions.cpp +++ b/Grbl_Esp32/src/SettingsDefinitions.cpp @@ -400,9 +400,6 @@ void make_settings() { step_invert_mask = new AxisMaskSetting(GRBL, WG, "2", "Stepper/StepInvert", DEFAULT_STEPPING_INVERT_MASK, postMotorSetting); stepper_idle_lock_time = new IntSetting(GRBL, WG, "1", "Stepper/IdleTime", DEFAULT_STEPPER_IDLE_LOCK_TIME, 0, 255); pulse_microseconds = new IntSetting(GRBL, WG, "0", "Stepper/Pulse", DEFAULT_STEP_PULSE_MICROSECONDS, 3, 1000); - direction_delay_microseconds = new IntSetting(EXTENDED, WG, NULL, "Stepper/Direction/Delay", 0, 0, 1000); - enable_delay_microseconds = new IntSetting(EXTENDED, WG, NULL, "Stepper/Enable/Delay", 0, 0, 1000); // microseconds - direction_delay_microseconds = new IntSetting(EXTENDED, WG, NULL, "Stepper/Direction/Delay", STEP_PULSE_DELAY, 0, 1000); enable_delay_microseconds = new IntSetting(EXTENDED, WG, NULL, "Stepper/Enable/Delay", DEFAULT_STEP_ENABLE_DELAY, 0, 1000); // microseconds diff --git a/Grbl_Esp32/src/Spindles/VFDSpindle.cpp b/Grbl_Esp32/src/Spindles/VFDSpindle.cpp index a332d0fd..956f3c6a 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 diff --git a/Grbl_Esp32/src/WebUI/WebServer.cpp b/Grbl_Esp32/src/WebUI/WebServer.cpp index b4a1cef5..1a3f2e99 100644 --- a/Grbl_Esp32/src/WebUI/WebServer.cpp +++ b/Grbl_Esp32/src/WebUI/WebServer.cpp @@ -888,7 +888,6 @@ namespace WebUI { path = ""; _webserver->sendHeader("Cache-Control", "no-cache"); _webserver->send(200, "application/json", jsonfile); - _upload_status = UploadStatusType::NONE; } //push error code and message to websocket @@ -1226,8 +1225,8 @@ namespace WebUI { String sstatus = "Ok"; if ((_upload_status == UploadStatusType::FAILED) || (_upload_status == UploadStatusType::FAILED)) { sstatus = "Upload failed"; - _upload_status = UploadStatusType::NONE; } + _upload_status = UploadStatusType::NONE; bool list_files = true; uint64_t totalspace = 0; uint64_t usedspace = 0; @@ -1332,6 +1331,7 @@ namespace WebUI { s += " does not exist on SD Card\"}"; _webserver->send(200, "application/json", s); SD.end(); + set_sd_state(SDState::Idle); return; } if (list_files) { @@ -1408,7 +1408,6 @@ namespace WebUI { jsonfile += "}"; _webserver->sendHeader("Cache-Control", "no-cache"); _webserver->send(200, "application/json", jsonfile); - _upload_status = UploadStatusType::NONE; set_sd_state(SDState::Idle); SD.end(); }