1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-30 09:39:49 +02:00
* Fixed various small bugs (#605)

* Fixed various small bugs

* Fixed potential cast bug

* Fixed double reporting of errors

Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>

* Stallguard tuning (#607)

* Devt (#571)

* Handles Tranimic drivers errors better

- If an unsupported driver is specified, it will give a message and not crash.

* Cleaned up unused files

Got rid of old unipolar files
Got rid of servo axis feature - it is a motor class now
Got rid of solenoid pen feature - never really used and it should be a motor class if it is.

* Fix ENABLE_AUTHENTICATION (#569)

* Fixed authentication code.

* Removed another const cast

Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>

* Fix step leakage with inverted steps (#570)

* Fix step leakage with inverted steps

* Update build date for merge

Co-authored-by: Bart Dring <bdring@buildlog.net>

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>

* Update platformio.ini

Per PR 583

* Created an enum for mode

* Removing some unused machine defs

* Added test machine definition

* Clean up for PR

* Remove test machine def.

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>
This commit is contained in:
bdring
2020-09-21 08:58:23 -05:00
committed by GitHub
parent 050aa19bff
commit 639b6c1345
10 changed files with 43 additions and 173 deletions

View File

@@ -23,7 +23,7 @@
// Grbl versioning system // Grbl versioning system
const char* const GRBL_VERSION = "1.3a"; const char* const GRBL_VERSION = "1.3a";
const char* const GRBL_VERSION_BUILD = "20200910"; const char* const GRBL_VERSION_BUILD = "20200919";
//#include <sdkconfig.h> //#include <sdkconfig.h>
#include <Arduino.h> #include <Arduino.h>

View File

@@ -1,140 +0,0 @@
#pragma once
// clang-format off
/*
6_pack_trinamic_V1.h
Part of Grbl_ESP32
Pin assignments for the ESP32 SPI 6-axis board
2018 - Bart Dring
2020 - Mitch Bradley
2020 - Michiyasu Odaki
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 <http://www.gnu.org/licenses/>.
*/
#define MACHINE_NAME "6 Pack Controller V1 (Trinamic)"
#define N_AXIS 6
// I2S (steppers & other output-only pins)
#define USE_I2S_OUT
#define USE_I2S_STEPS
//#define DEFAULT_STEPPER ST_I2S_STATIC
#define I2S_OUT_BCK GPIO_NUM_22
#define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP
#define X_TRINAMIC_DRIVER 2130
#define X_DISABLE_PIN I2SO(0)
#define X_DIRECTION_PIN I2SO(1)
#define X_STEP_PIN I2SO(2)
#define X_CS_PIN I2SO(3)
#define X_RSENSE TMC2130_RSENSE_DEFAULT
#define Y_TRINAMIC_DRIVER X_TRINAMIC_DRIVER
#define Y_DIRECTION_PIN I2SO(4)
#define Y_STEP_PIN I2SO(5)
#define Y_DISABLE_PIN I2SO(7)
#define Y_CS_PIN I2SO(6)
#define Y_RSENSE X_RSENSE
#define Z_TRINAMIC_DRIVER X_TRINAMIC_DRIVER
#define Z_DISABLE_PIN I2SO(8)
#define Z_DIRECTION_PIN I2SO(9)
#define Z_STEP_PIN I2SO(10)
#define Z_CS_PIN I2SO(11)
#define Z_RSENSE X_RSENSE
#define A_TRINAMIC_DRIVER X_TRINAMIC_DRIVER
#define A_DIRECTION_PIN I2SO(12)
#define A_STEP_PIN I2SO(13)
#define A_DISABLE_PIN I2SO(15)
#define A_CS_PIN I2SO(14)
#define A_RSENSE X_RSENSE
#define B_TRINAMIC_DRIVER X_TRINAMIC_DRIVER
#define B_DISABLE_PIN I2SO(16)
#define B_DIRECTION_PIN I2SO(17)
#define B_STEP_PIN I2SO(18)
#define B_CS_PIN I2SO(19)
#define B_RSENSE X_RSENSE
#define C_TRINAMIC_DRIVER X_TRINAMIC_DRIVER
#define C_DIRECTION_PIN I2SO(20)
#define C_STEP_PIN I2SO(21)
#define C_DISABLE_PIN I2SO(23)
#define C_CS_PIN I2SO(22)
#define C_RSENSE X_RSENSE
/*
Socket I/O reference
The list of modules is here...
https://github.com/bdring/6-Pack_CNC_Controller/wiki/CNC-I-O-Module-List
Click on each module to get example for using the modules in the sockets
Socket #1
#1 GPIO_NUM_33
#2 GPIO_NUM_32
#3 GPIO_NUM_35 (input only)
#4 GPIO_NUM_34 (input only)
Socket #2
#1 GPIO_NUM_2
#2 GPIO_NUM_25
#3 GPIO_NUM_39 (input only)
#4 GPIO_NUM_36 (input only)
Socket #3
#1 GPIO_NUM_26
#2 GPIO_NUM_4
#3 GPIO_NUM_16
#4 GPIO_NUM_27
Socket #4
#1 GPIO_NUM_14
#2 GPIO_NUM_13
#3 GPIO_NUM_15
#4 GPIO_NUM_12
Socket #5
#1 I2SO(24) (output only)
#2 I2SO(25) (output only)
#3 I2SO26) (output only)
*/
// 4x Input Module in Socket #1
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
#define X_LIMIT_PIN GPIO_NUM_33
#define Y_LIMIT_PIN GPIO_NUM_32
#define Z_LIMIT_PIN GPIO_NUM_35
#define A_LIMIT_PIN GPIO_NUM_34
// 4x Input Module in Socket #2
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
#define B_LIMIT_PIN GPIO_NUM_2
#define C_LIMIT_PIN GPIO_NUM_25
#define PROBE_PIN GPIO_NUM_39
// 0-10v CNC Module in Socket #3
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/0-10V-Output-Module
#define SPINDLE_TYPE SpindleType::PWM
#define SPINDLE_OUTPUT_PIN GPIO_NUM_26
#define SPINDLE_ENABLE_PIN GPIO_NUM_4
#define SPINDLE_DIR_PIN GPIO_NUM_16
// === Default settings
#define DEFAULT_STEP_PULSE_MICROSECONDS I2S_OUT_USEC_PER_PULSE

View File

@@ -32,9 +32,8 @@
#define I2S_OUT_WS GPIO_NUM_17 #define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21 #define I2S_OUT_DATA GPIO_NUM_21
#define TRINAMIC_RUN_MODE Motors::TrinamicMode::CoolStep
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_HOMING_MODE Motors::TrinamicMode::StallGuard
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_STALLGUARD
// Motor Socket #1 // Motor Socket #1
#define X_TRINAMIC_DRIVER 2130 #define X_TRINAMIC_DRIVER 2130
@@ -91,16 +90,16 @@
Click on each module to get example for using the modules in the sockets Click on each module to get example for using the modules in the sockets
Socket #1 Socket #1
#1 GPIO_NUM_33 #1 GPIO_NUM_33 (Sg1)
#2 GPIO_NUM_32 #2 GPIO_NUM_32 (Sg2)
#3 GPIO_NUM_35 (input only) #3 GPIO_NUM_35 (Sg3) (input only)
#4 GPIO_NUM_34 (input only) #4 GPIO_NUM_34 (Sg4) (input only)
Socket #2 Socket #2
#1 GPIO_NUM_2 #1 GPIO_NUM_2
#2 GPIO_NUM_25 #2 GPIO_NUM_25
#3 GPIO_NUM_39 (input only) #3 GPIO_NUM_39 (Sg5) (input only)
#4 GPIO_NUM_36 (input only) #4 GPIO_NUM_36 (Sg6) (input only)
Socket #3 Socket #3
#1 GPIO_NUM_26 #1 GPIO_NUM_26
@@ -122,12 +121,14 @@ Socket #5
*/ */
// Socket #1 (Empty) // Socket #1 (Empty)
// Install StallGuard Jumpers
#define X_LIMIT_PIN GPIO_NUM_33 // Sg1 #define X_LIMIT_PIN GPIO_NUM_33 // Sg1
#define Y_LIMIT_PIN GPIO_NUM_32 // Sg2 #define Y_LIMIT_PIN GPIO_NUM_32 // Sg2
#define Z_LIMIT_PIN GPIO_NUM_35 // Sg3 #define Z_LIMIT_PIN GPIO_NUM_35 // Sg3
#define A_LIMIT_PIN GPIO_NUM_34 // Sg4 #define A_LIMIT_PIN GPIO_NUM_34 // Sg4
// Socket #2 (Empty) // Socket #2 (Empty)
// Install StallGuard Jumpers
#define B_LIMIT_PIN GPIO_NUM_39 // Sg5 #define B_LIMIT_PIN GPIO_NUM_39 // Sg5
#define C_LIMIT_PIN GPIO_NUM_36 // Sg6 #define C_LIMIT_PIN GPIO_NUM_36 // Sg6

View File

@@ -37,8 +37,8 @@
#define I2S_OUT_WS GPIO_NUM_17 #define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21 #define I2S_OUT_DATA GPIO_NUM_21
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep
#define X_TRINAMIC_DRIVER 2130 #define X_TRINAMIC_DRIVER 2130
#define X_DISABLE_PIN I2SO(0) #define X_DISABLE_PIN I2SO(0)

View File

@@ -35,8 +35,8 @@
#define TRINAMIC_DAISY_CHAIN #define TRINAMIC_DAISY_CHAIN
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep
// Use SPI enable instead of the enable pin // Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground // The hardware enable pin is tied to ground

View File

@@ -35,8 +35,8 @@
#define TRINAMIC_DAISY_CHAIN #define TRINAMIC_DAISY_CHAIN
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep
// Use SPI enable instead of the enable pin // Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground // The hardware enable pin is tied to ground

View File

@@ -35,7 +35,7 @@
#define TRINAMIC_DAISY_CHAIN #define TRINAMIC_DAISY_CHAIN
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_STEALTHCHOP #define TRINAMIC_RUN_MODE TrinamicMode::StealthChop
// Use SPI enable instead of the enable pin // Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground // The hardware enable pin is tied to ground

View File

@@ -38,8 +38,8 @@
#define X_LIMIT_PIN GPIO_NUM_32 #define X_LIMIT_PIN GPIO_NUM_32
#endif #endif
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP #define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep
#define X_STEP_PIN GPIO_NUM_12 #define X_STEP_PIN GPIO_NUM_12
#define X_DIRECTION_PIN GPIO_NUM_26 #define X_DIRECTION_PIN GPIO_NUM_26

View File

@@ -205,21 +205,21 @@ namespace Motors {
_lastMode = _mode; _lastMode = _mode;
switch (_mode) { switch (_mode) {
case TRINAMIC_MODE_STEALTHCHOP: case TrinamicMode ::StealthChop:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_STEALTHCHOP"); //grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "StealthChop");
tmcstepper->en_pwm_mode(true); tmcstepper->en_pwm_mode(true);
tmcstepper->pwm_autoscale(true); tmcstepper->pwm_autoscale(true);
tmcstepper->diag1_stall(false); tmcstepper->diag1_stall(false);
break; break;
case TRINAMIC_MODE_COOLSTEP: case TrinamicMode :: CoolStep:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_COOLSTEP"); //grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Coolstep");
tmcstepper->en_pwm_mode(false); tmcstepper->en_pwm_mode(false);
tmcstepper->pwm_autoscale(false); tmcstepper->pwm_autoscale(false);
tmcstepper->TCOOLTHRS(NORMAL_TCOOLTHRS); // when to turn on coolstep tmcstepper->TCOOLTHRS(NORMAL_TCOOLTHRS); // when to turn on coolstep
tmcstepper->THIGH(NORMAL_THIGH); tmcstepper->THIGH(NORMAL_THIGH);
break; break;
case TRINAMIC_MODE_STALLGUARD: case TrinamicMode ::StallGuard:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_STALLGUARD"); //grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Stallguard");
tmcstepper->en_pwm_mode(false); tmcstepper->en_pwm_mode(false);
tmcstepper->pwm_autoscale(false); tmcstepper->pwm_autoscale(false);
tmcstepper->TCOOLTHRS(calc_tstep(homing_feed_rate->get(), 150.0)); tmcstepper->TCOOLTHRS(calc_tstep(homing_feed_rate->get(), 150.0));
@@ -286,7 +286,7 @@ namespace Motors {
if (_disabled) { if (_disabled) {
tmcstepper->toff(TRINAMIC_TOFF_DISABLE); tmcstepper->toff(TRINAMIC_TOFF_DISABLE);
} else { } else {
if (_mode == TRINAMIC_MODE_STEALTHCHOP) { if (_mode == TrinamicMode::StealthChop) {
tmcstepper->toff(TRINAMIC_TOFF_STEALTHCHOP); tmcstepper->toff(TRINAMIC_TOFF_STEALTHCHOP);
} else { } else {
tmcstepper->toff(TRINAMIC_TOFF_COOLSTEP); tmcstepper->toff(TRINAMIC_TOFF_COOLSTEP);

View File

@@ -24,9 +24,9 @@
#include <TMCStepper.h> // https://github.com/teemuatlut/TMCStepper #include <TMCStepper.h> // https://github.com/teemuatlut/TMCStepper
#define TRINAMIC_MODE_STEALTHCHOP 0 // very quiet //#define TRINAMIC_MODE_STEALTHCHOP 0 // very quiet
#define TRINAMIC_MODE_COOLSTEP 1 // everything runs cooler so higher current possible //#define TRINAMIC_MODE_COOLSTEP 1 // everything runs cooler so higher current possible
#define TRINAMIC_MODE_STALLGUARD 2 // coolstep plus generates stall indication //#define TRINAMIC_MODE_STALLGUARD 2 // coolstep plus generates stall indication
const float TMC2130_RSENSE_DEFAULT = 0.11f; const float TMC2130_RSENSE_DEFAULT = 0.11f;
const float TMC5160_RSENSE_DEFAULT = 0.075f; const float TMC5160_RSENSE_DEFAULT = 0.075f;
@@ -39,8 +39,9 @@ const int TRINAMIC_SPI_FREQ = 100000;
const double TRINAMIC_FCLK = 12700000.0; // Internal clock Approx (Hz) used to calculate TSTEP from homing rate const double TRINAMIC_FCLK = 12700000.0; // Internal clock Approx (Hz) used to calculate TSTEP from homing rate
// ==== defaults OK to define them in your machine definition ==== // ==== defaults OK to define them in your machine definition ====
#ifndef TRINAMIC_RUN_MODE #ifndef TRINAMIC_RUN_MODE
# define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP # define TRINAMIC_RUN_MODE TrinamicMode ::StealthChop
#endif #endif
#ifndef TRINAMIC_HOMING_MODE #ifndef TRINAMIC_HOMING_MODE
@@ -60,6 +61,14 @@ const double TRINAMIC_FCLK = 12700000.0; // Internal clock Approx (Hz) used to
#endif #endif
namespace Motors { namespace Motors {
enum class TrinamicMode : uint8_t {
None = 0, // not for machine defs!
StealthChop = 1,
CoolStep = 2,
StallGuard = 3,
};
class TrinamicDriver : public StandardStepper { class TrinamicDriver : public StandardStepper {
public: public:
TrinamicDriver(uint8_t axis_index, TrinamicDriver(uint8_t axis_index,
@@ -86,14 +95,14 @@ namespace Motors {
uint32_t calc_tstep(float speed, float percent); uint32_t calc_tstep(float speed, float percent);
TMC2130Stepper* tmcstepper; // all other driver types are subclasses of this one TMC2130Stepper* tmcstepper; // all other driver types are subclasses of this one
uint8_t _homing_mode; TrinamicMode _homing_mode;
uint8_t cs_pin = UNDEFINED_PIN; // The chip select pin (can be the same for daisy chain) uint8_t cs_pin = UNDEFINED_PIN; // The chip select pin (can be the same for daisy chain)
uint16_t _driver_part_number; // example: use 2130 for TMC2130 uint16_t _driver_part_number; // example: use 2130 for TMC2130
float _r_sense; float _r_sense;
int8_t spi_index; int8_t spi_index;
protected: protected:
uint8_t _mode; TrinamicMode _mode;
uint8_t _lastMode = 255; TrinamicMode _lastMode = TrinamicMode::None;
}; };
} }