From a6f643151581cbcd40ffc515f9b05c9944282bea Mon Sep 17 00:00:00 2001 From: chamnit Date: Tue, 25 Oct 2016 19:43:06 -0600 Subject: [PATCH] Resolved parking accessory handling issue. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Yikes. Totally borked the last parking “fix”. Testing shows that all accessories are now properly handled when retracting and restoring. It was caused by not accounting for the planner re-factoring correctly in the parking code. --- doc/log/commit_log_v1.1.txt | 21 +++++++++++++++++++++ grbl/grbl.h | 2 +- grbl/planner.h | 1 + grbl/protocol.c | 21 ++++++++++++--------- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/doc/log/commit_log_v1.1.txt b/doc/log/commit_log_v1.1.txt index 15d8de7..27330bf 100644 --- a/doc/log/commit_log_v1.1.txt +++ b/doc/log/commit_log_v1.1.txt @@ -1,3 +1,24 @@ +---------------- +Date: 2016-10-24 +Author: Sonny Jeon +Subject: Minor re-factoring. Fix an issue with parking and spindle restore. + +- Altered the report counters to be count down, rather than count up. +Simplified some of the logic. + +- Fixed an issue with parking restore. The spindle state would disable +then reenable. + +- Clarified some of the config.h descriptions. + +- Moved the compile-time checks from config.h to grbl.h. They don’t +belong in the config.h file. + +- Refactored the initialization of the system variables in main.c. +System position and probe position were undefined when power cycled, +but were zero anyway. Added clear vector code to make it explicit. + + ---------------- Date: 2016-10-23 Author: Sonny Jeon diff --git a/grbl/grbl.h b/grbl/grbl.h index b662c9d..665dbee 100644 --- a/grbl/grbl.h +++ b/grbl/grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1d" -#define GRBL_VERSION_BUILD "20161024" +#define GRBL_VERSION_BUILD "20161025" // Define standard libraries used by Grbl. #include diff --git a/grbl/planner.h b/grbl/planner.h index d8f2c45..f272bc8 100644 --- a/grbl/planner.h +++ b/grbl/planner.h @@ -45,6 +45,7 @@ #define PL_COND_FLAG_SPINDLE_CCW bit(5) #define PL_COND_FLAG_COOLANT_FLOOD bit(6) #define PL_COND_FLAG_COOLANT_MIST bit(7) +#define PL_COND_ACCESSORY_MASK (PL_COND_FLAG_SPINDLE_CW|PL_COND_FLAG_SPINDLE_CCW|PL_COND_FLAG_COOLANT_FLOOD|PL_COND_FLAG_COOLANT_MIST) // This struct stores a linear movement of a g-code block motion with its critical "nominal" values diff --git a/grbl/protocol.c b/grbl/protocol.c index 01cbd93..ad10555 100644 --- a/grbl/protocol.c +++ b/grbl/protocol.c @@ -506,12 +506,17 @@ void protocol_exec_rt_system() static void protocol_exec_rt_suspend() { #ifdef PARKING_ENABLE - // Declare parking local variables + // Declare and initialize parking local variables float restore_target[N_AXIS]; float parking_target[N_AXIS]; float retract_waypoint = PARKING_PULLOUT_INCREMENT; plan_line_data_t plan_data; plan_line_data_t *pl_data = &plan_data; + memset(pl_data,0,sizeof(plan_line_data_t)); + pl_data->condition = (PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE); + #ifdef USE_LINE_NUMBERS + pl_data->line_number = PARKING_MOTION_LINE_NUMBER; + #endif #endif plan_block_t *block = plan_get_current_block(); @@ -554,13 +559,6 @@ static void protocol_exec_rt_suspend() #else - // Initialize planner state data - memset(pl_data,0,sizeof(plan_line_data_t)); - pl_data->condition = (PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE); - #ifdef USE_LINE_NUMBERS - pl_data->line_number = PARKING_MOTION_LINE_NUMBER; - #endif - // Get current position and store restore location and spindle retract waypoint. system_convert_array_steps_to_mpos(parking_target,sys_position); if (bit_isfalse(sys.suspend,SUSPEND_RESTART_RETRACT)) { @@ -581,7 +579,12 @@ static void protocol_exec_rt_suspend() if (parking_target[PARKING_AXIS] < retract_waypoint) { parking_target[PARKING_AXIS] = retract_waypoint; pl_data->feed_rate = PARKING_PULLOUT_RATE; + // NOTE: Retain accessory state for retract motion, then clear for remaining parking motions. + pl_data->condition |= (restore_condition & PL_COND_ACCESSORY_MASK); + pl_data->spindle_speed = restore_spindle_speed; mc_parking_motion(parking_target, pl_data); + pl_data->condition = (PL_COND_FLAG_SYSTEM_MOTION|PL_COND_FLAG_NO_FEED_OVERRIDE); + pl_data->spindle_speed = 0.0; } spindle_set_state(SPINDLE_DISABLE,0.0); // De-energize @@ -677,7 +680,7 @@ static void protocol_exec_rt_suspend() // NOTE: If retract is restarted, spindle and coolant states will be cleared in // the beginning of the retract routine. pl_data->feed_rate = PARKING_PULLOUT_RATE; - pl_data->condition = restore_condition; + pl_data->condition |= (restore_condition & PL_COND_ACCESSORY_MASK); pl_data->spindle_speed = restore_spindle_speed; mc_parking_motion(restore_target, pl_data); }