kopia lustrzana https://github.com/gnea/grbl
Merge d2c097cf65
into bfb67f0c79
commit
99ea297d19
20
grbl/gcode.c
20
grbl/gcode.c
|
@ -44,7 +44,9 @@ void gc_init()
|
|||
memset(&gc_state, 0, sizeof(parser_state_t));
|
||||
|
||||
// Load default G54 coordinate system.
|
||||
if (!(settings_read_coord_data(gc_state.modal.coord_select,gc_state.coord_system))) {
|
||||
if (!(settings_read_coord_data(gc_state.modal.coord_select,gc_state.coord_system))
|
||||
|| !(settings_read_coord_data(SETTING_INDEX_G92,gc_state.coord_offset))
|
||||
|| !(settings_read_coord_data(SETTING_INDEX_G43,gc_state.tool_length_offset))) {
|
||||
report_status_message(STATUS_SETTING_READ_FAIL);
|
||||
}
|
||||
}
|
||||
|
@ -549,8 +551,7 @@ uint8_t gc_execute_line(char *line)
|
|||
if (gc_block.values.l == 20) {
|
||||
// L20: Update coordinate system axis at current position (with modifiers) with programmed value
|
||||
// WPos = MPos - WCS - G92 - TLO -> WCS = MPos - G92 - TLO - WPos
|
||||
gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_block.values.xyz[idx];
|
||||
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.ijk[idx] -= gc_state.tool_length_offset; }
|
||||
gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_state.tool_length_offset[idx]-gc_block.values.xyz[idx];
|
||||
} else {
|
||||
// L2: Update coordinate system axis to programmed value.
|
||||
gc_block.values.ijk[idx] = gc_block.values.xyz[idx];
|
||||
|
@ -567,8 +568,7 @@ uint8_t gc_execute_line(char *line)
|
|||
for (idx=0; idx<N_AXIS; idx++) { // Axes indices are consistent, so loop may be used.
|
||||
if (bit_istrue(axis_words,bit(idx)) ) {
|
||||
// WPos = MPos - WCS - G92 - TLO -> G92 = MPos - WCS - TLO - WPos
|
||||
gc_block.values.xyz[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_block.values.xyz[idx];
|
||||
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyz[idx] -= gc_state.tool_length_offset; }
|
||||
gc_block.values.xyz[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_state.tool_length_offset[idx]-gc_block.values.xyz[idx];
|
||||
} else {
|
||||
gc_block.values.xyz[idx] = gc_state.coord_offset[idx];
|
||||
}
|
||||
|
@ -592,8 +592,7 @@ uint8_t gc_execute_line(char *line)
|
|||
if (gc_block.non_modal_command != NON_MODAL_ABSOLUTE_OVERRIDE) {
|
||||
// Apply coordinate offsets based on distance mode.
|
||||
if (gc_block.modal.distance == DISTANCE_MODE_ABSOLUTE) {
|
||||
gc_block.values.xyz[idx] += block_coord_system[idx] + gc_state.coord_offset[idx];
|
||||
if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyz[idx] += gc_state.tool_length_offset; }
|
||||
gc_block.values.xyz[idx] += block_coord_system[idx] + gc_state.coord_offset[idx] + gc_state.tool_length_offset[idx];
|
||||
} else { // Incremental mode
|
||||
gc_block.values.xyz[idx] += gc_state.position[idx];
|
||||
}
|
||||
|
@ -986,8 +985,10 @@ uint8_t gc_execute_line(char *line)
|
|||
if (gc_state.modal.tool_length == TOOL_LENGTH_OFFSET_CANCEL) { // G49
|
||||
gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS] = 0.0;
|
||||
} // else G43.1
|
||||
if ( gc_state.tool_length_offset != gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS] ) {
|
||||
gc_state.tool_length_offset = gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS];
|
||||
if ( gc_state.tool_length_offset[TOOL_LENGTH_OFFSET_AXIS] != gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS] ) {
|
||||
clear_vector(gc_state.tool_length_offset); //keep all other axes zeroed
|
||||
gc_state.tool_length_offset[TOOL_LENGTH_OFFSET_AXIS] = gc_block.values.xyz[TOOL_LENGTH_OFFSET_AXIS];
|
||||
settings_write_coord_data(SETTING_INDEX_G43,gc_state.tool_length_offset);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
}
|
||||
|
@ -1033,6 +1034,7 @@ uint8_t gc_execute_line(char *line)
|
|||
break;
|
||||
case NON_MODAL_SET_COORDINATE_OFFSET:
|
||||
memcpy(gc_state.coord_offset,gc_block.values.xyz,sizeof(gc_block.values.xyz));
|
||||
settings_write_coord_data(SETTING_INDEX_G92,gc_state.coord_offset);
|
||||
system_flag_wco_change();
|
||||
break;
|
||||
case NON_MODAL_RESET_COORDINATE_OFFSET:
|
||||
|
|
|
@ -224,7 +224,7 @@ typedef struct {
|
|||
// position in mm. Loaded from EEPROM when called.
|
||||
float coord_offset[N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
|
||||
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
|
||||
float tool_length_offset; // Tracks tool length offset value when enabled.
|
||||
float tool_length_offset[N_AXIS];// Tracks tool length offset value when enabled.
|
||||
} parser_state_t;
|
||||
extern parser_state_t gc_state;
|
||||
|
||||
|
|
|
@ -251,22 +251,21 @@ void report_ngc_parameters()
|
|||
report_status_message(STATUS_SETTING_READ_FAIL);
|
||||
return;
|
||||
}
|
||||
printPgmString(PSTR("[G"));
|
||||
switch (coord_select) {
|
||||
case 6: printPgmString(PSTR("28")); break;
|
||||
case 7: printPgmString(PSTR("30")); break;
|
||||
default: print_uint8_base10(coord_select+54); break; // G54-G59
|
||||
if(coord_select < N_COORDINATE_SYSTEM) {
|
||||
printPgmString(PSTR("[G"));
|
||||
print_uint8_base10(coord_select+54);
|
||||
} else {
|
||||
static const char prefixes[] PROGMEM = "[G28\0[G30\0[G92\0[TLO\0"; //4 additional offset names packed into one string
|
||||
printPgmString(prefixes + (coord_select - N_COORDINATE_SYSTEM) * 5);
|
||||
}
|
||||
serial_write(':');
|
||||
report_util_axis_values(coord_data);
|
||||
if(coord_select == SETTING_INDEX_G43) { //TLO is reported only for one axis
|
||||
printFloat_CoordValue(coord_data[TOOL_LENGTH_OFFSET_AXIS]);
|
||||
} else {
|
||||
report_util_axis_values(coord_data);
|
||||
}
|
||||
report_util_feedback_line_feed();
|
||||
}
|
||||
printPgmString(PSTR("[G92:")); // Print G92,G92.1 which are not persistent in memory
|
||||
report_util_axis_values(gc_state.coord_offset);
|
||||
report_util_feedback_line_feed();
|
||||
printPgmString(PSTR("[TLO:")); // Print tool length offset value
|
||||
printFloat_CoordValue(gc_state.tool_length_offset);
|
||||
report_util_feedback_line_feed();
|
||||
report_probe_parameters(); // Print probe parameters. Not persistent in memory.
|
||||
}
|
||||
|
||||
|
@ -511,8 +510,7 @@ void report_realtime_status()
|
|||
(sys.report_wco_counter == 0) ) {
|
||||
for (idx=0; idx< N_AXIS; idx++) {
|
||||
// Apply work coordinate offsets and tool length offset to current position.
|
||||
wco[idx] = gc_state.coord_system[idx]+gc_state.coord_offset[idx];
|
||||
if (idx == TOOL_LENGTH_OFFSET_AXIS) { wco[idx] += gc_state.tool_length_offset; }
|
||||
wco[idx] = gc_state.coord_system[idx]+gc_state.coord_offset[idx]+gc_state.tool_length_offset[idx];
|
||||
if (bit_isfalse(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) {
|
||||
print_position[idx] -= wco[idx];
|
||||
}
|
||||
|
|
|
@ -72,11 +72,12 @@
|
|||
|
||||
// Define EEPROM address indexing for coordinate parameters
|
||||
#define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1)
|
||||
#define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+1 // Total number of system stored (from index 0)
|
||||
#define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+3 // Total number of system stored (from index 0)
|
||||
// NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59)
|
||||
#define SETTING_INDEX_G28 N_COORDINATE_SYSTEM // Home position 1
|
||||
#define SETTING_INDEX_G30 N_COORDINATE_SYSTEM+1 // Home position 2
|
||||
// #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported)
|
||||
#define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset
|
||||
#define SETTING_INDEX_G43 N_COORDINATE_SYSTEM+3 // Tool length
|
||||
|
||||
// Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.
|
||||
#define AXIS_N_SETTINGS 4
|
||||
|
|
Ładowanie…
Reference in New Issue