Tweaks. Seek rate updates when set. CCW arc full circle fix.
- Fixed a minor issue where the seek rates would not immediately be used and only would after a reset. Should update live now. - A full circle IJ offset CCW arc would not do anything. Fixed bug via a simple if-then statement. - Radius mode tweaks to check for negative value in sqrt() rather than isnan() it. Error report updated to indicate what actually happened.
This commit is contained in:
18
gcode.c
18
gcode.c
@@ -52,7 +52,7 @@ void gc_init()
|
||||
{
|
||||
memset(&gc, 0, sizeof(gc));
|
||||
gc.feed_rate = settings.default_feed_rate; // Should be zero at initialization.
|
||||
gc.seek_rate = settings.default_seek_rate;
|
||||
// gc.seek_rate = settings.default_seek_rate;
|
||||
select_plane(X_AXIS, Y_AXIS, Z_AXIS);
|
||||
gc.absolute_mode = true;
|
||||
|
||||
@@ -323,14 +323,14 @@ uint8_t gc_execute_line(char *line)
|
||||
target[i] = gc.position[i];
|
||||
}
|
||||
}
|
||||
mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], gc.seek_rate, false);
|
||||
mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], settings.default_seek_rate, false);
|
||||
}
|
||||
// Retreive G28/30 go-home position data (in machine coordinates) from EEPROM
|
||||
float coord_data[N_AXIS];
|
||||
uint8_t home_select = SETTING_INDEX_G28;
|
||||
if (non_modal_action == NON_MODAL_GO_HOME_1) { home_select = SETTING_INDEX_G30; }
|
||||
if (!settings_read_coord_data(home_select,coord_data)) { return(STATUS_SETTING_READ_FAIL); }
|
||||
mc_line(coord_data[X_AXIS], coord_data[Y_AXIS], coord_data[Z_AXIS], gc.seek_rate, false);
|
||||
mc_line(coord_data[X_AXIS], coord_data[Y_AXIS], coord_data[Z_AXIS], settings.default_seek_rate, false);
|
||||
axis_words = 0; // Axis words used. Lock out from motion modes by clearing flags.
|
||||
break;
|
||||
case NON_MODAL_SET_HOME_0: case NON_MODAL_SET_HOME_1:
|
||||
@@ -400,7 +400,7 @@ uint8_t gc_execute_line(char *line)
|
||||
break;
|
||||
case MOTION_MODE_SEEK:
|
||||
if (!axis_words) { FAIL(STATUS_INVALID_STATEMENT);}
|
||||
else { mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], gc.seek_rate, false); }
|
||||
else { mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], settings.default_seek_rate, false); }
|
||||
break;
|
||||
case MOTION_MODE_LINEAR:
|
||||
// TODO: Inverse time requires F-word with each statement. Need to do a check. Also need
|
||||
@@ -474,10 +474,12 @@ uint8_t gc_execute_line(char *line)
|
||||
float y = target[gc.plane_axis_1]-gc.position[gc.plane_axis_1];
|
||||
|
||||
clear_vector(offset);
|
||||
float h_x2_div_d = -sqrt(4 * r*r - x*x - y*y)/hypot(x,y); // == -(h * 2 / d)
|
||||
// If r is smaller than d, the arc is now traversing the complex plane beyond the reach of any
|
||||
// real CNC, and thus - for practical reasons - we will terminate promptly:
|
||||
if(isnan(h_x2_div_d)) { FAIL(STATUS_FLOATING_POINT_ERROR); return(gc.status_code); }
|
||||
// First, use h_x2_div_d to compute 4*h^2 to check if it is negative or r is smaller
|
||||
// than d. If so, the sqrt of a negative number is complex and error out.
|
||||
float h_x2_div_d = 4 * r*r - x*x - y*y;
|
||||
if (h_x2_div_d < 0) { FAIL(STATUS_ARC_RADIUS_ERROR); return(gc.status_code); }
|
||||
// Finish computing h_x2_div_d.
|
||||
h_x2_div_d = -sqrt(h_x2_div_d)/hypot(x,y); // == -(h * 2 / d)
|
||||
// Invert the sign of h_x2_div_d if the circle is counter clockwise (see sketch below)
|
||||
if (gc.motion_mode == MOTION_MODE_CCW_ARC) { h_x2_div_d = -h_x2_div_d; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user