G38.2 probe feature rough draft installed. Working but needs testing.

- G38.2 straight probe now supported. Rough draft. May be tweaked more
as testing ramps up.

- G38.2 requires at least one axis word. Multiple axis words work too.
When commanded, the probe cycle will move at the last ‘F’ feed rate
specified in a straight line.

- During a probe cycle: If the probe pin goes low (normal high), Grbl
will record that immediate position and engage a feed hold. Meaning
that the CNC machine will move a little past the probe switch point, so
keep federates low to stop sooner. Once stopped, Grbl will issue a move
to go back to the recorded probe trigger point.

- During a probe cycle: If the probe switch does not engage by the time
the machine has traveled to its target coordinates, Grbl will issue an
ALARM and the user will be forced to reset Grbl. (Currently G38.3 probe
without error isn’t supported, but would be easy to implement later.)

- After a successful probe, Grbl will send a feedback message
containing the recorded probe coordinates in the machine coordinate
system. This is as the g-code standard on probe parameters specifies.

- The recorded probe parameters are retained in Grbl memory and can be
viewed with the ‘$#’ print parameters command. Upon a power-cycle, not
a soft-reset, Grbl will re-zero these values.

- Moved ‘$#’ command to require IDLE or ALARM mode, because it accesses
EEPROM to fetch the coordinate system offsets.

- Updated the Grbl version to v0.9d.

- The probe cycle is subject to change upon testing or user-feedback.
This commit is contained in:
Sonny Jeon
2014-02-28 22:03:26 -07:00
parent 4d7ca76f6c
commit 76ab1b6a42
17 changed files with 195 additions and 210 deletions

44
gcode.c
View File

@@ -119,7 +119,7 @@ uint8_t gc_execute_line(char *line)
// Set modal group values
switch(int_value) {
case 4: case 10: case 28: case 30: case 53: case 92: group_number = MODAL_GROUP_0; break;
case 0: case 1: case 2: case 3: case 80: group_number = MODAL_GROUP_1; break;
case 0: case 1: case 2: case 3: case 38: case 80: group_number = MODAL_GROUP_1; break;
case 17: case 18: case 19: group_number = MODAL_GROUP_2; break;
case 90: case 91: group_number = MODAL_GROUP_3; break;
case 93: case 94: group_number = MODAL_GROUP_5; break;
@@ -152,8 +152,10 @@ uint8_t gc_execute_line(char *line)
case 38:
int_value = trunc(10*value); // Multiply by 10 to pick up Gxx.1
switch(int_value) {
case 382: non_modal_action = NON_MODAL_PROBE_WITH_ERROR; break;
case 383: non_modal_action = NON_MODAL_PROBE_NO_ERROR; break;
case 382: gc.motion_mode = MOTION_MODE_PROBE; break;
// case 383: gc.motion_mode = MOTION_MODE_PROBE_NO_ERROR; break; // Not supported.
// case 384: // Not supported.
// case 385: // Not supported.
default: FAIL(STATUS_UNSUPPORTED_STATEMENT);
}
break;
@@ -366,32 +368,6 @@ uint8_t gc_execute_line(char *line)
memcpy(gc.position, coord_data, sizeof(coord_data)); // gc.position[] = coord_data[];
axis_words = 0; // Axis words used. Lock out from motion modes by clearing flags.
break;
case NON_MODAL_PROBE_WITH_ERROR:
if (!axis_words) { // No axis words
FAIL(STATUS_INVALID_STATEMENT);
break;
}
#ifdef USE_LINE_NUMBERS
if(mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, line_number)){
#else
if(mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode)){
#endif
FAIL(STATUS_PROBE_ERROR);
}
axis_words = 0;
break;
case NON_MODAL_PROBE_NO_ERROR:
if (!axis_words) { // No axis words
FAIL(STATUS_INVALID_STATEMENT);
break;
}
#ifdef USE_LINE_NUMBERS
mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, line_number);
#else
mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode);
#endif
axis_words = 0;
break;
case NON_MODAL_SET_HOME_0: case NON_MODAL_SET_HOME_1:
if (non_modal_action == NON_MODAL_SET_HOME_0) {
settings_write_coord_data(SETTING_INDEX_G28,gc.position);
@@ -512,6 +488,16 @@ uint8_t gc_execute_line(char *line)
#endif
}
break;
case MOTION_MODE_PROBE:
if (!axis_words) { FAIL(STATUS_INVALID_STATEMENT); }
else {
#ifdef USE_LINE_NUMBERS
mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, line_number);
#else
mc_probe_cycle(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode);
#endif
}
break;
}
// Report any errors.