From 4bce69e15279a8d37710295a3f957eaf31e5bca3 Mon Sep 17 00:00:00 2001 From: bdring Date: Thu, 16 Apr 2020 09:56:38 -0500 Subject: [PATCH 1/2] Machine file cleanup Cleaning up tmc2130_pen for a user. - Removed the Servo and Solenoid setup from config.h. It was typically used from machine definition files. - Added some defines for default resistor values. Note: some of this may be redone with saved settings in the future. --- Grbl_Esp32/Machines/midtbot.h | 4 +-- Grbl_Esp32/Machines/polar_coaster.h | 4 +-- Grbl_Esp32/Machines/spi_daisy_4axis.h | 8 ++--- Grbl_Esp32/Machines/spi_daisy_4axis_xyyz.h | 8 ++--- Grbl_Esp32/Machines/tmc2130_pen.h | 36 +++++++++++----------- Grbl_Esp32/config.h | 10 ------ Grbl_Esp32/grbl_trinamic.h | 4 +++ 7 files changed, 32 insertions(+), 42 deletions(-) diff --git a/Grbl_Esp32/Machines/midtbot.h b/Grbl_Esp32/Machines/midtbot.h index 4654d986..7a030607 100644 --- a/Grbl_Esp32/Machines/midtbot.h +++ b/Grbl_Esp32/Machines/midtbot.h @@ -40,9 +40,7 @@ #define Y_LIMIT_PIN GPIO_NUM_4 #define LIMIT_MASK B11 -#ifndef USE_SERVO_AXES // maybe set in config.h - #define USE_SERVO_AXES -#endif +#define USE_SERVO_AXES #define SERVO_Z_PIN GPIO_NUM_27 #define SERVO_Z_RANGE_MIN 0.0 diff --git a/Grbl_Esp32/Machines/polar_coaster.h b/Grbl_Esp32/Machines/polar_coaster.h index 0f6e0a7c..e4b35649 100644 --- a/Grbl_Esp32/Machines/polar_coaster.h +++ b/Grbl_Esp32/Machines/polar_coaster.h @@ -43,9 +43,7 @@ #define STEPPERS_DISABLE_PIN GPIO_NUM_17 -#ifndef USE_SERVO_AXES // maybe set in config.h - #define USE_SERVO_AXES -#endif +#define USE_SERVO_AXES #define SERVO_Z_PIN GPIO_NUM_16 #define SERVO_Z_RANGE_MIN 0.0 diff --git a/Grbl_Esp32/Machines/spi_daisy_4axis.h b/Grbl_Esp32/Machines/spi_daisy_4axis.h index 3e3dd803..559fdb48 100644 --- a/Grbl_Esp32/Machines/spi_daisy_4axis.h +++ b/Grbl_Esp32/Machines/spi_daisy_4axis.h @@ -38,21 +38,21 @@ #define USE_TRINAMIC_ENABLE #define X_DRIVER_TMC2130 // Which Driver Type? -#define X_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define X_RSENSE TMC2130_RSENSE_DEFAULT #define X_STEP_PIN GPIO_NUM_12 #define X_DIRECTION_PIN GPIO_NUM_14 #define X_TRINAMIC // using SPI control #define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin #define Y_DRIVER_TMC2130 // Which Driver Type? -#define Y_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define Y_RSENSE TMC2130_RSENSE_DEFAULT #define Y_STEP_PIN GPIO_NUM_27 #define Y_DIRECTION_PIN GPIO_NUM_26 #define Y_TRINAMIC // using SPI control #define Y_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin #define Z_DRIVER_TMC2130 // Which Driver Type? -#define Z_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define Z_RSENSE TMC2130_RSENSE_DEFAULT #define Z_STEP_PIN GPIO_NUM_15 #define Z_DIRECTION_PIN GPIO_NUM_2 #define Z_TRINAMIC // using SPI control @@ -60,7 +60,7 @@ #if (N_AXIS == 4) #define A_DRIVER_TMC2130 // Which Driver Type? - #define A_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 + #define A_RSENSE TMC2130_RSENSE_DEFAULT #define A_STEP_PIN GPIO_NUM_33 #define A_DIRECTION_PIN GPIO_NUM_32 #define A_TRINAMIC // using SPI control diff --git a/Grbl_Esp32/Machines/spi_daisy_4axis_xyyz.h b/Grbl_Esp32/Machines/spi_daisy_4axis_xyyz.h index 820d6ef0..c279eeb6 100644 --- a/Grbl_Esp32/Machines/spi_daisy_4axis_xyyz.h +++ b/Grbl_Esp32/Machines/spi_daisy_4axis_xyyz.h @@ -42,7 +42,7 @@ // Y motor connects to the 1st driver #define X_DRIVER_TMC2130 // Which Driver Type? -#define X_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define X_RSENSE TMC2130_RSENSE_DEFAULT #define X_STEP_PIN GPIO_NUM_12 #define X_DIRECTION_PIN GPIO_NUM_14 #define X_TRINAMIC // using SPI control @@ -50,7 +50,7 @@ // Y motor connects to the 2nd driver #define Y_DRIVER_TMC2130 // Which Driver Type? -#define Y_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define Y_RSENSE TMC2130_RSENSE_DEFAULT #define Y_STEP_PIN GPIO_NUM_27 #define Y_DIRECTION_PIN GPIO_NUM_26 #define Y_TRINAMIC // using SPI control @@ -58,7 +58,7 @@ // Y2 motor connects to the 2nd driver #define Y2_DRIVER_TMC2130 // Which Driver Type? -#define Y2_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define Y2_RSENSE TMC2130_RSENSE_DEFAULT #define Y2_STEP_PIN GPIO_NUM_15 // Z on schem #define Y2_DIRECTION_PIN GPIO_NUM_2 // Z on schem #define Y2_TRINAMIC // using SPI control @@ -68,7 +68,7 @@ // Z Axis motor connects to the 4th driver #define Z_DRIVER_TMC2130 // Which Driver Type? -#define Z_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160 +#define Z_RSENSE TMC2130_RSENSE_DEFAULT #define Z_STEP_PIN GPIO_NUM_33 // A on schem #define Z_DIRECTION_PIN GPIO_NUM_32 // A on schem #define Z_TRINAMIC // using SPI control diff --git a/Grbl_Esp32/Machines/tmc2130_pen.h b/Grbl_Esp32/Machines/tmc2130_pen.h index 82900f8d..059abcdd 100644 --- a/Grbl_Esp32/Machines/tmc2130_pen.h +++ b/Grbl_Esp32/Machines/tmc2130_pen.h @@ -42,36 +42,36 @@ #define X_TRINAMIC // using SPI control #define X_DRIVER_TMC2130 // Which Driver Type? #define X_CS_PIN GPIO_NUM_17 //chip select -#define X_RSENSE 0.11f // .11 Ohm +#define X_RSENSE TMC2130_RSENSE_DEFAULT #define Y_STEP_PIN GPIO_NUM_14 #define Y_DIRECTION_PIN GPIO_NUM_25 #define Y_TRINAMIC // using SPI control #define Y_DRIVER_TMC2130 // Which Driver Type? #define Y_CS_PIN GPIO_NUM_16 //chip select -#define Y_RSENSE 0.11f // .11 Ohm +#define Y_RSENSE TMC2130_RSENSE_DEFAULT // OK to comment out to use pin for other features #define STEPPERS_DISABLE_PIN GPIO_NUM_13 -#ifndef USE_SERVO_AXES // may be set in config.h - #define USE_SERVO_AXES + + +// Define one of these 2 options for spindle or servo +#define USE_SERVO_AXES +//#define USE_SPINDLE + +#ifdef USE_SERVO_AXES + #define SERVO_Z_PIN GPIO_NUM_27 // comment this out if PWM spindle/laser control. + #define SERVO_Z_RANGE_MIN 0.0 + #define SERVO_Z_RANGE_MAX 5.0 + #define SERVO_Z_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value + #define SERVO_Z_HOME_POS SERVO_Z_RANGE_MAX // move to max during homing + #define SERVO_Z_MPOS false // will not use mpos, uses work coordinates +#else + #define SPINDLE_PWM_PIN GPIO_NUM_27 #endif -#define SERVO_Z_PIN GPIO_NUM_27 // comment this out if PWM spindle/laser control. -#define SERVO_Z_RANGE_MIN 0.0 -#define SERVO_Z_RANGE_MAX 5.0 -#define SERVO_Z_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value -#define SERVO_Z_HOME_POS SERVO_Z_RANGE_MAX // move to max during homing -#define SERVO_Z_MPOS false // will not use mpos, uses work coordinates - - -// Comment out servo pin and uncomment spindle pwm pin to use the servo PWM to control a spindle -/* -#define SPINDLE_PWM_PIN GPIO_NUM_27 -*/ - -// #define X_LIMIT_PIN See version section +// #define X_LIMIT_PIN See version section at beginning of file #define Y_LIMIT_PIN GPIO_NUM_4 #define LIMIT_MASK B11 diff --git a/Grbl_Esp32/config.h b/Grbl_Esp32/config.h index 0cb8d532..4b6507eb 100644 --- a/Grbl_Esp32/config.h +++ b/Grbl_Esp32/config.h @@ -303,16 +303,6 @@ Some features should not be changed. See notes below. // have the same steps per mm internally. // #define COREXY // Default disabled. Uncomment to enable. -// Enable using a servo for the Z axis on a pen type machine. -// You typically should not define a pin for the Z axis in the machine definition file -// You should configure your settings in servo_pen.h -// #define USE_SERVO_AXES // the new method -// define your servo pin here or in the machine definition file -//#define SERVO_PEN_PIN GPIO_NUM_27 - -// Enable using a solenoid for the Z axis on a pen type machine -// #define USE_PEN_SOLENOID - // Inverts select limit pin states based on the following mask. This effects all limit pin functions, // such as hard limits and homing. However, this is different from overall invert limits setting. // This build option will invert only the limit pins defined here, and then the invert limits setting diff --git a/Grbl_Esp32/grbl_trinamic.h b/Grbl_Esp32/grbl_trinamic.h index ef886b85..0ca10c12 100644 --- a/Grbl_Esp32/grbl_trinamic.h +++ b/Grbl_Esp32/grbl_trinamic.h @@ -25,6 +25,10 @@ #include "grbl.h" +// the default current sense resistors used on most driver modules +#define TMC2130_RSENSE_DEFAULT 0.11f +#define TMC5160_RSENSE_DEFAULT 0.075f + #ifdef USE_TRINAMIC #include // https://github.com/teemuatlut/TMCStepper void Trinamic_Init(); From 57956371e7bc3ac3db4f7ee024ee7d2498b1c7a3 Mon Sep 17 00:00:00 2001 From: bdring Date: Fri, 17 Apr 2020 13:33:40 -0500 Subject: [PATCH 2/2] Machine file cleanup - Split out some options into individual files. --- Grbl_Esp32/Machines/spi_daisy_4axis_xyz.h | 82 +++++++++++++++++++ ...i_daisy_4axis.h => spi_daisy_4axis_xyza.h} | 26 +++--- Grbl_Esp32/grbl.h | 2 +- 3 files changed, 93 insertions(+), 17 deletions(-) create mode 100644 Grbl_Esp32/Machines/spi_daisy_4axis_xyz.h rename Grbl_Esp32/Machines/{spi_daisy_4axis.h => spi_daisy_4axis_xyza.h} (83%) diff --git a/Grbl_Esp32/Machines/spi_daisy_4axis_xyz.h b/Grbl_Esp32/Machines/spi_daisy_4axis_xyz.h new file mode 100644 index 00000000..3a767be5 --- /dev/null +++ b/Grbl_Esp32/Machines/spi_daisy_4axis_xyz.h @@ -0,0 +1,82 @@ +/* + spi_daisy_4axis.h + Part of Grbl_ESP32 + + Pin assignments for a 4-axis machine using Triaminic drivers + in daisy-chained SPI mode. + https://github.com/bdring/4_Axis_SPI_CNC + + 2019 - Bart Dring + 2020 - Mitch Bradley + + 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 + (at your option) any later version. + + Grbl is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . +*/ + +#define MACHINE_NAME "SPI_DAISY_4X_XYZ" + +#ifdef N_AXIS + #undef N_AXIS +#endif +#define N_AXIS 3 + +#define USE_TRINAMIC +#define TRINAMIC_DAISY_CHAIN + +// Use SPI enable instead of the enable pin +// The hardware enable pin is tied to ground +#define USE_TRINAMIC_ENABLE + +#define X_DRIVER_TMC2130 // Which Driver Type? +#define X_RSENSE TMC2130_RSENSE_DEFAULT +#define X_STEP_PIN GPIO_NUM_12 +#define X_DIRECTION_PIN GPIO_NUM_14 +#define X_TRINAMIC // using SPI control +#define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin + +#define Y_DRIVER_TMC2130 // Which Driver Type? +#define Y_RSENSE TMC2130_RSENSE_DEFAULT +#define Y_STEP_PIN GPIO_NUM_27 +#define Y_DIRECTION_PIN GPIO_NUM_26 +#define Y_TRINAMIC // using SPI control +#define Y_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin + +#define Z_DRIVER_TMC2130 // Which Driver Type? +#define Z_RSENSE TMC2130_RSENSE_DEFAULT +#define Z_STEP_PIN GPIO_NUM_15 +#define Z_DIRECTION_PIN GPIO_NUM_2 +#define Z_TRINAMIC // using SPI control +#define Z_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin + + +// Mist is a 3.3V output +// Turn on with M7 and off with M9 +#define COOLANT_MIST_PIN GPIO_NUM_21 + +#define SPINDLE_PWM_PIN GPIO_NUM_25 +#define SPINDLE_ENABLE_PIN GPIO_NUM_4 + +// Relay operation +// Install Jumper near relay +// For spindle Use max RPM of 1 +// For PWM remove jumper and set MAX RPM to something higher ($30 setting) +// Interlock jumper along top edge needs to be installed for both versions +#define DEFAULT_SPINDLE_RPM_MAX 1 // Should be 1 for relay operation + +#define PROBE_PIN GPIO_NUM_22 + +#define X_LIMIT_PIN GPIO_NUM_36 +#define Y_LIMIT_PIN GPIO_NUM_39 +#define Z_LIMIT_PIN GPIO_NUM_34 +#define LIMIT_MASK B0111 + diff --git a/Grbl_Esp32/Machines/spi_daisy_4axis.h b/Grbl_Esp32/Machines/spi_daisy_4axis_xyza.h similarity index 83% rename from Grbl_Esp32/Machines/spi_daisy_4axis.h rename to Grbl_Esp32/Machines/spi_daisy_4axis_xyza.h index 559fdb48..e85abc66 100644 --- a/Grbl_Esp32/Machines/spi_daisy_4axis.h +++ b/Grbl_Esp32/Machines/spi_daisy_4axis_xyza.h @@ -23,7 +23,7 @@ along with Grbl_ESP32. If not, see . */ -#define MACHINE_NAME "SPI_DAISY_4X" +#define MACHINE_NAME "SPI_DAISY_4X XYZA" #ifdef N_AXIS #undef N_AXIS @@ -58,14 +58,13 @@ #define Z_TRINAMIC // using SPI control #define Z_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin -#if (N_AXIS == 4) - #define A_DRIVER_TMC2130 // Which Driver Type? - #define A_RSENSE TMC2130_RSENSE_DEFAULT - #define A_STEP_PIN GPIO_NUM_33 - #define A_DIRECTION_PIN GPIO_NUM_32 - #define A_TRINAMIC // using SPI control - #define A_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin -#endif + +#define A_DRIVER_TMC2130 // Which Driver Type? +#define A_RSENSE TMC2130_RSENSE_DEFAULT +#define A_STEP_PIN GPIO_NUM_33 +#define A_DIRECTION_PIN GPIO_NUM_32 +#define A_TRINAMIC // using SPI control +#define A_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin // Mist is a 3.3V output // Turn on with M7 and off with M9 @@ -86,10 +85,5 @@ #define X_LIMIT_PIN GPIO_NUM_36 #define Y_LIMIT_PIN GPIO_NUM_39 #define Z_LIMIT_PIN GPIO_NUM_34 - -#if (N_AXIS == 4) - #define A_LIMIT_PIN GPIO_NUM_35 - #define LIMIT_MASK B1111 -#else - #define LIMIT_MASK B0111 -#endif +#define A_LIMIT_PIN GPIO_NUM_35 +#define LIMIT_MASK B1111 diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index c554dec6..31d760ca 100644 --- a/Grbl_Esp32/grbl.h +++ b/Grbl_Esp32/grbl.h @@ -20,7 +20,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20200412" +#define GRBL_VERSION_BUILD "20200417" //#include #include