mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-30 09:39:49 +02:00
Added addiitonal settings. Fixed Polar Coaster's buttons
Settings - Added stallguard - Added user machine settings Polar Coaster - Fixed the invert mask for the buttons
This commit is contained in:
@@ -292,10 +292,29 @@
|
||||
#define DEFAULT_C_MICROSTEPS 16 // $165 micro steps (extended set)
|
||||
#endif
|
||||
|
||||
// ========== Stallguard (SPI Drivers ) ================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DEFAULT_X_STALLGUARD
|
||||
#define DEFAULT_X_STALLGUARD 16 // $170 stallguard (extended set)
|
||||
#endif
|
||||
#ifndef DEFAULT_Y_STALLGUARD
|
||||
#define DEFAULT_Y_STALLGUARD 16 // $171 stallguard (extended set)
|
||||
#endif
|
||||
#ifndef DEFAULT_Z_STALLGUARD
|
||||
#define DEFAULT_Z_STALLGUARD 16 // $172 stallguard (extended set)
|
||||
#endif
|
||||
#ifndef DEFAULT_A_STALLGUARD
|
||||
#define DEFAULT_A_STALLGUARD 16 // $173 stallguard (extended set)
|
||||
#endif
|
||||
#ifndef DEFAULT_B_STALLGUARD
|
||||
#define DEFAULT_B_STALLGUARD 16 // $174 stallguard (extended set)
|
||||
#endif
|
||||
#ifndef DEFAULT_C_STALLGUARD
|
||||
#define DEFAULT_C_STALLGUARD 16 // $175 stallguard (extended set)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -64,6 +64,16 @@
|
||||
#define ENABLE_CONTROL_SW_DEBOUNCE
|
||||
#endif
|
||||
|
||||
#ifdef CONTROL_SW_DEBOUNCE_PERIOD
|
||||
#undef CONTROL_SW_DEBOUNCE_PERIOD
|
||||
#endif
|
||||
#define CONTROL_SW_DEBOUNCE_PERIOD 100 // really long debounce
|
||||
|
||||
#ifdef INVERT_CONTROL_PIN_MASK
|
||||
#undef INVERT_CONTROL_PIN_MASK
|
||||
#endif
|
||||
#define INVERT_CONTROL_PIN_MASK B11111111
|
||||
|
||||
#define MACRO_BUTTON_0_PIN GPIO_NUM_13
|
||||
#define MACRO_BUTTON_1_PIN GPIO_NUM_12
|
||||
#define MACRO_BUTTON_2_PIN GPIO_NUM_14
|
||||
|
@@ -284,7 +284,7 @@ void report_grbl_help(uint8_t client) {
|
||||
void report_grbl_settings(uint8_t client) {
|
||||
// Print Grbl settings.
|
||||
char setting[20];
|
||||
char rpt[1000];
|
||||
char rpt[1000];
|
||||
|
||||
rpt[0] = '\0';
|
||||
|
||||
@@ -326,7 +326,16 @@ void report_grbl_settings(uint8_t client) {
|
||||
sprintf(setting, "$33=%5.3f\r\n", settings.spindle_pwm_freq); strcat(rpt, setting);
|
||||
sprintf(setting, "$34=%3.3f\r\n", settings.spindle_pwm_off_value); strcat(rpt, setting);
|
||||
sprintf(setting, "$35=%3.3f\r\n", settings.spindle_pwm_min_value); strcat(rpt, setting);
|
||||
sprintf(setting, "$36=%3.3f\r\n", settings.spindle_pwm_max_value); strcat(rpt, setting);
|
||||
sprintf(setting, "$36=%3.3f\r\n", settings.spindle_pwm_max_value); strcat(rpt, setting);
|
||||
|
||||
for (uint8_t index = 0; index<USER_SETTING_COUNT; index++) {
|
||||
sprintf(setting, "$%d=%d\r\n", 80 + index, settings.machine_int16[index]); strcat(rpt, setting);
|
||||
}
|
||||
|
||||
for (uint8_t index = 0; index<USER_SETTING_COUNT; index++) {
|
||||
sprintf(setting, "$%d=%5.3f\r\n", 90 + index, settings.machine_float[index]); strcat(rpt, setting);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Print axis settings
|
||||
@@ -343,6 +352,7 @@ void report_grbl_settings(uint8_t client) {
|
||||
case 4: sprintf(setting, "$%d=%4.3f\r\n", val+idx, settings.current[idx]); strcat(rpt, setting); break;
|
||||
case 5: sprintf(setting, "$%d=%4.3f\r\n", val+idx, settings.hold_current[idx]); strcat(rpt, setting); break;
|
||||
case 6: sprintf(setting, "$%d=%d\r\n", val+idx, settings.microsteps[idx]); strcat(rpt, setting); break;
|
||||
case 7: sprintf(setting, "$%d=%d\r\n", val+idx, settings.stallguard[idx]); strcat(rpt, setting); break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -812,7 +822,7 @@ void report_realtime_status(uint8_t client)
|
||||
uint8_t cl_state = coolant_get_state();
|
||||
if (sp_state || cl_state) {
|
||||
strcat(status, "|A:");
|
||||
if (sp_state) { // != SPINDLE_STATE_DISABLE
|
||||
if (sp_state) { // != SPINDLE_STATE_DISABLE
|
||||
if (sp_state == SPINDLE_STATE_CW) { strcat(status, "S"); } // CW
|
||||
else { strcat(status, "C"); } // CCW
|
||||
}
|
||||
@@ -861,4 +871,4 @@ void report_gcode_comment(char *comment) {
|
||||
|
||||
grbl_sendf(CLIENT_ALL, "[MSG:GCode Comment %s]\r\n",msg);
|
||||
}
|
||||
}
|
||||
}
|
@@ -121,7 +121,9 @@ void settings_restore(uint8_t restore_flag) {
|
||||
settings.microsteps[Y_AXIS] = DEFAULT_Y_MICROSTEPS;
|
||||
settings.microsteps[Z_AXIS] = DEFAULT_Z_MICROSTEPS;
|
||||
|
||||
|
||||
settings.stallguard[X_AXIS] = DEFAULT_X_STALLGUARD;
|
||||
settings.stallguard[Y_AXIS] = DEFAULT_Y_STALLGUARD;
|
||||
settings.stallguard[Z_AXIS] = DEFAULT_Z_STALLGUARD;
|
||||
|
||||
#if (N_AXIS > A_AXIS)
|
||||
settings.steps_per_mm[A_AXIS] = DEFAULT_A_STEPS_PER_MM;
|
||||
@@ -131,6 +133,7 @@ void settings_restore(uint8_t restore_flag) {
|
||||
settings.current[A_AXIS] = DEFAULT_A_CURRENT;
|
||||
settings.hold_current[A_AXIS] = DEFAULT_A_HOLD_CURRENT;
|
||||
settings.microsteps[A_AXIS] = DEFAULT_A_MICROSTEPS;
|
||||
settings.stallguard[A_AXIS] = DEFAULT_Z_STALLGUARD;
|
||||
#endif
|
||||
|
||||
#if (N_AXIS > B_AXIS)
|
||||
@@ -141,6 +144,7 @@ void settings_restore(uint8_t restore_flag) {
|
||||
settings.current[B_AXIS] = DEFAULT_B_CURRENT;
|
||||
settings.hold_current[B_AXIS] = DEFAULT_B_HOLD_CURRENT;
|
||||
settings.microsteps[B_AXIS] = DEFAULT_B_MICROSTEPS;
|
||||
settings.stallguard[B_AXIS] = DEFAULT_Z_STALLGUARD;
|
||||
#endif
|
||||
|
||||
#if (N_AXIS > C_AXIS)
|
||||
@@ -151,9 +155,15 @@ void settings_restore(uint8_t restore_flag) {
|
||||
settings.current[C_AXIS] = DEFAULT_C_CURRENT;
|
||||
settings.hold_current[C_AXIS] = DEFAULT_C_HOLD_CURRENT;
|
||||
settings.microsteps[C_AXIS] = DEFAULT_C_MICROSTEPS;
|
||||
settings.stallguard[C_AXIS] = DEFAULT_Z_STALLGUARD;
|
||||
#endif
|
||||
|
||||
|
||||
// TODO figure out a clean way to add actual default values
|
||||
for (uint8_t index = 0; index<USER_SETTING_COUNT; index++) {
|
||||
settings.machine_int16[index] = 0;
|
||||
settings.machine_float[index] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
write_global_settings();
|
||||
}
|
||||
@@ -307,6 +317,10 @@ uint8_t settings_store_global_setting(uint8_t parameter, float value) {
|
||||
case 6: // microstepping
|
||||
settings.microsteps[parameter] = int_value;
|
||||
settings_spi_driver_init();
|
||||
break;
|
||||
case 7: // stallguard
|
||||
settings.stallguard[parameter] = int_value;
|
||||
settings_spi_driver_init();
|
||||
break;
|
||||
}
|
||||
break; // Exit while-loop after setting has been configured and proceed to the EEPROM write call.
|
||||
@@ -391,6 +405,22 @@ uint8_t settings_store_global_setting(uint8_t parameter, float value) {
|
||||
case 34: settings.spindle_pwm_off_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
|
||||
case 35: settings.spindle_pwm_min_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
|
||||
case 36: settings.spindle_pwm_max_value = value; spindle_init(); break; // Re-initialize spindle pwm calibration
|
||||
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 84:
|
||||
settings.machine_int16[parameter - 80] = int_value;
|
||||
break;
|
||||
|
||||
case 90:
|
||||
case 91:
|
||||
case 92:
|
||||
case 93:
|
||||
case 94:
|
||||
settings.machine_float[parameter - 90] = value;
|
||||
break;
|
||||
default:
|
||||
return(STATUS_INVALID_STATEMENT);
|
||||
}
|
||||
@@ -420,4 +450,3 @@ void settings_spi_driver_init() {
|
||||
grbl_send(CLIENT_ALL, "[MSG: No SPI drivers setup]\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
|
||||
// when firmware is upgraded. Always stored in byte 0 of eeprom
|
||||
#define SETTINGS_VERSION 10 // NOTE: Check settings_reset() when moving to next version.
|
||||
#define SETTINGS_VERSION 12 // NOTE: Check settings_reset() when moving to next version.
|
||||
|
||||
// Define bit flag masks for the boolean settings in settings.flag.
|
||||
#define BITFLAG_REPORT_INCHES bit(0)
|
||||
@@ -78,11 +78,13 @@
|
||||
#ifndef SHOW_EXTENDED_SETTINGS
|
||||
#define AXIS_N_SETTINGS 4
|
||||
#else
|
||||
#define AXIS_N_SETTINGS 7
|
||||
#define AXIS_N_SETTINGS 8
|
||||
#endif
|
||||
#define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255.
|
||||
#define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings
|
||||
|
||||
#define USER_SETTING_COUNT 5 // for user to define for their machine
|
||||
|
||||
// Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards)
|
||||
typedef struct {
|
||||
// Axis settings
|
||||
@@ -93,6 +95,7 @@ typedef struct {
|
||||
float current[N_AXIS]; // $140... run current (extended set)
|
||||
float hold_current[N_AXIS]; // $150 percent of run current (extended set)
|
||||
uint16_t microsteps[N_AXIS]; // $160... (extended set)
|
||||
uint8_t stallguard[N_AXIS]; // $170... (extended set)
|
||||
|
||||
// Remaining Grbl settings
|
||||
uint8_t pulse_microseconds;
|
||||
@@ -118,6 +121,10 @@ typedef struct {
|
||||
float homing_seek_rate;
|
||||
uint16_t homing_debounce_delay;
|
||||
float homing_pulloff;
|
||||
|
||||
int16_t machine_int16[USER_SETTING_COUNT]; // settings starting at 80 to be defined by the user
|
||||
float machine_float[USER_SETTING_COUNT]; // settings starting at 80 to be defined by the user
|
||||
|
||||
} settings_t;
|
||||
extern settings_t settings;
|
||||
|
||||
@@ -150,4 +157,3 @@ uint8_t get_direction_pin_mask(uint8_t i);
|
||||
void settings_spi_driver_init();
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -21,6 +21,12 @@
|
||||
"30","Maximum spindle speed","RPM","Maximum spindle speed. Sets PWM to 100% duty cycle."
|
||||
"31","Minimum spindle speed","RPM","Minimum spindle speed. Sets PWM to 0.4% or lowest duty cycle."
|
||||
"32","Laser-mode enable","boolean","Enables laser mode. Consecutive G1/2/3 commands will not halt when spindle speed is changed."
|
||||
"33","Spindle PWM Freq","16-bit","Spindle PWM Freq"
|
||||
"34","Spindle PWM Off Value","16-bit","Spindle PWM Off Value"
|
||||
"35","Spindle PWM Min Value","16-bit","Spindle PWM Min Value"
|
||||
"36","Spindle PWM Max Value","16-bit","Spindle PWM Max Value"
|
||||
"80-84","User integer Values","unsigned 16-bit","Reserved for custom machine use"
|
||||
"90-94","User Floating point value","float","Reserved for custom machine use"
|
||||
"100","X-axis travel resolution","step/mm","X-axis travel resolution in steps per millimeter."
|
||||
"101","Y-axis travel resolution","step/mm","Y-axis travel resolution in steps per millimeter."
|
||||
"102","Z-axis travel resolution","step/mm","Z-axis travel resolution in steps per millimeter."
|
||||
@@ -36,3 +42,5 @@
|
||||
"140-145","Motor run current","Amps","Motor run current for SPI (Trinamic) type motors"
|
||||
"150-155","Motor hold current","Percent","Hold current in percent of run current for SPI (Trinamic) type motors"
|
||||
"160-165","Motor microstepping","micros/step","Number of microsteps per step for SPI (Trinamic) type motors"
|
||||
"170-175","Motor Stallguard Value","0-255","Value of Stallguard setting for SPI (Trinamic) type motors"
|
||||
|
||||
|
|
Reference in New Issue
Block a user