Updated interface protocol. Fixed M2 bug.

- Updated interface protocol to play nicer with interface programs. All
Grbl responses beginning with '$' signifies a setting. Bracketed '[]'
responses are feedback messages containing either state, parameter, or
general messages. Chevron '<>' response are from the real-time status
messages, i.e. position.

- M2 Program end command was causing a system alarm. Fixed. Thanks
@blinkenlight !
This commit is contained in:
Sonny Jeon 2012-11-19 17:39:40 -07:00
parent b3f5536530
commit 9e0ce55dbc
4 changed files with 41 additions and 42 deletions

View File

@ -29,14 +29,14 @@
#ifdef DEFAULTS_GENERIC #ifdef DEFAULTS_GENERIC
// Grbl generic default settings. Should work across different machines. // Grbl generic default settings. Should work across different machines.
#define DEFAULT_X_STEPS_PER_MM 250 #define DEFAULT_X_STEPS_PER_MM 250.0
#define DEFAULT_Y_STEPS_PER_MM 250 #define DEFAULT_Y_STEPS_PER_MM 250.0
#define DEFAULT_Z_STEPS_PER_MM 250 #define DEFAULT_Z_STEPS_PER_MM 250.0
#define DEFAULT_STEP_PULSE_MICROSECONDS 10 #define DEFAULT_STEP_PULSE_MICROSECONDS 10
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1 #define DEFAULT_MM_PER_ARC_SEGMENT 0.1
#define DEFAULT_RAPID_FEEDRATE 500.0 // mm/min #define DEFAULT_RAPID_FEEDRATE 500.0 // mm/min
#define DEFAULT_FEEDRATE 250.0 #define DEFAULT_FEEDRATE 250.0
#define DEFAULT_ACCELERATION 10*60*60 // 10 mm/min^2 #define DEFAULT_ACCELERATION (10.0*60*60) // 10 mm/min^2
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm #define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) #define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
#define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_REPORT_INCHES 0 // false
@ -46,9 +46,9 @@
#define DEFAULT_HOMING_ENABLE 0 // false #define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min #define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min #define DEFAULT_HOMING_FEEDRATE 25.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k) #define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1 // mm #define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255) #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
#define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_DECIMAL_PLACES 3
#define DEFAULT_N_ARC_CORRECTION 25 #define DEFAULT_N_ARC_CORRECTION 25
@ -76,10 +76,10 @@
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false #define DEFAULT_HARD_LIMIT_ENABLE 0 // false
#define DEFAULT_HOMING_ENABLE 0 // false #define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_RAPID_FEEDRATE 254.0 // mm/min #define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min #define DEFAULT_HOMING_FEEDRATE 25.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k) #define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1 // mm #define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255) #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
#define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_DECIMAL_PLACES 3
#define DEFAULT_N_ARC_CORRECTION 25 #define DEFAULT_N_ARC_CORRECTION 25
@ -101,7 +101,7 @@
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1 #define DEFAULT_MM_PER_ARC_SEGMENT 0.1
#define DEFAULT_RAPID_FEEDRATE 1000.0 // mm/min #define DEFAULT_RAPID_FEEDRATE 1000.0 // mm/min
#define DEFAULT_FEEDRATE 250.0 #define DEFAULT_FEEDRATE 250.0
#define DEFAULT_ACCELERATION 15.0*60*60 // 15 mm/min^2 #define DEFAULT_ACCELERATION (15.0*60*60) // 15 mm/min^2
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm #define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) #define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
#define DEFAULT_REPORT_INCHES 0 // false #define DEFAULT_REPORT_INCHES 0 // false
@ -111,9 +111,9 @@
#define DEFAULT_HOMING_ENABLE 0 // false #define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
#define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min #define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min #define DEFAULT_HOMING_FEEDRATE 25.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k) #define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1 // mm #define DEFAULT_HOMING_PULLOFF 1.0 // mm
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-255) #define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-255)
#define DEFAULT_DECIMAL_PLACES 3 #define DEFAULT_DECIMAL_PLACES 3
#define DEFAULT_N_ARC_CORRECTION 25 #define DEFAULT_N_ARC_CORRECTION 25

View File

@ -327,10 +327,11 @@ uint8_t plan_check_full_buffer()
return(false); return(false);
} }
// Block until all buffered steps are executed. // Block until all buffered steps are executed or in a cycle state. Works with feed hold
// during a synchronize call, if it should happen. Also, waits for clean cycle end.
void plan_synchronize() void plan_synchronize()
{ {
while (plan_get_current_block()) { while (plan_get_current_block() || sys.state == STATE_CYCLE) {
protocol_execute_runtime(); // Check and execute run-time commands protocol_execute_runtime(); // Check and execute run-time commands
if (sys.abort) { return; } // Check for system abort if (sys.abort) { return; } // Check for system abort
} }

View File

@ -182,18 +182,18 @@ void report_gcode_parameters()
report_status_message(STATUS_SETTING_READ_FAIL); report_status_message(STATUS_SETTING_READ_FAIL);
return; return;
} }
printPgmString(PSTR("[G"));
switch (coord_select) { switch (coord_select) {
case 0: printPgmString(PSTR("G54")); break; case 0: printPgmString(PSTR("54:")); break;
case 1: printPgmString(PSTR("G55")); break; case 1: printPgmString(PSTR("55:")); break;
case 2: printPgmString(PSTR("G56")); break; case 2: printPgmString(PSTR("56:")); break;
case 3: printPgmString(PSTR("G57")); break; case 3: printPgmString(PSTR("57:")); break;
case 4: printPgmString(PSTR("G58")); break; case 4: printPgmString(PSTR("58:")); break;
case 5: printPgmString(PSTR("G59")); break; case 5: printPgmString(PSTR("59:")); break;
case 6: printPgmString(PSTR("G28")); break; case 6: printPgmString(PSTR("28:")); break;
case 7: printPgmString(PSTR("G30")); break; case 7: printPgmString(PSTR("30:")); break;
// case 8: printPgmString(PSTR("G92")); break; // G92.2, G92.3 not supported. Hence not stored. // case 8: printPgmString(PSTR("92:")); break; // G92.2, G92.3 not supported. Hence not stored.
} }
printPgmString(PSTR(":["));
for (i=0; i<N_AXIS; i++) { for (i=0; i<N_AXIS; i++) {
if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(coord_data[i]*INCH_PER_MM); } if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(coord_data[i]*INCH_PER_MM); }
else { printFloat(coord_data[i]); } else { printFloat(coord_data[i]); }
@ -201,7 +201,7 @@ void report_gcode_parameters()
else { printPgmString(PSTR("]\r\n")); } else { printPgmString(PSTR("]\r\n")); }
} }
} }
printPgmString(PSTR("G92:[")); // Print G92,G92.1 which are not persistent in memory printPgmString(PSTR("[G92:")); // Print G92,G92.1 which are not persistent in memory
for (i=0; i<N_AXIS; i++) { for (i=0; i<N_AXIS; i++) {
if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(gc.coord_offset[i]*INCH_PER_MM); } if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(gc.coord_offset[i]*INCH_PER_MM); }
else { printFloat(gc.coord_offset[i]); } else { printFloat(gc.coord_offset[i]); }
@ -215,11 +215,11 @@ void report_gcode_parameters()
void report_gcode_modes() void report_gcode_modes()
{ {
switch (gc.motion_mode) { switch (gc.motion_mode) {
case MOTION_MODE_SEEK : printPgmString(PSTR("G0")); break; case MOTION_MODE_SEEK : printPgmString(PSTR("[G0")); break;
case MOTION_MODE_LINEAR : printPgmString(PSTR("G1")); break; case MOTION_MODE_LINEAR : printPgmString(PSTR("[G1")); break;
case MOTION_MODE_CW_ARC : printPgmString(PSTR("G2")); break; case MOTION_MODE_CW_ARC : printPgmString(PSTR("[G2")); break;
case MOTION_MODE_CCW_ARC : printPgmString(PSTR("G3")); break; case MOTION_MODE_CCW_ARC : printPgmString(PSTR("[G3")); break;
case MOTION_MODE_CANCEL : printPgmString(PSTR("G80")); break; case MOTION_MODE_CANCEL : printPgmString(PSTR("[G80")); break;
} }
printPgmString(PSTR(" G")); printPgmString(PSTR(" G"));
@ -266,13 +266,13 @@ void report_gcode_modes()
if (gc.inches_mode) { printFloat(gc.feed_rate*INCH_PER_MM); } if (gc.inches_mode) { printFloat(gc.feed_rate*INCH_PER_MM); }
else { printFloat(gc.feed_rate); } else { printFloat(gc.feed_rate); }
printPgmString(PSTR("\r\n")); printPgmString(PSTR("]\r\n"));
} }
// Prints specified startup line // Prints specified startup line
void report_startup_line(uint8_t n, char *line) void report_startup_line(uint8_t n, char *line)
{ {
printPgmString(PSTR("N")); printInteger(n); printPgmString(PSTR("$N")); printInteger(n);
printPgmString(PSTR("=")); printString(line); printPgmString(PSTR("=")); printString(line);
printPgmString(PSTR("\r\n")); printPgmString(PSTR("\r\n"));
} }
@ -295,14 +295,14 @@ void report_realtime_status()
// Report current machine state // Report current machine state
switch (sys.state) { switch (sys.state) {
case STATE_IDLE: printPgmString(PSTR("[Idle")); break; case STATE_IDLE: printPgmString(PSTR("<Idle")); break;
// case STATE_INIT: printPgmString(PSTR("[Init")); break; // Never observed // case STATE_INIT: printPgmString(PSTR("[Init")); break; // Never observed
case STATE_QUEUED: printPgmString(PSTR("[Queue")); break; case STATE_QUEUED: printPgmString(PSTR("<Queue")); break;
case STATE_CYCLE: printPgmString(PSTR("[Run")); break; case STATE_CYCLE: printPgmString(PSTR("<Run")); break;
case STATE_HOLD: printPgmString(PSTR("[Hold")); break; case STATE_HOLD: printPgmString(PSTR("<Hold")); break;
case STATE_HOMING: printPgmString(PSTR("[Home")); break; case STATE_HOMING: printPgmString(PSTR("<Home")); break;
case STATE_ALARM: printPgmString(PSTR("[Alarm")); break; case STATE_ALARM: printPgmString(PSTR("<Alarm")); break;
case STATE_CHECK_MODE: printPgmString(PSTR("[Check")); break; case STATE_CHECK_MODE: printPgmString(PSTR("<Check")); break;
} }
// Report machine position // Report machine position
@ -326,5 +326,5 @@ void report_realtime_status()
if (i < 2) { printPgmString(PSTR(",")); } if (i < 2) { printPgmString(PSTR(",")); }
} }
printPgmString(PSTR("]\r\n")); printPgmString(PSTR(">\r\n"));
} }

View File

@ -420,8 +420,6 @@ static void set_step_events_per_minute(uint32_t steps_per_minute)
// Planner external interface to start stepper interrupt and execute the blocks in queue. Called // Planner external interface to start stepper interrupt and execute the blocks in queue. Called
// by the main program functions: planner auto-start and run-time command execution. // by the main program functions: planner auto-start and run-time command execution.
// TODO: Update sys.cycle_start and feed_hold variables to a sys.state variable. This state
// variable will manage all of Grbl's processes and keep them separate.
void st_cycle_start() void st_cycle_start()
{ {
if (sys.state == STATE_QUEUED) { if (sys.state == STATE_QUEUED) {