mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-16 19:44:07 +02:00
Merge pull request #366 from bdring/Devt
Parking Feature and Spindle Fix
This commit is contained in:
@@ -343,10 +343,14 @@ uint8_t gc_execute_line(char* line, uint8_t client) {
|
||||
case 9:
|
||||
gc_block.modal.coolant = COOLANT_DISABLE;
|
||||
break;
|
||||
default:
|
||||
FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND); // [Unsupported M command]
|
||||
}
|
||||
break;
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
case 56:
|
||||
word_bit = MODAL_GROUP_M9;
|
||||
gc_block.modal.override = OVERRIDE_PARKING_MOTION;
|
||||
break;
|
||||
#endif
|
||||
case 62:
|
||||
case 63:
|
||||
//grbl_sendf(CLIENT_SERIAL,"M%d...\r\n", int_value);
|
||||
@@ -580,6 +584,14 @@ uint8_t gc_execute_line(char* line, uint8_t client) {
|
||||
// [7. Spindle control ]: N/A
|
||||
// [8. Coolant control ]: N/A
|
||||
// [9. Enable/disable feed rate or spindle overrides ]: NOT SUPPORTED.
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
if (bit_istrue(command_words, bit(MODAL_GROUP_M9))) { // Already set as enabled in parser.
|
||||
if (bit_istrue(value_words, bit(WORD_P))) {
|
||||
if (gc_block.values.p == 0.0) gc_block.modal.override = OVERRIDE_DISABLED;
|
||||
bit_false(value_words, bit(WORD_P));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// [10. Dwell ]: P value missing. P is negative (done.) NOTE: See below.
|
||||
if (gc_block.non_modal_command == NON_MODAL_DWELL) {
|
||||
if (bit_isfalse(value_words, bit(WORD_P))) {
|
||||
@@ -1128,7 +1140,13 @@ uint8_t gc_execute_line(char* line, uint8_t client) {
|
||||
else
|
||||
FAIL(STATUS_P_PARAM_MAX_EXCEEDED);
|
||||
}
|
||||
// [9. Enable/disable feed rate or spindle overrides ]: NOT SUPPORTED. Always enabled.
|
||||
// [9. Override control ]: NOT SUPPORTED. Always enabled. Except for a Grbl-only parking control.
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
if (gc_state.modal.override != gc_block.modal.override) {
|
||||
gc_state.modal.override = gc_block.modal.override;
|
||||
mc_override_ctrl_update(gc_state.modal.override);
|
||||
}
|
||||
#endif
|
||||
// [10. Dwell ]:
|
||||
if (gc_block.non_modal_command == NON_MODAL_DWELL)
|
||||
mc_dwell(gc_block.values.p);
|
||||
@@ -1258,6 +1276,13 @@ uint8_t gc_execute_line(char* line, uint8_t client) {
|
||||
gc_state.modal.coord_select = 0; // G54
|
||||
gc_state.modal.spindle = SPINDLE_DISABLE;
|
||||
gc_state.modal.coolant = COOLANT_DISABLE;
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
#ifdef DEACTIVATE_PARKING_UPON_INIT
|
||||
gc_state.modal.override = OVERRIDE_DISABLED;
|
||||
#else
|
||||
gc_state.modal.override = OVERRIDE_PARKING_MOTION;
|
||||
#endif
|
||||
#endif
|
||||
// gc_state.modal.override = OVERRIDE_DISABLE; // Not supported.
|
||||
#ifdef RESTORE_OVERRIDES_AFTER_PROGRAM_END
|
||||
sys.f_override = DEFAULT_FEED_OVERRIDE;
|
||||
|
@@ -47,7 +47,8 @@
|
||||
#define MODAL_GROUP_M6 14 // [M6] Tool change
|
||||
#define MODAL_GROUP_M7 12 // [M3,M4,M5] Spindle turning
|
||||
#define MODAL_GROUP_M8 13 // [M7,M8,M9] Coolant control
|
||||
#define MODAL_GROUP_M10 14 // [M62, M63] User Defined http://linuxcnc.org/docs/html/gcode/overview.html#_modal_groups
|
||||
#define MODAL_GROUP_M9 14 // [M56] Override control
|
||||
#define MODAL_GROUP_M10 15 // [M62, M63] User Defined http://linuxcnc.org/docs/html/gcode/overview.html#_modal_groups
|
||||
|
||||
// #define OTHER_INPUT_F 14
|
||||
// #define OTHER_INPUT_S 15
|
||||
@@ -126,6 +127,15 @@
|
||||
#define COOLANT_FLOOD_ENABLE PL_COND_FLAG_COOLANT_FLOOD // M8 (NOTE: Uses planner condition bit flag)
|
||||
#define COOLANT_MIST_ENABLE PL_COND_FLAG_COOLANT_MIST // M7 (NOTE: Uses planner condition bit flag)
|
||||
|
||||
// Modal Group M9: Override control
|
||||
#ifdef DEACTIVATE_PARKING_UPON_INIT
|
||||
#define OVERRIDE_DISABLED 0 // (Default: Must be zero)
|
||||
#define OVERRIDE_PARKING_MOTION 1 // M56
|
||||
#else
|
||||
#define OVERRIDE_PARKING_MOTION 0 // M56 (Default: Must be zero)
|
||||
#define OVERRIDE_DISABLED 1 // Parking disabled.
|
||||
#endif
|
||||
|
||||
// modal Group M10: User I/O control
|
||||
#define NON_MODAL_IO_ENABLE 1
|
||||
#define NON_MODAL_IO_DISABLE 2
|
||||
@@ -203,6 +213,7 @@ typedef struct {
|
||||
uint8_t spindle; // {M3,M4,M5}
|
||||
uint8_t tool_change; // {M6}
|
||||
uint8_t io_control; // {M62, M63}
|
||||
uint8_t override; // {M56}
|
||||
} gc_modal_t;
|
||||
|
||||
typedef struct {
|
||||
|
@@ -404,6 +404,15 @@ void mc_parking_motion(float* parking_target, plan_line_data_t* pl_data) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
void mc_override_ctrl_update(uint8_t override_state) {
|
||||
// Finish all queued commands before altering override control state
|
||||
protocol_buffer_synchronize();
|
||||
if (sys.abort) return;
|
||||
sys.override_ctrl = override_state;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Method to ready the system to reset by setting the realtime reset command and killing any
|
||||
// active processes in the system. This also checks if a system reset is issued while Grbl
|
||||
|
@@ -65,6 +65,9 @@ void mc_homing_cycle(uint8_t cycle_mask);
|
||||
// Perform tool length probe cycle. Requires probe switch.
|
||||
uint8_t mc_probe_cycle(float* target, plan_line_data_t* pl_data, uint8_t parser_flags);
|
||||
|
||||
// Handles updating the override control state.
|
||||
void mc_override_ctrl_update(uint8_t override_state);
|
||||
|
||||
// Plans and executes the single special motion case for parking. Independent of main planner buffer.
|
||||
void mc_parking_motion(float* parking_target, plan_line_data_t* pl_data);
|
||||
|
||||
|
@@ -458,6 +458,12 @@ void report_gcode_modes(uint8_t client) {
|
||||
if (gc_state.modal.coolant & PL_COND_FLAG_COOLANT_FLOOD) strcat(modes_rpt, " M8");
|
||||
} else
|
||||
strcat(modes_rpt, " M9");
|
||||
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
if (sys.override_ctrl == OVERRIDE_PARKING_MOTION)
|
||||
strcat(modes_rpt, " M56");
|
||||
#endif
|
||||
|
||||
sprintf(temp, " T%d", gc_state.tool);
|
||||
strcat(modes_rpt, temp);
|
||||
if (bit_istrue(settings.flags, BITFLAG_REPORT_INCHES))
|
||||
@@ -524,6 +530,9 @@ void report_build_info(char* line, uint8_t client) {
|
||||
#ifdef ENABLE_SD_CARD
|
||||
strcat(build_info, "S");
|
||||
#endif
|
||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||
serial_write('R');
|
||||
#endif
|
||||
#if defined (ENABLE_WIFI)
|
||||
strcat(build_info, "W");
|
||||
#endif
|
||||
|
@@ -56,7 +56,7 @@ void spindle_init() {
|
||||
pinMode(SPINDLE_DIR_PIN, OUTPUT);
|
||||
#endif
|
||||
// use the LED control feature to setup PWM https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html
|
||||
spindle_pwm_chan_num - sys_get_next_PWM_chan_num();
|
||||
spindle_pwm_chan_num = sys_get_next_PWM_chan_num();
|
||||
ledcSetup(spindle_pwm_chan_num, (double)settings.spindle_pwm_freq, SPINDLE_PWM_BIT_PRECISION); // setup the channel
|
||||
ledcAttachPin(SPINDLE_PWM_PIN, spindle_pwm_chan_num); // attach the PWM to the pin
|
||||
// Start with spindle off off
|
||||
|
Reference in New Issue
Block a user