New jog cancel real-time command. Parser typo fix from last push.

- Added a new jog cancel real-time command. Rather than depending on a
feed hold to cancel a jogging motion, this realtime command can be used
instead. The main advantage is if a feed hold is used, you can
accidentally hold the machine right when Grbl returns to IDLE after
completing a jog. And the GUI doesn’t have to worry about tracking this
either.

- Fixed a typo in the g-code parser edits from the last push. Was
causing the G10 set coordinate system command to not work correctly.

- Updated the documentation with the jog cancel command.
This commit is contained in:
Sonny Jeon
2016-09-28 21:17:02 -06:00
parent bf5fc48074
commit e2e2bb5242
10 changed files with 116 additions and 62 deletions

View File

@ -52,7 +52,6 @@
#define CMD_STATUS_REPORT '?'
#define CMD_CYCLE_START '~'
#define CMD_FEED_HOLD '!'
// #define CMD_SAFETY_DOOR '@' // Moved to extended ASCII.
// NOTE: All override realtime commands must be in the extended ASCII character set, starting
// at character value 128 (0x80) and up to 255 (0xFF). If the normal set of realtime commands,
@ -63,7 +62,8 @@
// #define CMD_CYCLE_START 0x82
// #define CMD_FEED_HOLD 0x83
#define CMD_SAFETY_DOOR 0x84
#define CMD_DEBUG_REPORT 0x85 // Only when DEBUG enabled, sends debug report in '{}' braces.
#define CMD_JOG_CANCEL 0x85
#define CMD_DEBUG_REPORT 0x86 // Only when DEBUG enabled, sends debug report in '{}' braces.
#define CMD_FEED_OVR_RESET 0x90 // Restores feed override value to 100%.
#define CMD_FEED_OVR_COARSE_PLUS 0x91
#define CMD_FEED_OVR_COARSE_MINUS 0x92

View File

@ -983,10 +983,10 @@ uint8_t gc_execute_line(char *line)
// [19. Go to predefined position, Set G10, or Set axis offsets ]:
switch(gc_block.non_modal_command) {
case NON_MODAL_SET_COORDINATE_DATA:
settings_write_coord_data(coord_select,gc_block.values.xyz);
settings_write_coord_data(coord_select,gc_block.values.ijk);
// Update system coordinate system if currently active.
if (gc_state.modal.coord_select == coord_select) {
memcpy(gc_state.coord_system,gc_block.values.xyz,N_AXIS*sizeof(float));
memcpy(gc_state.coord_system,gc_block.values.ijk,N_AXIS*sizeof(float));
system_flag_wco_change();
}
break;

View File

@ -23,7 +23,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.1b"
#define GRBL_VERSION_BUILD "20160927"
#define GRBL_VERSION_BUILD "20160928"
// Define standard libraries used by Grbl.
#include <avr/io.h>

View File

@ -276,9 +276,9 @@ void protocol_exec_rt_system()
// to halt and cancel the remainder of the motion.
if (rt_exec & EXEC_MOTION_CANCEL) {
// MOTION_CANCEL only occurs during a CYCLE, but a HOLD and SAFETY_DOOR may been initiated beforehand
// to hold the CYCLE. If so, only flag that motion cancel is complete.
// NOTE: State is still STATE_CYCLE.
sys.suspend |= SUSPEND_MOTION_CANCEL; // Indicate motion cancel when resuming.
// to hold the CYCLE. Motion cancel is valid for a single planner block motion only, while jog cancel
// will handle and clear multiple planner block motions.
if (!(sys.state & STATE_JOG)) { sys.suspend |= SUSPEND_MOTION_CANCEL; } // NOTE: State is STATE_CYCLE.
}
// Execute a feed hold with deceleration, if required. Then, suspend system.

View File

@ -30,12 +30,10 @@
// Internal report utilities to reduce flash with repetitive tasks turned into functions.
void report_util_setting_prefix(uint8_t n) { serial_write('$'); print_uint8_base10(n); serial_write('='); }
static void report_util_line_feed() { printPgmString(PSTR("\r\n")); }
static void report_util_feedback_line_feed() { serial_write(']'); report_util_line_feed(); }
void report_util_setting_prefix(uint8_t n) { serial_write('$'); print_uint8_base10(n); serial_write('='); }
static void report_util_uint8_setting(uint8_t n, int val) { report_util_setting_prefix(n); print_uint8_base10(val); report_util_line_feed(); }
static void report_util_float_setting(uint8_t n, float val) { report_util_setting_prefix(n); printFloat(val,N_DECIMAL_SETTINGVALUE); report_util_line_feed(); }
static void report_util_rpm_setting(uint8_t n, float val) { report_util_setting_prefix(n); printFloat(val,N_DECIMAL_RPMVALUE); report_util_line_feed(); }
// static void report_util_comment_line_feed() { serial_write(')'); report_util_line_feed(); }
static void report_util_axis_values(float *axis_value) {
uint8_t idx;
for (idx=0; idx<N_AXIS; idx++) {
@ -44,6 +42,66 @@ static void report_util_axis_values(float *axis_value) {
}
}
// static void report_util_setting_string(uint8_t n) {
// serial_write(' ');
// serial_write('(');
// switch(n) {
// case 0: printPgmString(PSTR("stp pulse:us")); break;
// case 1: printPgmString(PSTR("idl delay:ms")); break;
// case 2: printPgmString(PSTR("stp inv:msk")); break;
// case 3: printPgmString(PSTR("dir inv:msk")); break;
// case 4: printPgmString(PSTR("stp enbl inv")); break;
// case 5: printPgmString(PSTR("lim inv")); break;
// case 6: printPgmString(PSTR("prb inv")); break;
// case 10: printPgmString(PSTR("rpt:msk")); break;
// case 11: printPgmString(PSTR("jnc dev:mm")); break;
// case 12: printPgmString(PSTR("arc tol:mm")); break;
// case 13: printPgmString(PSTR("rpt inch")); break;
// case 20: printPgmString(PSTR("sft lim")); break;
// case 21: printPgmString(PSTR("hrd lim")); break;
// case 22: printPgmString(PSTR("hm cyc")); break;
// case 23: printPgmString(PSTR("hm dir inv:msk")); break;
// case 24: printPgmString(PSTR("hm feed:mm/min")); break;
// case 25: printPgmString(PSTR("hm seek:mm/min")); break;
// case 26: printPgmString(PSTR("hm delay:ms")); break;
// case 27: printPgmString(PSTR("hm off:mm")); break;
// case 30: printPgmString(PSTR("rpm max")); break;
// case 31: printPgmString(PSTR("rpm min")); break;
// case 32: printPgmString(PSTR("laser")); break;
// default:
// n -= AXIS_SETTINGS_START_VAL;
// uint8_t idx = 0;
// while (n < 10) {
// if (n<10) {
// print_uint8_base10(n+idx);
// switch (idx) {
// case 0: printPgmString(PSTR(":stp/mm")); break;
// case 1: printPgmString(PSTR(":mm/min")); break;
// case 2: printPgmString(PSTR(":mm/s^2")); break;
// case 3: printPgmString(PSTR(":mm max")); break;
// }
// } else {
// n -= 10;
// idx++;
// }
// }
// }
// report_util_comment_line_feed();
// }
static void report_util_uint8_setting(uint8_t n, int val) {
report_util_setting_prefix(n);
print_uint8_base10(val);
report_util_line_feed();
// report_util_setting_string(n);
}
static void report_util_float_setting(uint8_t n, float val, uint8_t n_decimal) {
report_util_setting_prefix(n);
printFloat(val,n_decimal);
report_util_line_feed();
// report_util_setting_string(n);
}
// Handles the primary confirmation protocol response for streaming interfaces and human-feedback.
// For every incoming line, this method responds with an 'ok' for a successful command or an
@ -51,8 +109,7 @@ static void report_util_axis_values(float *axis_value) {
// operation. Errors events can originate from the g-code parser, settings module, or asynchronously
// from a critical error, such as a triggered hard limit. Interface should always monitor for these
// responses.
// NOTE: In silent mode, all error codes are greater than zero.
// TODO: Install silent mode to return only numeric values, primarily for GUIs.
// NOTE: In REPORT_GUI_MODE, all error codes are greater than zero.
void report_status_message(uint8_t status_code)
{
switch(status_code) {
@ -150,7 +207,6 @@ void report_alarm_message(int8_t alarm_code)
// messages such as setup warnings, switch toggling, and how to exit alarms.
// NOTE: For interfaces, messages are always placed within brackets. And if silent mode
// is installed, the message number codes are less than zero.
// TODO: Install silence feedback messages option in settings
void report_feedback_message(uint8_t message_code)
{
printPgmString(PSTR("[MSG:"));
@ -224,19 +280,19 @@ void report_grbl_settings() {
report_util_uint8_setting(5,bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS));
report_util_uint8_setting(6,bit_istrue(settings.flags,BITFLAG_INVERT_PROBE_PIN));
report_util_uint8_setting(10,settings.status_report_mask);
report_util_float_setting(11,settings.junction_deviation);
report_util_float_setting(12,settings.arc_tolerance);
report_util_float_setting(11,settings.junction_deviation,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(12,settings.arc_tolerance,N_DECIMAL_SETTINGVALUE);
report_util_uint8_setting(13,bit_istrue(settings.flags,BITFLAG_REPORT_INCHES));
report_util_uint8_setting(20,bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE));
report_util_uint8_setting(21,bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE));
report_util_uint8_setting(22,bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE));
report_util_uint8_setting(23,settings.homing_dir_mask);
report_util_float_setting(24,settings.homing_feed_rate);
report_util_float_setting(25,settings.homing_seek_rate);
report_util_float_setting(24,settings.homing_feed_rate,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(25,settings.homing_seek_rate,N_DECIMAL_SETTINGVALUE);
report_util_uint8_setting(26,settings.homing_debounce_delay);
report_util_float_setting(27,settings.homing_pulloff);
report_util_rpm_setting(30,settings.rpm_max);
report_util_rpm_setting(31,settings.rpm_min);
report_util_float_setting(27,settings.homing_pulloff,N_DECIMAL_SETTINGVALUE);
report_util_float_setting(30,settings.rpm_max,N_DECIMAL_RPMVALUE);
report_util_float_setting(31,settings.rpm_min,N_DECIMAL_RPMVALUE);
#ifdef VARIABLE_SPINDLE
report_util_uint8_setting(32,bit_istrue(settings.flags,BITFLAG_LASER_MODE));
#else
@ -248,43 +304,15 @@ void report_grbl_settings() {
for (set_idx=0; set_idx<AXIS_N_SETTINGS; set_idx++) {
for (idx=0; idx<N_AXIS; idx++) {
switch (set_idx) {
case 0: report_util_float_setting(val+idx,settings.steps_per_mm[idx]); break;
case 1: report_util_float_setting(val+idx,settings.max_rate[idx]); break;
case 2: report_util_float_setting(val+idx,settings.acceleration[idx]/(60*60)); break;
case 3: report_util_float_setting(val+idx,-settings.max_travel[idx]); break;
case 0: report_util_float_setting(val+idx,settings.steps_per_mm[idx],N_DECIMAL_SETTINGVALUE); break;
case 1: report_util_float_setting(val+idx,settings.max_rate[idx],N_DECIMAL_SETTINGVALUE); break;
case 2: report_util_float_setting(val+idx,settings.acceleration[idx]/(60*60),N_DECIMAL_SETTINGVALUE); break;
case 3: report_util_float_setting(val+idx,-settings.max_travel[idx],N_DECIMAL_SETTINGVALUE); break;
}
}
val += AXIS_SETTINGS_INCREMENT;
}
// printPgmString(PSTR("$0=")); print_uint8_base10(settings.pulse_microseconds);
// printPgmString(PSTR("\r\n$1=")); print_uint8_base10(settings.stepper_idle_lock_time);
// printPgmString(PSTR("\r\n$2=")); print_uint8_base10(settings.step_invert_mask);
// printPgmString(PSTR("\r\n$3=")); print_uint8_base10(settings.dir_invert_mask);
// printPgmString(PSTR("\r\n$4=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE));
// printPgmString(PSTR("\r\n$5=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS));
// printPgmString(PSTR("\r\n$6=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_INVERT_PROBE_PIN));
// printPgmString(PSTR("\r\n$10=")); print_uint8_base10(settings.status_report_mask);
// printPgmString(PSTR("\r\n$11=")); printFloat_SettingValue(settings.junction_deviation);
// printPgmString(PSTR("\r\n$12=")); printFloat_SettingValue(settings.arc_tolerance);
// printPgmString(PSTR("\r\n$13=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_REPORT_INCHES));
// printPgmString(PSTR("\r\n$20=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE));
// printPgmString(PSTR("\r\n$21=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE));
// printPgmString(PSTR("\r\n$22=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE));
// printPgmString(PSTR("\r\n$23=")); print_uint8_base10(settings.homing_dir_mask);
// printPgmString(PSTR("\r\n$24=")); printFloat_SettingValue(settings.homing_feed_rate);
// printPgmString(PSTR("\r\n$25=")); printFloat_SettingValue(settings.homing_seek_rate);
// printPgmString(PSTR("\r\n$26=")); print_uint8_base10(settings.homing_debounce_delay);
// printPgmString(PSTR("\r\n$27=")); printFloat_SettingValue(settings.homing_pulloff);
// printPgmString(PSTR("\r\n$30=")); printFloat_RPMValue(settings.rpm_max);
// printPgmString(PSTR("\r\n$31=")); printFloat_RPMValue(settings.rpm_min);
// #ifdef VARIABLE_SPINDLE
// printPgmString(PSTR("\r\n$32=")); print_uint8_base10(bit_istrue(settings.flags,BITFLAG_LASER_MODE));
// printPgmString(PSTR("\r\n"));
// #else
// printPgmString(PSTR("\r\n$32=0\r\n"));
// #endif
#else
printPgmString(PSTR("$0=")); print_uint8_base10(settings.pulse_microseconds);

View File

@ -157,6 +157,11 @@ ISR(SERIAL_RX)
if (data > 0x7F) { // Real-time control characters are extended ACSII only.
switch(data) {
case CMD_SAFETY_DOOR: system_set_exec_state_flag(EXEC_SAFETY_DOOR); break; // Set as true
case CMD_JOG_CANCEL:
if (sys.state & STATE_JOG) { // Block all other states from invoking motion cancel.
system_set_exec_state_flag(EXEC_MOTION_CANCEL);
}
break;
#ifdef DEBUG
case CMD_DEBUG_REPORT: {uint8_t sreg = SREG; cli(); bit_true(sys_rt_exec_debug,EXEC_DEBUG_REPORT); SREG = sreg;} break;
#endif

View File

@ -202,10 +202,7 @@ uint8_t system_execute_line(char *line)
}
break;
case 'R' : // Restore defaults [IDLE/ALARM]
if (line[2] != 'S') { return(STATUS_INVALID_STATEMENT); }
if (line[3] != 'T') { return(STATUS_INVALID_STATEMENT); }
if (line[4] != '=') { return(STATUS_INVALID_STATEMENT); }
if (line[6] != 0) { return(STATUS_INVALID_STATEMENT); }
if ((line[2] != 'S') || (line[3] != 'T') || (line[4] != '=') || (line[6] != 0)) { return(STATUS_INVALID_STATEMENT); }
switch (line[5]) {
#ifdef ENABLE_RESTORE_EEPROM_DEFAULT_SETTINGS
case '$': settings_restore(SETTINGS_RESTORE_DEFAULTS); break;