mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 10:53:01 +02:00
more stuff
This commit is contained in:
@@ -119,11 +119,11 @@ Some features should not be changed. See notes below.
|
|||||||
//#define CONNECT_TO_SSID "your SSID"
|
//#define CONNECT_TO_SSID "your SSID"
|
||||||
//#define SSID_PASSWORD "your SSID password"
|
//#define SSID_PASSWORD "your SSID password"
|
||||||
//CONFIGURE_EYECATCH_BEGIN (DO NOT MODIFY THIS LINE)
|
//CONFIGURE_EYECATCH_BEGIN (DO NOT MODIFY THIS LINE)
|
||||||
#define ENABLE_BLUETOOTH // enable bluetooth
|
//#define ENABLE_BLUETOOTH // enable bluetooth
|
||||||
|
|
||||||
#define ENABLE_SD_CARD // enable use of SD Card to run jobs
|
#define ENABLE_SD_CARD // enable use of SD Card to run jobs
|
||||||
|
|
||||||
#define ENABLE_WIFI //enable wifi
|
//#define ENABLE_WIFI //enable wifi
|
||||||
|
|
||||||
#if defined(ENABLE_WIFI) || defined(ENABLE_BLUETOOTH)
|
#if defined(ENABLE_WIFI) || defined(ENABLE_BLUETOOTH)
|
||||||
# define WIFI_OR_BLUETOOTH
|
# define WIFI_OR_BLUETOOTH
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#define TRINAMIC_DAISY_CHAIN
|
#define TRINAMIC_DAISY_CHAIN
|
||||||
|
|
||||||
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_STEALTHCHOP
|
#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
|
||||||
|
|
||||||
#define TRINAMIC_TOFF_COOLSTEP 4
|
#define TRINAMIC_TOFF_COOLSTEP 4
|
||||||
#define TRINAMIC_HEND_COOLSTEP 5
|
#define TRINAMIC_HEND_COOLSTEP 5
|
||||||
@@ -45,27 +45,27 @@
|
|||||||
// The hardware enable pin is tied to ground
|
// The hardware enable pin is tied to ground
|
||||||
#define USE_TRINAMIC_ENABLE
|
#define USE_TRINAMIC_ENABLE
|
||||||
|
|
||||||
#define X_TRINAMIC_DRIVER 2130 // Which Driver Type?
|
#define X_TRINAMIC_DRIVER 5160 // Which Driver Type?
|
||||||
#define X_RSENSE TMC2130_RSENSE_DEFAULT
|
#define X_RSENSE TMC5160_RSENSE_DEFAULT
|
||||||
#define X_STEP_PIN GPIO_NUM_12
|
#define X_STEP_PIN GPIO_NUM_12
|
||||||
#define X_DIRECTION_PIN GPIO_NUM_14
|
#define X_DIRECTION_PIN GPIO_NUM_14
|
||||||
#define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin
|
#define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin
|
||||||
|
|
||||||
#define Y_TRINAMIC_DRIVER 2130 // Which Driver Type?
|
#define Y_TRINAMIC_DRIVER X_TRINAMIC_DRIVER // Which Driver Type?
|
||||||
#define Y_RSENSE TMC2130_RSENSE_DEFAULT
|
#define Y_RSENSE X_RSENSE
|
||||||
#define Y_STEP_PIN GPIO_NUM_27
|
#define Y_STEP_PIN GPIO_NUM_27
|
||||||
#define Y_DIRECTION_PIN GPIO_NUM_26
|
#define Y_DIRECTION_PIN GPIO_NUM_26
|
||||||
#define Y_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
#define Y_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
||||||
|
|
||||||
#define Z_TRINAMIC_DRIVER 2130 // Which Driver Type?
|
#define Z_TRINAMIC_DRIVER X_TRINAMIC_DRIVER // Which Driver Type?
|
||||||
#define Z_RSENSE TMC2130_RSENSE_DEFAULT
|
#define Z_RSENSE X_RSENSE
|
||||||
#define Z_STEP_PIN GPIO_NUM_15
|
#define Z_STEP_PIN GPIO_NUM_15
|
||||||
#define Z_DIRECTION_PIN GPIO_NUM_2
|
#define Z_DIRECTION_PIN GPIO_NUM_2
|
||||||
#define Z_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
#define Z_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
||||||
|
|
||||||
|
|
||||||
#define A_TRINAMIC_DRIVER 2130 // Which Driver Type?
|
#define A_TRINAMIC_DRIVER X_TRINAMIC_DRIVER // Which Driver Type?
|
||||||
#define A_RSENSE TMC2130_RSENSE_DEFAULT
|
#define A_RSENSE X_RSENSE
|
||||||
#define A_STEP_PIN GPIO_NUM_33
|
#define A_STEP_PIN GPIO_NUM_33
|
||||||
#define A_DIRECTION_PIN GPIO_NUM_32
|
#define A_DIRECTION_PIN GPIO_NUM_32
|
||||||
#define A_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
#define A_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
|
||||||
|
@@ -341,8 +341,7 @@ void motors_set_disable(bool disable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void motors_read_settings() {
|
void motors_read_settings() {
|
||||||
//grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Read Settings");
|
for (uint8_t gang_index = 0; gang_index < MAX_GANGED; gang_index++) {
|
||||||
for (uint8_t gang_index = 0; gang_index < 2; gang_index++) {
|
|
||||||
for (uint8_t axis = X_AXIS; axis < N_AXIS; axis++)
|
for (uint8_t axis = X_AXIS; axis < N_AXIS; axis++)
|
||||||
myMotor[axis][gang_index]->read_settings();
|
myMotor[axis][gang_index]->read_settings();
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,8 @@ namespace Motors {
|
|||||||
config_message();
|
config_message();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void StandardStepper::read_settings() {}
|
||||||
|
|
||||||
void StandardStepper::init_step_dir_pins() {
|
void StandardStepper::init_step_dir_pins() {
|
||||||
// TODO Step pin, but RMT complicates things
|
// TODO Step pin, but RMT complicates things
|
||||||
_invert_step_pin = bit_istrue(step_invert_mask->get(), bit(axis_index));
|
_invert_step_pin = bit_istrue(step_invert_mask->get(), bit(axis_index));
|
||||||
|
@@ -13,6 +13,7 @@ namespace Motors {
|
|||||||
virtual void set_direction_pins(uint8_t onMask);
|
virtual void set_direction_pins(uint8_t onMask);
|
||||||
void init_step_dir_pins();
|
void init_step_dir_pins();
|
||||||
virtual void set_disable(bool disable);
|
virtual void set_disable(bool disable);
|
||||||
|
|
||||||
uint8_t step_pin;
|
uint8_t step_pin;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -44,6 +44,8 @@ namespace Motors {
|
|||||||
_homing_mode = TRINAMIC_HOMING_MODE;
|
_homing_mode = TRINAMIC_HOMING_MODE;
|
||||||
_homing_mask = 0; // no axes homing
|
_homing_mask = 0; // no axes homing
|
||||||
|
|
||||||
|
has_errors = false;
|
||||||
|
|
||||||
set_axis_name();
|
set_axis_name();
|
||||||
|
|
||||||
if (_driver_part_number == 2130)
|
if (_driver_part_number == 2130)
|
||||||
@@ -155,6 +157,7 @@ namespace Motors {
|
|||||||
void TrinamicDriver::read_settings() {
|
void TrinamicDriver::read_settings() {
|
||||||
if (has_errors)
|
if (has_errors)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint16_t run_i_ma = (uint16_t)(axis_settings[axis_index]->run_current->get() * 1000.0);
|
uint16_t run_i_ma = (uint16_t)(axis_settings[axis_index]->run_current->get() * 1000.0);
|
||||||
float hold_i_percent;
|
float hold_i_percent;
|
||||||
|
|
||||||
@@ -169,6 +172,13 @@ namespace Motors {
|
|||||||
|
|
||||||
tmcstepper->microsteps(axis_settings[axis_index]->microsteps->get());
|
tmcstepper->microsteps(axis_settings[axis_index]->microsteps->get());
|
||||||
tmcstepper->rms_current(run_i_ma, hold_i_percent);
|
tmcstepper->rms_current(run_i_ma, hold_i_percent);
|
||||||
|
tmcstepper->en_pwm_mode(trinamic_en_pwm_mode->get());
|
||||||
|
tmcstepper->pwm_autoscale(trinamic_pwm_auto_scale->get());
|
||||||
|
tmcstepper->TCOOLTHRS(trinamic_tcoolthrs->get()); // when to turn on coolstep
|
||||||
|
tmcstepper->THIGH(trinamic_thigh->get());
|
||||||
|
tmcstepper->toff(trinamic_toff->get());
|
||||||
|
tmcstepper->hend(trinamic_hend->get());
|
||||||
|
tmcstepper->hstrt(trinamic_hstrt->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrinamicDriver::set_homing_mode(uint8_t homing_mask, bool isHoming) {
|
void TrinamicDriver::set_homing_mode(uint8_t homing_mask, bool isHoming) {
|
||||||
@@ -182,6 +192,8 @@ namespace Motors {
|
|||||||
Coolstep mode, so it will need to switch to Coolstep when homing
|
Coolstep mode, so it will need to switch to Coolstep when homing
|
||||||
*/
|
*/
|
||||||
void TrinamicDriver::set_mode(bool isHoming) {
|
void TrinamicDriver::set_mode(bool isHoming) {
|
||||||
|
|
||||||
|
|
||||||
if (has_errors)
|
if (has_errors)
|
||||||
return;
|
return;
|
||||||
if (isHoming)
|
if (isHoming)
|
||||||
@@ -202,10 +214,10 @@ namespace Motors {
|
|||||||
break;
|
break;
|
||||||
case TRINAMIC_MODE_COOLSTEP:
|
case TRINAMIC_MODE_COOLSTEP:
|
||||||
//grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "TRINAMIC_MODE_COOLSTEP");
|
//grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "TRINAMIC_MODE_COOLSTEP");
|
||||||
tmcstepper->en_pwm_mode(false);
|
tmcstepper->en_pwm_mode(trinamic_en_pwm_mode->get());
|
||||||
tmcstepper->pwm_autoscale(false);
|
tmcstepper->pwm_autoscale(trinamic_pwm_auto_scale->get());
|
||||||
tmcstepper->TCOOLTHRS(trinamic_tcoolthrs->get()); // when to turn on coolstep
|
tmcstepper->TCOOLTHRS(trinamic_tcoolthrs->get()); // when to turn on coolstep
|
||||||
tmcstepper->THIGH(NORMAL_THIGH);
|
tmcstepper->THIGH(trinamic_thigh->get());
|
||||||
tmcstepper->toff(trinamic_toff->get());
|
tmcstepper->toff(trinamic_toff->get());
|
||||||
tmcstepper->hend(trinamic_hend->get());
|
tmcstepper->hend(trinamic_hend->get());
|
||||||
tmcstepper->hstrt(trinamic_hstrt->get());
|
tmcstepper->hstrt(trinamic_hstrt->get());
|
||||||
@@ -228,6 +240,9 @@ namespace Motors {
|
|||||||
This is the stallguard tuning info. It is call debug, so it could be generic across all classes.
|
This is the stallguard tuning info. It is call debug, so it could be generic across all classes.
|
||||||
*/
|
*/
|
||||||
void TrinamicDriver::debug_message() {
|
void TrinamicDriver::debug_message() {
|
||||||
|
error_check();
|
||||||
|
return;
|
||||||
|
|
||||||
if (has_errors)
|
if (has_errors)
|
||||||
return;
|
return;
|
||||||
uint32_t tstep = tmcstepper->TSTEP();
|
uint32_t tstep = tmcstepper->TSTEP();
|
||||||
@@ -246,6 +261,44 @@ namespace Motors {
|
|||||||
axis_settings[axis_index]->stallguard->get());
|
axis_settings[axis_index]->stallguard->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrinamicDriver::error_check() {
|
||||||
|
|
||||||
|
|
||||||
|
TMC2130_n ::DRV_STATUS_t status { 0 }; // a useful struct to access the bits.
|
||||||
|
status.sr = tmcstepper->DRV_STATUS();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool err = false;
|
||||||
|
|
||||||
|
if (status.s2ga || status.s2gb) {
|
||||||
|
grbl_msg_sendf(
|
||||||
|
CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Motor Short Coil a:%s b:%s", _axis_name, status.s2ga ? "Y" : "N", status.s2gb ? "Y" : "N");
|
||||||
|
err = true;
|
||||||
|
}
|
||||||
|
// check for over temp or pre-warning
|
||||||
|
if (status.ot || status.otpw) {
|
||||||
|
grbl_msg_sendf(
|
||||||
|
CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Driver Temp Warning:%s Fault:%s", _axis_name, status.otpw ? "Y" : "N", status.ot ? "Y" : "N");
|
||||||
|
err = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.ola || status.olb) {
|
||||||
|
grbl_msg_sendf(
|
||||||
|
CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Motor open load a:%s b:%s", _axis_name, status.ola ? "Y" : "N", status.olb ? "Y" : "N");
|
||||||
|
err = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!err) {
|
||||||
|
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Motor OK status %x", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// calculate a tstep from a rate
|
// calculate a tstep from a rate
|
||||||
// tstep = TRINAMIC_FCLK / (time between 1/256 steps)
|
// tstep = TRINAMIC_FCLK / (time between 1/256 steps)
|
||||||
// This is used to set the stallguard window from the homing speed.
|
// This is used to set the stallguard window from the homing speed.
|
||||||
|
@@ -85,6 +85,7 @@ namespace Motors {
|
|||||||
void trinamic_test_response();
|
void trinamic_test_response();
|
||||||
void trinamic_stepper_enable(bool enable);
|
void trinamic_stepper_enable(bool enable);
|
||||||
void debug_message();
|
void debug_message();
|
||||||
|
void error_check();
|
||||||
void set_homing_mode(uint8_t homing_mask, bool ishoming);
|
void set_homing_mode(uint8_t homing_mask, bool ishoming);
|
||||||
void set_disable(bool disable);
|
void set_disable(bool disable);
|
||||||
bool test();
|
bool test();
|
||||||
|
@@ -53,10 +53,14 @@ IntSetting* spindle_pwm_bit_precision;
|
|||||||
|
|
||||||
EnumSetting* spindle_type;
|
EnumSetting* spindle_type;
|
||||||
|
|
||||||
IntSetting* trinamic_toff;
|
IntSetting* trinamic_toff;
|
||||||
IntSetting* trinamic_hend;
|
IntSetting* trinamic_hend;
|
||||||
IntSetting* trinamic_hstrt;
|
IntSetting* trinamic_hstrt;
|
||||||
IntSetting* trinamic_tcoolthrs;
|
IntSetting* trinamic_tcoolthrs;
|
||||||
|
IntSetting* trinamic_thigh;
|
||||||
|
IntSetting* trinamic_tbl;
|
||||||
|
FlagSetting* trinamic_en_pwm_mode;
|
||||||
|
FlagSetting* trinamic_pwm_auto_scale;
|
||||||
|
|
||||||
enum_opt_t spindleTypes = {
|
enum_opt_t spindleTypes = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@@ -169,6 +173,11 @@ static bool checkStallguard(char* value) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool trinamic_change(char* value) {
|
||||||
|
motorSettingChanged = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool checkMicrosteps(char* value) {
|
static bool checkMicrosteps(char* value) {
|
||||||
motorSettingChanged = true;
|
motorSettingChanged = true;
|
||||||
return true;
|
return true;
|
||||||
@@ -298,10 +307,10 @@ void make_settings() {
|
|||||||
rpm_min = new FloatSetting(GRBL, WG, "31", "GCode/MinS", DEFAULT_SPINDLE_RPM_MIN, 0, 100000);
|
rpm_min = new FloatSetting(GRBL, WG, "31", "GCode/MinS", DEFAULT_SPINDLE_RPM_MIN, 0, 100000);
|
||||||
rpm_max = new FloatSetting(GRBL, WG, "30", "GCode/MaxS", DEFAULT_SPINDLE_RPM_MAX, 0, 100000);
|
rpm_max = new FloatSetting(GRBL, WG, "30", "GCode/MaxS", DEFAULT_SPINDLE_RPM_MAX, 0, 100000);
|
||||||
|
|
||||||
homing_pulloff = new FloatSetting(GRBL, WG, "27", "Homing/Pulloff", DEFAULT_HOMING_PULLOFF, 0, 1000);
|
homing_pulloff = new FloatSetting(GRBL, WG, "27", "Homing/Pulloff", DEFAULT_HOMING_PULLOFF, 0, 1000);
|
||||||
homing_debounce = new FloatSetting(GRBL, WG, "26", "Homing/Debounce", DEFAULT_HOMING_DEBOUNCE_DELAY, 0, 10000);
|
homing_debounce = new FloatSetting(GRBL, WG, "26", "Homing/Debounce", DEFAULT_HOMING_DEBOUNCE_DELAY, 0, 10000);
|
||||||
homing_seek_rate = new FloatSetting(GRBL, WG, "25", "Homing/Seek", DEFAULT_HOMING_SEEK_RATE, 0, 10000);
|
homing_seek_rate = new FloatSetting(GRBL, WG, "25", "Homing/Seek", DEFAULT_HOMING_SEEK_RATE, 0, 10000);
|
||||||
homing_feed_rate = new FloatSetting(GRBL, WG, "24", "Homing/Feed", DEFAULT_HOMING_FEED_RATE, 0, 10000);
|
homing_feed_rate = new FloatSetting(GRBL, WG, "24", "Homing/Feed", DEFAULT_HOMING_FEED_RATE, 0, 10000);
|
||||||
homing_squared_axes = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Squared", DEFAULT_HOMING_SQUARED_AXES);
|
homing_squared_axes = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Squared", DEFAULT_HOMING_SQUARED_AXES);
|
||||||
|
|
||||||
// TODO Settings - need to call st_generate_step_invert_masks()
|
// TODO Settings - need to call st_generate_step_invert_masks()
|
||||||
@@ -329,11 +338,15 @@ void make_settings() {
|
|||||||
spindle_type = new EnumSetting(NULL, EXTENDED, WG, NULL, "Spindle/Type", SPINDLE_TYPE, &spindleTypes);
|
spindle_type = new EnumSetting(NULL, EXTENDED, WG, NULL, "Spindle/Type", SPINDLE_TYPE, &spindleTypes);
|
||||||
stallguard_debug_mask = new AxisMaskSetting(EXTENDED, WG, NULL, "Report/StallGuard", 0, checkStallguardDebugMask);
|
stallguard_debug_mask = new AxisMaskSetting(EXTENDED, WG, NULL, "Report/StallGuard", 0, checkStallguardDebugMask);
|
||||||
|
|
||||||
|
trinamic_toff = new IntSetting(GRBL, WG, NULL, "Trinamic/toff", 4, 0, 255, trinamic_change);
|
||||||
|
trinamic_hend = new IntSetting(GRBL, WG, NULL, "Trinamic/hend", 5, 0, 255, trinamic_change);
|
||||||
|
trinamic_hstrt = new IntSetting(GRBL, WG, NULL, "Trinamic/hstrt", 0, 0, 255, trinamic_change);
|
||||||
|
trinamic_tcoolthrs = new IntSetting(GRBL, WG, NULL, "Trinamic/tcoolthrs", 0, 1000, 0xFFFFF, trinamic_change);
|
||||||
|
trinamic_thigh = new IntSetting(GRBL, WG, NULL, "Trinamic/thigh", 0, 1000, 0xFFFFF, trinamic_change);
|
||||||
|
trinamic_tbl = new IntSetting(GRBL, WG, NULL, "Trinamic/tbl", 1, 0, 3, trinamic_change);
|
||||||
|
trinamic_en_pwm_mode = new FlagSetting(GRBL, WG, NULL, "Trinamic/EnPwmMode", 1, trinamic_change);
|
||||||
|
trinamic_pwm_auto_scale = new FlagSetting(GRBL, WG, NULL, "Trinamic/PwmAutoScale", 1, trinamic_change);
|
||||||
|
|
||||||
trinamic_toff = new IntSetting(GRBL, WG, NULL, "Trinamic/toff", 4, 0, 255);
|
|
||||||
trinamic_hend = new IntSetting(GRBL, WG, NULL, "Trinamic/hend", 5, 0, 255);
|
|
||||||
trinamic_hstrt = new IntSetting(GRBL, WG, NULL, "Trinamic/hstrt", 0, 0, 255);
|
|
||||||
trinamic_tcoolthrs = new IntSetting(GRBL, WG, NULL, "Trinamic/tcoolthrs", 0, 1000, 0xFFFFF);
|
|
||||||
//trinamic_s2vs = new IntSetting(GRBL, WG, NULL, "Trinamic/s2vs", 0, 1000, 0xFFFFF);
|
//trinamic_s2vs = new IntSetting(GRBL, WG, NULL, "Trinamic/s2vs", 0, 1000, 0xFFFFF);
|
||||||
//trinamic_s2g = new IntSetting(GRBL, WG, NULL, "Trinamic/s2g", 0, 1000, 0xFFFFF);
|
//trinamic_s2g = new IntSetting(GRBL, WG, NULL, "Trinamic/s2g", 0, 1000, 0xFFFFF);
|
||||||
}
|
}
|
||||||
|
@@ -61,3 +61,7 @@ extern IntSetting* trinamic_toff;
|
|||||||
extern IntSetting* trinamic_hend;
|
extern IntSetting* trinamic_hend;
|
||||||
extern IntSetting* trinamic_hstrt;
|
extern IntSetting* trinamic_hstrt;
|
||||||
extern IntSetting* trinamic_tcoolthrs;
|
extern IntSetting* trinamic_tcoolthrs;
|
||||||
|
extern IntSetting* trinamic_thigh;
|
||||||
|
extern IntSetting* trinamic_tbl;
|
||||||
|
extern FlagSetting* trinamic_en_pwm_mode;
|
||||||
|
extern FlagSetting* trinamic_pwm_auto_scale;
|
||||||
|
Reference in New Issue
Block a user