From 6fdf10ba066bbdd7e1d1d971a22caf33f19bb4dc Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Wed, 13 Aug 2014 21:12:37 -0600 Subject: [PATCH] G28/30 bug fix. Block '$$' during cycle. SO2 defaults. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A G28/30 bug would cause it to move to machine coordinate [0,0,0] if no axis words were sent. It was a typo in the new g-code parser. Fixed and slightly re-written to be more consistent with the program flow. - Updated the ShapeOko2 defaults based on testing on the real machine. A little conservative, but it might change again after some more testing. - Now blocks ‘$$’ command during a motion, because the printout takes too long and can starve the segment buffer. --- defaults.h | 19 +++++++------------ gcode.c | 2 ++ serial.c | 1 + settings.h | 2 +- system.c | 1 + 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/defaults.h b/defaults.h index 147a863..678b8e2 100644 --- a/defaults.h +++ b/defaults.h @@ -48,7 +48,6 @@ #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)) #define DEFAULT_JUNCTION_DEVIATION 0.02 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm - #define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false @@ -88,7 +87,6 @@ #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)) #define DEFAULT_JUNCTION_DEVIATION 0.02 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm - #define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_REPORT_INCHES 0 // true #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false @@ -131,7 +129,6 @@ #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)) #define DEFAULT_JUNCTION_DEVIATION 0.05 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm - #define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false @@ -148,7 +145,7 @@ #ifdef DEFAULTS_SHAPEOKO_2 // Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos - // grblShield with a 24V, 4.2A power supply. + // grblShield at 28V. #define MICROSTEPS_XY 8 #define STEP_REVS_XY 200 #define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth @@ -158,12 +155,12 @@ #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY) #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY) #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z) - #define DEFAULT_X_MAX_RATE 500.0 // mm/min - #define DEFAULT_Y_MAX_RATE 500.0 // mm/min - #define DEFAULT_Z_MAX_RATE 500.0 // mm/min - #define DEFAULT_X_ACCELERATION (25.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 - #define DEFAULT_Y_ACCELERATION (25.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 - #define DEFAULT_Z_ACCELERATION (25.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 + #define DEFAULT_X_MAX_RATE 5000.0 // mm/min + #define DEFAULT_Y_MAX_RATE 5000.0 // mm/min + #define DEFAULT_Z_MAX_RATE 750.0 // mm/min + #define DEFAULT_X_ACCELERATION (250.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 + #define DEFAULT_Y_ACCELERATION (250.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 + #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2 #define DEFAULT_X_MAX_TRAVEL 200.0 // mm #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm @@ -174,7 +171,6 @@ #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)) #define DEFAULT_JUNCTION_DEVIATION 0.05 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm - #define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false @@ -215,7 +211,6 @@ #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)) #define DEFAULT_JUNCTION_DEVIATION 0.02 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm - #define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false diff --git a/gcode.c b/gcode.c index e8f27d8..1977d83 100644 --- a/gcode.c +++ b/gcode.c @@ -610,11 +610,13 @@ uint8_t gc_execute_line(char *line) case NON_MODAL_GO_HOME_0: // [G28 Errors]: Cutter compensation is enabled. // Retreive G28 go-home position data (in machine coordinates) from EEPROM + if (!axis_words) { axis_command = AXIS_COMMAND_NONE; } // Set to none if no intermediate motion. if (!settings_read_coord_data(SETTING_INDEX_G28,parameter_data)) { FAIL(STATUS_SETTING_READ_FAIL); } break; case NON_MODAL_GO_HOME_1: // [G30 Errors]: Cutter compensation is enabled. // Retreive G30 go-home position data (in machine coordinates) from EEPROM + if (!axis_words) { axis_command = AXIS_COMMAND_NONE; } // Set to none if no intermediate motion. if (!settings_read_coord_data(SETTING_INDEX_G30,parameter_data)) { FAIL(STATUS_SETTING_READ_FAIL); } break; case NON_MODAL_SET_HOME_0: case NON_MODAL_SET_HOME_1: diff --git a/serial.c b/serial.c index 89d6107..8e7d50b 100644 --- a/serial.c +++ b/serial.c @@ -97,6 +97,7 @@ void serial_write(uint8_t data) { // Wait until there is space in the buffer while (next_head == serial_tx_buffer_tail) { + // TODO: Restructure st_prep_buffer() calls to be executed here during a long print. if (sys.execute & EXEC_RESET) { return; } // Only check for abort to avoid an endless loop. } diff --git a/settings.h b/settings.h index aae276d..3fa4501 100644 --- a/settings.h +++ b/settings.h @@ -29,7 +29,7 @@ #define GRBL_VERSION "0.9g" -#define GRBL_VERSION_BUILD "20140805" +#define GRBL_VERSION_BUILD "20140813" // 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 diff --git a/system.c b/system.c index d9abc71..9079820 100644 --- a/system.c +++ b/system.c @@ -88,6 +88,7 @@ uint8_t system_execute_line(char *line) case 0 : report_grbl_help(); break; case '$' : // Prints Grbl settings if ( line[++char_counter] != 0 ) { return(STATUS_INVALID_STATEMENT); } + if ( sys.state & (STATE_CYCLE | STATE_HOLD) ) { return(STATUS_IDLE_ERROR); } // Block during cycle. Takes too long to print. else { report_grbl_settings(); } break; case 'G' : // Prints gcode parser state