Added grbl planner Matlab simulator for test reference. Updated line number compile-time option.

- Added a grbl planner simulation tool that was written in Matlab and
Python. It was used to visualize the inner workings of the planner as a
program is streamed to it. The simulation assumes that the planner
buffer is empty, then filled, and kept filled. This is mainly for users
to see how the planner works.

- Updated some of the compile-time ifdefs when enabling line numbers.
The leaving the un-used line numbers in the function calls eats a
non-neglible amount of flash memory. So the new if-defs remove them.
This commit is contained in:
Sonny Jeon
2014-02-26 12:10:07 -07:00
parent 1fd45791a5
commit 8f8d8e2887
11 changed files with 5549 additions and 39 deletions

38
gcode.c
View File

@ -101,7 +101,9 @@ uint8_t gc_execute_line(char *line)
float target[N_AXIS];
clear_vector(target); // XYZ(ABC) axes parameters.
#ifdef USE_LINE_NUMBERS
int32_t line_number = 0;
#endif
gc.arc_radius = 0;
clear_vector(gc.arc_offset); // IJK Arc offsets are incremental. Value of zero indicates no change.
@ -227,7 +229,11 @@ uint8_t gc_execute_line(char *line)
break;
case 'I': case 'J': case 'K': gc.arc_offset[letter-'I'] = to_millimeters(value); break;
case 'L': l = trunc(value); break;
case 'N': line_number = trunc(value); break;
case 'N':
#ifdef USE_LINE_NUMBERS
line_number = trunc(value);
#endif
break;
case 'P': p = value; break;
case 'R': gc.arc_radius = to_millimeters(value); break;
case 'S':
@ -331,7 +337,11 @@ uint8_t gc_execute_line(char *line)
target[idx] = gc.position[idx];
}
}
#ifdef USE_LINE_NUMBERS
mc_line(target, -1.0, false, line_number);
#else
mc_line(target, -1.0, false);
#endif
}
// Retreive G28/30 go-home position data (in machine coordinates) from EEPROM
float coord_data[N_AXIS];
@ -340,7 +350,11 @@ uint8_t gc_execute_line(char *line)
} else {
if (!settings_read_coord_data(SETTING_INDEX_G30,coord_data)) { return(STATUS_SETTING_READ_FAIL); }
}
#ifdef USE_LINE_NUMBERS
mc_line(coord_data, -1.0, false, line_number);
#else
mc_line(coord_data, -1.0, false);
#endif
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;
@ -411,7 +425,13 @@ uint8_t gc_execute_line(char *line)
break;
case MOTION_MODE_SEEK:
if (!axis_words) { FAIL(STATUS_INVALID_STATEMENT);}
else { mc_line(target, -1.0, false, line_number); }
else {
#ifdef USE_LINE_NUMBERS
mc_line(target, -1.0, false, line_number);
#else
mc_line(target, -1.0, false);
#endif
}
break;
case MOTION_MODE_LINEAR:
// TODO: Inverse time requires F-word with each statement. Need to do a check. Also need
@ -419,7 +439,13 @@ uint8_t gc_execute_line(char *line)
// and after an inverse time move and then check for non-zero feed rate each time. This
// should be efficient and effective.
if (!axis_words) { FAIL(STATUS_INVALID_STATEMENT);}
else { mc_line(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, line_number); }
else {
#ifdef USE_LINE_NUMBERS
mc_line(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, line_number);
#else
mc_line(target, (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode);
#endif
}
break;
case MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC:
// Check if at least one of the axes of the selected plane has been specified. If in center
@ -441,9 +467,15 @@ uint8_t gc_execute_line(char *line)
if (gc.motion_mode == MOTION_MODE_CW_ARC) { isclockwise = true; }
// Trace the arc
#ifdef USE_LINE_NUMBERS
mc_arc(gc.position, target, gc.arc_offset, gc.plane_axis_0, gc.plane_axis_1, gc.plane_axis_2,
(gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode,
gc.arc_radius, isclockwise, line_number);
#else
mc_arc(gc.position, target, gc.arc_offset, gc.plane_axis_0, gc.plane_axis_1, gc.plane_axis_2,
(gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode,
gc.arc_radius, isclockwise);
#endif
}
break;
}