From e0c0ccb26e3b5276bebbda8806719b3971073e27 Mon Sep 17 00:00:00 2001 From: bdring Date: Fri, 28 May 2021 10:29:24 -0500 Subject: [PATCH] Moved step/dir/enable timing to global --- Grbl_Esp32/Custom/CoreXY.cpp | 2 +- Grbl_Esp32/data/config.yaml | 42 ++++++++++++++++++++--- Grbl_Esp32/src/MachineConfig.cpp | 2 ++ Grbl_Esp32/src/Motors/StandardStepper.cpp | 3 +- Grbl_Esp32/src/Motors/StandardStepper.h | 5 --- Grbl_Esp32/src/Stepper.cpp | 8 ++++- Grbl_Esp32/src/Stepper.h | 2 -- 7 files changed, 48 insertions(+), 16 deletions(-) diff --git a/Grbl_Esp32/Custom/CoreXY.cpp b/Grbl_Esp32/Custom/CoreXY.cpp index 074df45b..8bd515a5 100644 --- a/Grbl_Esp32/Custom/CoreXY.cpp +++ b/Grbl_Esp32/Custom/CoreXY.cpp @@ -201,7 +201,7 @@ bool user_defined_homing(AxisMask cycle_mask) { } while (!switch_touched); #ifdef USE_I2S_STEPS - if (current_stepper == ST_I2S_STREAM) { + if (config->_stepType == ST_I2S_STREAM) { if (!approach) { delay_ms(I2S_OUT_DELAY_MS); } diff --git a/Grbl_Esp32/data/config.yaml b/Grbl_Esp32/data/config.yaml index f196f18d..9dda3f2d 100644 --- a/Grbl_Esp32/data/config.yaml +++ b/Grbl_Esp32/data/config.yaml @@ -1,14 +1,46 @@ -name: "Debug config" -board: Debug-board +name: "ESP32 Dev Controller V4" +board: "ESP32 Dev Controller V4" +yaml_wiki: "https://github.com/bdring/Grbl_Esp32/wiki/YAML-Config-File" + +idle_time: 250 +step_type: rmt +dir_delay_microseconds: 1 +pulse_microseconds: 2 +disable_delay_us: 0 axes: number_axis: 3 + shared_stepper_disable: gpio.13:low + + x: + limit: gpio.32:high + + gang0: + stepstick: + direction: gpio:14 + step: gpio.12 + gang1: + null_motor: + + y: + limit: gpio.4:low + + gang0: + stepstick: + direction: gpio:15 + step: gpio.26 + gang1: + stepstick: + direction: gpio:33 + step: gpio.27 + laser_mode: true coolant: - flood: gpio.26:low - mist: gpio.4 + flood: gpio.25:low + mist: gpio.21 probe: - pin: gpio.12:high:pu + pin: gpio.32:high:pu + \ No newline at end of file diff --git a/Grbl_Esp32/src/MachineConfig.cpp b/Grbl_Esp32/src/MachineConfig.cpp index 3f1836b1..316a9043 100644 --- a/Grbl_Esp32/src/MachineConfig.cpp +++ b/Grbl_Esp32/src/MachineConfig.cpp @@ -369,6 +369,8 @@ void MachineConfig::handle(Configuration::HandlerBase& handler) { handler.handle("coolant", _coolant); handler.handle("probe", _probe); handler.handle("pulse_microseconds", _pulseMicroSeconds); + handler.handle("dir_delay_microseconds", _directionDelayMicroSeconds); + handler.handle("disable_delay_us", _disableDelayMicroSeconds); handler.handle("board", _board); handler.handle("name", _name); handler.handle("idle_time", _idleTime); diff --git a/Grbl_Esp32/src/Motors/StandardStepper.cpp b/Grbl_Esp32/src/Motors/StandardStepper.cpp index 707be3f2..e01742b1 100644 --- a/Grbl_Esp32/src/Motors/StandardStepper.cpp +++ b/Grbl_Esp32/src/Motors/StandardStepper.cpp @@ -66,8 +66,7 @@ namespace Motors { rmtConfig.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; rmtConfig.tx_config.idle_output_en = true; - auto stepPulseDelay = _direction_delay_us; - rmtItem[0].duration0 = stepPulseDelay < 1 ? 1 : stepPulseDelay * 4; + rmtItem[0].duration0 = config->_directionDelayMicroSeconds < 1 ? 1 : config->_directionDelayMicroSeconds * 4; rmtItem[0].duration1 = 4 * config->_pulseMicroSeconds; rmtItem[1].duration0 = 0; diff --git a/Grbl_Esp32/src/Motors/StandardStepper.h b/Grbl_Esp32/src/Motors/StandardStepper.h index 26257076..aaeea879 100644 --- a/Grbl_Esp32/src/Motors/StandardStepper.h +++ b/Grbl_Esp32/src/Motors/StandardStepper.h @@ -29,9 +29,6 @@ namespace Motors { Pin _dir_pin; Pin _disable_pin; - int _direction_delay_us = 0; - int _enable_delay_us = 0; - // Configuration handlers: void validate() const override { Assert(!_step_pin.undefined(), "Step pin should be configured."); @@ -42,8 +39,6 @@ namespace Motors { handler.handle("step", _step_pin); handler.handle("direction", _dir_pin); handler.handle("disable", _disable_pin); - handler.handle("direction_delay_us", _direction_delay_us); - handler.handle("enable_delay_us", _enable_delay_us); } // Name of the configurable. Must match the name registered in the cpp file. diff --git a/Grbl_Esp32/src/Stepper.cpp b/Grbl_Esp32/src/Stepper.cpp index 65c75c5b..017933c9 100644 --- a/Grbl_Esp32/src/Stepper.cpp +++ b/Grbl_Esp32/src/Stepper.cpp @@ -353,7 +353,13 @@ void stepper_init() { busy.store(false); grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Axis count %d", config->_axes->_numberAxis); - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Step type: %s", stepTypes[config->_stepType].name); + grbl_msg_sendf(CLIENT_SERIAL, + MsgLevel::Info, + "Step type:%s Pulse:%dus Dsbl Delay:%dus Dir Delay:%dus", + stepTypes[config->_stepType].name, + config->_pulseMicroSeconds, + config->_disableDelayMicroSeconds, + config->_directionDelayMicroSeconds); #ifdef USE_I2S_STEPS // I2S stepper stream mode use callback but timer interrupt diff --git a/Grbl_Esp32/src/Stepper.h b/Grbl_Esp32/src/Stepper.h index f000088a..4f69424a 100644 --- a/Grbl_Esp32/src/Stepper.h +++ b/Grbl_Esp32/src/Stepper.h @@ -39,8 +39,6 @@ enum stepper_id_t { extern uint64_t stepper_idle_counter; extern bool stepper_idle; -extern stepper_id_t current_stepper; - void stepper_init(); void stepper_switch(stepper_id_t new_stepper);