1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-03 11:22:38 +02:00

Added TMC2130 Support

- Added TMC2130 Support from that branch
- Added a CPU mape for testing
This commit is contained in:
bdring
2019-05-10 11:41:52 -05:00
parent 75f8e73b3c
commit f28f312f75
5 changed files with 151 additions and 0 deletions

58
Grbl_Esp32/TMC2130.cpp Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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
}

31
Grbl_Esp32/TMC2130.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TMC2130_h
#define TMC2130_h
#include "grbl.h"
#include <TMC2130Stepper.h>
#ifdef USE_TMC2130
void TMC2130_Init();
#endif
#endif

View File

@@ -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 ================================

View File

@@ -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

View File

@@ -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();