diff --git a/Grbl_Esp32/TMC2130.cpp b/Grbl_Esp32/TMC2130.cpp
new file mode 100644
index 00000000..09ae9eff
--- /dev/null
+++ b/Grbl_Esp32/TMC2130.cpp
@@ -0,0 +1,58 @@
+
+/*
+ TMC2130.cpp - Support for TMC2130 Stepper Drivers SPI Mode
+ Part of Grbl_ESP32
+
+ Copyright (c) 2019 Barton Dring for Buildlog.net LLC
+
+ GrblESP32 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. If not, see .
+*/
+
+#include "grbl.h"
+
+#ifdef X_CS_PIN
+ TMC2130Stepper TMC2130_X = TMC2130Stepper(X_CS_PIN);
+#endif
+
+#ifdef Y_CS_PIN
+ TMC2130Stepper TMC2130_Y = TMC2130Stepper(Y_CS_PIN);
+#endif
+
+#ifdef Z_CS_PIN
+ TMC2130Stepper TMC2130_Z = TMC2130Stepper(Z_CS_PIN);
+#endif
+
+void TMC2130_Init()
+{
+ #ifdef X_CS_PIN
+ TMC2130_X.begin(); // Initiate pins and registries
+ TMC2130_X.microsteps(32);
+ TMC2130_X.setCurrent(200, 0.11, 0.5);
+ TMC2130_X.stealthChop(1); // Enable extremely quiet stepping
+ #endif
+
+ #ifdef Y_CS_PIN
+ TMC2130_Y.begin(); // Initiate pins and registries
+ TMC2130_Y.microsteps(32);
+ TMC2130_Y.setCurrent(200, 0.11, 0.5);
+ TMC2130_Y.stealthChop(1); // Enable extremely quiet stepping
+ #endif
+
+ #ifdef Z_CS_PIN
+ TMC2130_Z.begin(); // Initiate pins and registries
+ TMC2130_Z.microsteps(32);
+ TMC2130_Z.setCurrent(200, 0.11, 0.5);
+ TMC2130_Z.stealthChop(1); // Enable extremely quiet stepping
+ #endif
+}
\ No newline at end of file
diff --git a/Grbl_Esp32/TMC2130.h b/Grbl_Esp32/TMC2130.h
new file mode 100644
index 00000000..8a79fc46
--- /dev/null
+++ b/Grbl_Esp32/TMC2130.h
@@ -0,0 +1,31 @@
+/*
+ TMC2130.h - Support for TMC2130 Stepper Drivers SPI Mode
+ Part of Grbl_ESP32
+
+ Copyright (c) 2019 Barton Dring for Buildlog.net LLC
+
+ GrblESP32 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. If not, see .
+*/
+
+#ifndef TMC2130_h
+ #define TMC2130_h
+
+#include "grbl.h"
+#include
+
+#ifdef USE_TMC2130
+ void TMC2130_Init();
+#endif
+
+#endif
\ No newline at end of file
diff --git a/Grbl_Esp32/cpu_map.h b/Grbl_Esp32/cpu_map.h
index c8286d03..ae75b2fd 100644
--- a/Grbl_Esp32/cpu_map.h
+++ b/Grbl_Esp32/cpu_map.h
@@ -759,26 +759,26 @@
#ifdef CPU_MAP_LOWRIDER // !!!!!!!!!!!!!!!!! Warning: Untested !!!!!!!!!!!!!!!!! //
// This is the CPU Map for the Buildlog.net MPCNC controller
- // used in lowrider mode. Low rider has (2) Z and one each of X and Y
+ // used in lowrider mode. Low rider has (2) Y and Z and one X motor
// These will not match the silkscreen or schematic descriptions
#define CPU_MAP_NAME "CPU_MAP_LOWRIDER"
#define USE_GANGED_AXES // allow two motors on an axis
- #define X_STEP_PIN GPIO_NUM_27 // use Z labeled connector
+ #define X_STEP_PIN GPIO_NUM_27 // use Z labeled connector
+ #define X_DIRECTION_PIN GPIO_NUM_33 // use Z labeled connector
#define Y_STEP_PIN GPIO_NUM_14
- #define Y_STEP_B_PIN GPIO_NUM_21 // ganged motor
+ #define Y_STEP_B_PIN GPIO_NUM_21 // ganged motor
+ #define Y_DIRECTION_PIN GPIO_NUM_25
#define Y_AXIS_SQUARING
- #define Z_STEP_PIN GPIO_NUM_12
- #define Z_STEP_B_PIN GPIO_NUM_22
+ #define Z_STEP_PIN GPIO_NUM_12 // use X labeled connector
+ #define Z_STEP_B_PIN GPIO_NUM_22 // use X labeled connector
+ #define Z_DIRECTION_PIN GPIO_NUM_26 // use X labeled connector
#define Z_AXIS_SQUARING
- #define X_DIRECTION_PIN GPIO_NUM_33 // use Z labeled connector
- #define Y_DIRECTION_PIN GPIO_NUM_25
- #define Z_DIRECTION_PIN GPIO_NUM_26 // use X labeled connector
// OK to comment out to use pin for other features
#define STEPPERS_DISABLE_PIN GPIO_NUM_13
@@ -836,6 +836,59 @@
#endif
+#ifdef CPU_MAP_TMC2130_PEN
+
+ #define CPU_MAP_NAME "ESP32_TMC2130_PEN"
+
+ #define USE_RMT_STEPS
+
+ #define USE_TMC2130 // make sure you assign chip select pins to each axis
+
+ #define X_STEP_PIN GPIO_NUM_12
+ #define X_DIRECTION_PIN GPIO_NUM_26
+ #define X_CS_PIN GPIO_NUM_17 //chip select
+ #define X_RMT_CHANNEL 0
+
+ #define Y_STEP_PIN GPIO_NUM_14
+ #define Y_DIRECTION_PIN GPIO_NUM_25
+ #define Y_CS_PIN GPIO_NUM_16 //chip select
+ #define Y_RMT_CHANNEL 1
+
+ // OK to comment out to use pin for other features
+ #define STEPPERS_DISABLE_PIN GPIO_NUM_13
+
+ // *** the flood coolant feature code is activated by defining this pins
+ // *** Comment it out to use the pin for other features
+ //#define COOLANT_FLOOD_PIN GPIO_NUM_16
+ //#define COOLANT_MIST_PIN GPIO_NUM_21
+
+ // If SPINDLE_PWM_PIN is commented out, this frees up the pin, but Grbl will still
+ // use a virtual spindle. Do not comment out the other parameters for the spindle.
+ //#define SPINDLE_PWM_PIN GPIO_NUM_17
+ #define SPINDLE_PWM_CHANNEL 0
+ // PWM Generator is based on 80,000,000 Hz counter
+ // Therefor the freq determines the resolution
+ // 80,000,000 / freq = max resolution
+ // For 5000 that is 80,000,000 / 5000 = 16000
+ // round down to nearest bit count for SPINDLE_PWM_MAX_VALUE = 13bits (8192)
+ #define SPINDLE_PWM_BASE_FREQ 5000 // Hz
+ #define SPINDLE_PWM_BIT_PRECISION 8 // be sure to match this with SPINDLE_PWM_MAX_VALUE
+ #define SPINDLE_PWM_OFF_VALUE 0
+ #define SPINDLE_PWM_MAX_VALUE 255 // (2^SPINDLE_PWM_BIT_PRECISION)
+
+ #ifndef SPINDLE_PWM_MIN_VALUE
+ #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
+ #endif
+
+ #define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)
+
+ #define X_LIMIT_PIN GPIO_NUM_2
+ #define Y_LIMIT_PIN GPIO_NUM_4
+ #define LIMIT_MASK B11
+
+#endif
+
+
// ================= common to all machines ================================
diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h
index fbff5fa3..df01a61e 100644
--- a/Grbl_Esp32/grbl.h
+++ b/Grbl_Esp32/grbl.h
@@ -83,3 +83,8 @@
#ifdef USE_SERVO_AXES
#include "servo_axis.h"
#endif
+
+#ifdef USE_TMC2130
+ #include "TMC2130.h" // https://github.com/teemuatlut/TMC2130Stepper
+#endif
+
diff --git a/Grbl_Esp32/stepper.cpp b/Grbl_Esp32/stepper.cpp
index 9d3d20b9..7a2e1ed0 100644
--- a/Grbl_Esp32/stepper.cpp
+++ b/Grbl_Esp32/stepper.cpp
@@ -360,6 +360,10 @@ void IRAM_ATTR onStepperDriverTimer(void *para) // ISR It is time to take a ste
void stepper_init()
{
+ #ifdef USE_TMC2130
+ TMC2130_Init();
+ #endif
+
#ifdef USE_RMT_STEPS
grbl_send(CLIENT_SERIAL, "[MSG:Using RMT Steps}\r\n");
initRMT();
@@ -646,11 +650,21 @@ void set_stepper_pins_on(uint8_t onMask)
#endif
#endif
-
- // ganged z not supported yet
#ifdef Z_STEP_PIN
+#ifndef Z_STEP_B_PIN // if not a ganged axis
digitalWrite(Z_STEP_PIN, (onMask & (1<