New startup script setting. New dry run, check gcode switches. New system state variable. Lots of reorganizing.
(All v0.8 features installed. Still likely buggy, but now thourough testing will need to start to squash them all. As soon as we're done, this will be pushed to master and v0.9 development will be started. Please report ANY issues to us so we can get this rolled out ASAP.) - User startup script! A user can now save one (up to 5 as compile-time option) block of g-code in EEPROM memory. This will be run everytime Grbl resets. Mainly to be used as a way to set your preferences, like G21, G54, etc. - New dry run and check g-code switches. Dry run moves ALL motions at rapids rate ignoring spindle, coolant, and dwell commands. For rapid physical proofing of your code. The check g-code switch ignores all motion and provides the user a way to check if there are any errors in their program that Grbl may not like. - Program restart! (sort of). Program restart is typically an advanced feature that allows users to restart a program mid-stream. The check g-code switch can perform this feature by enabling the switch at the start of the program, and disabling it at the desired point with some minimal changes. - New system state variable. This state variable tracks all of the different state processes that Grbl performs, i.e. cycle start, feed hold, homing, etc. This is mainly for making managing of these task easier and more clear. - Position lost state variable. Only when homing is enabled, Grbl will refuse to move until homing is completed and position is known. This is mainly for safety. Otherwise, it will let users fend for themselves. - Moved the default settings defines into config.h. The plan is to eventually create a set of config.h's for particular as-built machines to help users from doing it themselves. - Moved around misc defines into .h files. And lots of other little things.
This commit is contained in:
167
report.c
167
report.c
@ -26,14 +26,11 @@
|
||||
methods to accomodate their needs.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "print.h"
|
||||
#include "settings.h"
|
||||
#include <math.h>
|
||||
#include "nuts_bolts.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include "report.h"
|
||||
#include "protocol.h"
|
||||
#include "print.h"
|
||||
#include "settings.h"
|
||||
#include "nuts_bolts.h"
|
||||
#include "gcode.h"
|
||||
#include "coolant_control.h"
|
||||
|
||||
@ -75,6 +72,10 @@ void report_status_message(uint8_t status_code)
|
||||
printPgmString(PSTR("Step pulse must be >= 3 microseconds")); break;
|
||||
case STATUS_SETTING_READ_FAIL:
|
||||
printPgmString(PSTR("Failed to read EEPROM settings. Using defaults")); break;
|
||||
case STATUS_HOMING_ERROR:
|
||||
printPgmString(PSTR("Grbl must be idle to home")); break;
|
||||
case STATUS_ABORT_CYCLE:
|
||||
printPgmString(PSTR("Abort during cycle")); break;
|
||||
}
|
||||
printPgmString(PSTR("\r\n"));
|
||||
}
|
||||
@ -84,78 +85,91 @@ void report_status_message(uint8_t status_code)
|
||||
// Prints feedback messages. This serves as a centralized method to provide additional
|
||||
// user feedback for things that are not of the status message response protocol. These
|
||||
// are messages such as setup warnings and how to exit alarms.
|
||||
// NOTE: For interfaces, messages are always placed within chevrons. And if silent mode
|
||||
// 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(int8_t message_code)
|
||||
{
|
||||
printPgmString(PSTR("<"));
|
||||
printPgmString(PSTR("["));
|
||||
switch(message_code) {
|
||||
case MESSAGE_SYSTEM_ALARM:
|
||||
printPgmString(PSTR("ALARM: Check and reset Grbl")); break;
|
||||
case MESSAGE_POSITION_LOST:
|
||||
printPgmString(PSTR("warning: Position may be lost")); break;
|
||||
printPgmString(PSTR("Position unknown. '$H' to home")); break;
|
||||
case MESSAGE_HOMING_ENABLE:
|
||||
printPgmString(PSTR("'$H' to home. Ensure all limit switches are installed")); break;
|
||||
printPgmString(PSTR("WARNING: All limit switches must be installed before homing")); break;
|
||||
case MESSAGE_SWITCH_ON:
|
||||
printPgmString(PSTR("Switch enabled")); break;
|
||||
case MESSAGE_SWITCH_OFF:
|
||||
printPgmString(PSTR("Switch disabled")); break;
|
||||
case MESSAGE_SWITCHES_CLEARED:
|
||||
printPgmString(PSTR("Switches cleared")); break;
|
||||
}
|
||||
printPgmString(PSTR(">\r\n"));
|
||||
printPgmString(PSTR("]\r\n"));
|
||||
}
|
||||
|
||||
|
||||
// Welcome message
|
||||
void report_init_message()
|
||||
{
|
||||
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION " ['$' for help]\r\n"));
|
||||
}
|
||||
|
||||
|
||||
// Grbl help message
|
||||
void report_grbl_help() {
|
||||
// char st_line[LINE_BUFFER_SIZE];
|
||||
// printPgmString(PSTR("\r\n\r\n Startup\r\n$100 = ")); printString(settings_read_startup(st_line,0));
|
||||
// printPgmString(PSTR("\r\n$101 = ")); printString(settings_read_startup(st_line,1));
|
||||
|
||||
// char buf[4];
|
||||
// settings_startup_string((char *)buf);
|
||||
// printPgmString(PSTR("\r\n Startup: ")); printString(buf);
|
||||
|
||||
printPgmString(PSTR("$ (help)\r\n$$ (print Grbl settings)\r\n$# (print gcode parameters)\r\n$G (print gcode parser state)"));
|
||||
printPgmString(PSTR("\r\n$x=value (store Grbl setting)\r\n$Nx=line (store startup block)\r\n$H (run homing cycle, if enabled)"));
|
||||
printPgmString(PSTR("\r\n$B (toggle block delete)\r\n$S (toggle single block mode)\r\n$O (toggle opt stop)"));
|
||||
printPgmString(PSTR("\r\n~ (cycle start)\r\n! (feed hold)\r\n? (current position)\r\n^x (reset Grbl)\r\n"));
|
||||
printPgmString(PSTR("$ (help)\r\n"
|
||||
"$$ (print Grbl settings)\r\n"
|
||||
"$# (print gcode parameters)\r\n"
|
||||
"$G (print gcode parser state)\r\n"
|
||||
"$N (print startup blocks)\r\n"
|
||||
"$x=value (store Grbl setting)\r\n"
|
||||
"$Nx=line (store startup block)\r\n"
|
||||
"$H (perform homing cycle)\r\n"
|
||||
"$S (clear all switches)\r\n"
|
||||
"$S0 (toggle check gcode)\r\n"
|
||||
"$S1 (toggle dry run)\r\n"
|
||||
"$S2 (toggle block delete)\r\n"
|
||||
"$S3 (toggle single block)\r\n"
|
||||
"$S4 (toggle optional stop)\r\n"
|
||||
"~ (cycle start)\r\n"
|
||||
"! (feed hold)\r\n"
|
||||
"? (current position)\r\n"
|
||||
"^x (reset Grbl)\r\n"));
|
||||
}
|
||||
|
||||
// Grbl global settings print out.
|
||||
// NOTE: The numbering scheme here must correlate to storing in settings.c
|
||||
void report_grbl_settings() {
|
||||
printPgmString(PSTR("$0 = ")); printFloat(settings.steps_per_mm[X_AXIS]);
|
||||
printPgmString(PSTR(" (x axis, steps/mm)\r\n$1 = ")); printFloat(settings.steps_per_mm[Y_AXIS]);
|
||||
printPgmString(PSTR(" (y axis, steps/mm)\r\n$2 = ")); printFloat(settings.steps_per_mm[Z_AXIS]);
|
||||
printPgmString(PSTR(" (z axis, steps/mm)\r\n$3 = ")); printInteger(settings.pulse_microseconds);
|
||||
printPgmString(PSTR(" (step pulse, usec)\r\n$4 = ")); printFloat(settings.default_feed_rate);
|
||||
printPgmString(PSTR(" (default feed rate, mm/min)\r\n$5 = ")); printFloat(settings.default_seek_rate);
|
||||
printPgmString(PSTR(" (default seek rate, mm/min)\r\n$6 = ")); printFloat(settings.mm_per_arc_segment);
|
||||
printPgmString(PSTR(" (arc resolution, mm/segment)\r\n$7 = ")); printInteger(settings.invert_mask);
|
||||
printPgmString(PSTR(" (step port invert mask, int:binary = ")); print_uint8_base2(settings.invert_mask);
|
||||
printPgmString(PSTR(")\r\n$8 = ")); printFloat(settings.acceleration/(60*60)); // Convert from mm/min^2 for human readability
|
||||
printPgmString(PSTR(" (acceleration, mm/sec^2)\r\n$9 = ")); printFloat(settings.junction_deviation);
|
||||
printPgmString(PSTR(" (cornering junction deviation, mm)\r\n$10 = ")); printInteger(bit_istrue(settings.flags,BITFLAG_REPORT_INCHES));
|
||||
printPgmString(PSTR(" (status report inches, bool)\r\n$11 = ")); printInteger(bit_istrue(settings.flags,BITFLAG_AUTO_START));
|
||||
printPgmString(PSTR(" (auto start enable, bool)\r\n$12 = ")); printInteger(bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE));
|
||||
printPgmString(PSTR(" (invert stepper enable, bool)\r\n$13 = ")); printInteger(bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE));
|
||||
printPgmString(PSTR(" (hard limit enable, bool)\r\n$14 = ")); printInteger(bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE));
|
||||
printPgmString(PSTR(" (homing enable, bool)\r\n$15 = ")); printInteger(settings.homing_dir_mask);
|
||||
printPgmString(PSTR(" (homing direction mask, int:binary = ")); print_uint8_base2(settings.homing_dir_mask);
|
||||
printPgmString(PSTR(")\r\n$16 = ")); printFloat(settings.homing_feed_rate);
|
||||
printPgmString(PSTR(" (homing feed rate, mm/min)\r\n$17 = ")); printFloat(settings.homing_seek_rate);
|
||||
printPgmString(PSTR(" (homing seek rate, mm/min)\r\n$18 = ")); printInteger(settings.homing_debounce_delay);
|
||||
printPgmString(PSTR(" (homing debounce delay, msec)\r\n$19 = ")); printFloat(settings.homing_pulloff);
|
||||
printPgmString(PSTR(" (homing pull-off travel, mm)\r\n$20 = ")); printInteger(settings.stepper_idle_lock_time);
|
||||
printPgmString(PSTR(" (stepper idle lock time, msec)\r\n$21 = ")); printInteger(settings.decimal_places);
|
||||
printPgmString(PSTR(" (decimal places, int)\r\n$22 = ")); printInteger(settings.n_arc_correction);
|
||||
printPgmString(PSTR("$0=")); printFloat(settings.steps_per_mm[X_AXIS]);
|
||||
printPgmString(PSTR(" (x axis, steps/mm)\r\n$1=")); printFloat(settings.steps_per_mm[Y_AXIS]);
|
||||
printPgmString(PSTR(" (y axis, steps/mm)\r\n$2=")); printFloat(settings.steps_per_mm[Z_AXIS]);
|
||||
printPgmString(PSTR(" (z axis, steps/mm)\r\n$3=")); printInteger(settings.pulse_microseconds);
|
||||
printPgmString(PSTR(" (step pulse, usec)\r\n$4=")); printFloat(settings.default_feed_rate);
|
||||
printPgmString(PSTR(" (default feed rate, mm/min)\r\n$5=")); printFloat(settings.default_seek_rate);
|
||||
printPgmString(PSTR(" (default seek rate, mm/min)\r\n$6=")); printFloat(settings.mm_per_arc_segment);
|
||||
printPgmString(PSTR(" (arc resolution, mm/segment)\r\n$7=")); printInteger(settings.invert_mask);
|
||||
printPgmString(PSTR(" (step port invert mask, int:binary=")); print_uint8_base2(settings.invert_mask);
|
||||
printPgmString(PSTR(")\r\n$8=")); printFloat(settings.acceleration/(60*60)); // Convert from mm/min^2 for human readability
|
||||
printPgmString(PSTR(" (acceleration, mm/sec^2)\r\n$9=")); printFloat(settings.junction_deviation);
|
||||
printPgmString(PSTR(" (cornering junction deviation, mm)\r\n$10=")); printInteger(bit_istrue(settings.flags,BITFLAG_REPORT_INCHES));
|
||||
printPgmString(PSTR(" (report inches, bool)\r\n$11=")); printInteger(bit_istrue(settings.flags,BITFLAG_AUTO_START));
|
||||
printPgmString(PSTR(" (auto start enable, bool)\r\n$12=")); printInteger(bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE));
|
||||
printPgmString(PSTR(" (invert stepper enable, bool)\r\n$13=")); printInteger(bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE));
|
||||
printPgmString(PSTR(" (hard limit enable, bool)\r\n$14=")); printInteger(bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE));
|
||||
printPgmString(PSTR(" (homing enable, bool)\r\n$15=")); printInteger(settings.homing_dir_mask);
|
||||
printPgmString(PSTR(" (homing dir invert mask, int:binary=")); print_uint8_base2(settings.homing_dir_mask);
|
||||
printPgmString(PSTR(")\r\n$16=")); printFloat(settings.homing_feed_rate);
|
||||
printPgmString(PSTR(" (homing feed rate, mm/min)\r\n$17=")); printFloat(settings.homing_seek_rate);
|
||||
printPgmString(PSTR(" (homing seek rate, mm/min)\r\n$18=")); printInteger(settings.homing_debounce_delay);
|
||||
printPgmString(PSTR(" (homing debounce delay, msec)\r\n$19=")); printFloat(settings.homing_pulloff);
|
||||
printPgmString(PSTR(" (homing pull-off travel, mm)\r\n$20=")); printInteger(settings.stepper_idle_lock_time);
|
||||
printPgmString(PSTR(" (stepper idle lock time, msec)\r\n$21=")); printInteger(settings.decimal_places);
|
||||
printPgmString(PSTR(" (decimal places, int)\r\n$22=")); printInteger(settings.n_arc_correction);
|
||||
printPgmString(PSTR(" (n arc correction, int)\r\n"));
|
||||
}
|
||||
|
||||
|
||||
// Prints gcode coordinate offset parameters
|
||||
void report_gcode_parameters()
|
||||
{
|
||||
float coord_data[N_AXIS];
|
||||
@ -174,7 +188,7 @@ void report_gcode_parameters()
|
||||
case 5: printPgmString(PSTR("G59")); break;
|
||||
case 6: printPgmString(PSTR("G28")); break;
|
||||
case 7: printPgmString(PSTR("G30")); break;
|
||||
// case 8: printPgmString(PSTR("G92")); break; // G92.2, G92.3 currently not supported.
|
||||
// case 8: printPgmString(PSTR("G92")); break; // G92.2, G92.3 not supported. Hence not stored.
|
||||
}
|
||||
printPgmString(PSTR(":["));
|
||||
for (i=0; i<N_AXIS; i++) {
|
||||
@ -193,6 +207,8 @@ void report_gcode_parameters()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print current gcode parser mode state and active switches
|
||||
void report_gcode_modes()
|
||||
{
|
||||
switch (gc.motion_mode) {
|
||||
@ -219,9 +235,7 @@ void report_gcode_modes()
|
||||
|
||||
if (gc.inverse_feed_rate_mode) { printPgmString(PSTR(" G93")); }
|
||||
else { printPgmString(PSTR(" G94")); }
|
||||
|
||||
// TODO: Check if G92 needs to be here. If so, how to track it.
|
||||
|
||||
|
||||
switch (gc.program_flow) {
|
||||
case PROGRAM_FLOW_RUNNING : printPgmString(PSTR(" M0")); break;
|
||||
case PROGRAM_FLOW_PAUSED : printPgmString(PSTR(" M1")); break;
|
||||
@ -237,7 +251,9 @@ void report_gcode_modes()
|
||||
switch (gc.coolant_mode) {
|
||||
case COOLANT_DISABLE : printPgmString(PSTR(" M9")); break;
|
||||
case COOLANT_FLOOD_ENABLE : printPgmString(PSTR(" M8")); break;
|
||||
// case COOLANT_MIST_ENABLE : printPgmString(PSTR(" M7")); break;
|
||||
#ifdef ENABLE_M7
|
||||
case COOLANT_MIST_ENABLE : printPgmString(PSTR(" M7")); break;
|
||||
#endif
|
||||
}
|
||||
|
||||
printPgmString(PSTR(" T"));
|
||||
@ -247,36 +263,37 @@ void report_gcode_modes()
|
||||
if (gc.inches_mode) { printFloat(gc.feed_rate*INCH_PER_MM); }
|
||||
else { printFloat(gc.feed_rate); }
|
||||
|
||||
if (sys.switches) {
|
||||
if (bit_istrue(sys.switches,BITFLAG_BLOCK_DELETE)) { printPgmString(PSTR(" $B")); }
|
||||
if (bit_istrue(sys.switches,BITFLAG_SINGLE_BLOCK)) { printPgmString(PSTR(" $S")); }
|
||||
if (bit_istrue(sys.switches,BITFLAG_OPT_STOP)) { printPgmString(PSTR(" $O")); }
|
||||
// Print active switches
|
||||
if (gc.switches) {
|
||||
if (bit_istrue(gc.switches,BITFLAG_CHECK_GCODE)) { printPgmString(PSTR(" $S0")); }
|
||||
if (bit_istrue(gc.switches,BITFLAG_DRY_RUN)) { printPgmString(PSTR(" $S1")); }
|
||||
if (bit_istrue(gc.switches,BITFLAG_BLOCK_DELETE)) { printPgmString(PSTR(" $S2")); }
|
||||
if (bit_istrue(gc.switches,BITFLAG_SINGLE_BLOCK)) { printPgmString(PSTR(" $S3")); }
|
||||
if (bit_istrue(gc.switches,BITFLAG_OPT_STOP)) { printPgmString(PSTR(" $S4")); }
|
||||
}
|
||||
|
||||
printPgmString(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
// Prints specified startup line
|
||||
void report_startup_line(uint8_t n, char *line)
|
||||
{
|
||||
printPgmString(PSTR("N")); printInteger(n);
|
||||
printPgmString(PSTR("=")); printString(line);
|
||||
printPgmString(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
// Prints real-time data. This function grabs a real-time snapshot of the stepper subprogram
|
||||
// and the actual location of the CNC machine. Users may change the following function to their
|
||||
// specific needs, but the desired real-time data report must be as short as possible. This is
|
||||
// requires as it minimizes the computational overhead and allows grbl to keep running smoothly,
|
||||
// especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz).
|
||||
void report_realtime_status()
|
||||
{
|
||||
// TODO: Status report data is written to the user here. This function should be able to grab a
|
||||
// real-time snapshot of the stepper subprogram and the actual location of the CNC machine. At a
|
||||
// minimum, status report should return real-time location information. Other important information
|
||||
// may be distance to go on block, processed block id, and feed rate. A secondary, non-critical
|
||||
// status report may include g-code state, i.e. inch mode, plane mode, absolute mode, etc.
|
||||
// The report generated must be as short as possible, yet still provide the user easily readable
|
||||
// information, i.e. '[0.23,120.4,2.4]'. This is necessary as it minimizes the computational
|
||||
// overhead and allows grbl to keep running smoothly, especially with g-code programs with fast,
|
||||
// short line segments and interface setups that require real-time status reports (5-20Hz).
|
||||
|
||||
// **Under construction** Bare-bones status report. Provides real-time machine position relative to
|
||||
// the system power on location (0,0,0) and work coordinate position (G54 and G92 applied).
|
||||
// The following are still needed: user setting of output units (mm|inch), compressed (non-human
|
||||
// readable) data for interfaces?, save last known position in EEPROM?, code optimizations, solidify
|
||||
// the reporting schemes, move to a separate .c file for easy user accessibility, and setting the
|
||||
// home position by the user (likely through '$' setting interface).
|
||||
// Successfully tested at a query rate of 10-20Hz while running a gauntlet of programs at various
|
||||
// speeds.
|
||||
// the system power on location (0,0,0) and work coordinate position (G54 and G92 applied). Eventually
|
||||
// to be added are distance to go on block, processed block id, and feed rate. Also a settings bitmask
|
||||
// for a user to select the desired real-time data.
|
||||
uint8_t i;
|
||||
int32_t current_position[3]; // Copy current state of the system position variable
|
||||
memcpy(current_position,sys.position,sizeof(sys.position));
|
||||
|
Reference in New Issue
Block a user