diff --git a/config.h b/config.h index 601457e..0a0d886 100644 --- a/config.h +++ b/config.h @@ -32,7 +32,6 @@ #ifndef config_h #define config_h -#include "system.h" // Default settings. Used when resetting EEPROM. Change to desired name in defaults.h diff --git a/coolant_control.c b/coolant_control.c index d8336d5..f94f51a 100644 --- a/coolant_control.c +++ b/coolant_control.c @@ -18,10 +18,7 @@ along with Grbl. If not, see . */ -#include "system.h" -#include "coolant_control.h" -#include "protocol.h" -#include "gcode.h" +#include "grbl.h" void coolant_init() diff --git a/examples/Grbl/Grbl.ino b/examples/Grbl/Grbl.ino new file mode 100644 index 0000000..caf26fd --- /dev/null +++ b/examples/Grbl/Grbl.ino @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include diff --git a/gcode.c b/gcode.c index 69d58e0..ec5b44a 100644 --- a/gcode.c +++ b/gcode.c @@ -24,15 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "settings.h" -#include "protocol.h" -#include "gcode.h" -#include "motion_control.h" -#include "spindle_control.h" -#include "coolant_control.h" -#include "probe.h" -#include "report.h" +#include "grbl.h" // NOTE: Max line number is defined by the g-code standard to be 99999. It seems to be an // arbitrary value, and some GUIs may require more. So we increased it based on a max safe diff --git a/grbl.h b/grbl.h index 913e4f5..6295e7c 100644 --- a/grbl.h +++ b/grbl.h @@ -25,25 +25,41 @@ #ifndef grbl_h #define grbl_h -// All of the Grbl system include files. +#define GRBL_VERSION "0.9h" +#define GRBL_VERSION_BUILD "20150210" + +// Define standard libraries used by Grbl. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Define the Grbl system include files. #include "config.h" -#include "coolant_control.h" -#include "cpu_map.h" +#include "nuts_bolts.h" +#include "settings.h" +#include "system.h" #include "defaults.h" +#include "cpu_map.h" +#include "coolant_control.h" #include "eeprom.h" #include "gcode.h" #include "limits.h" #include "motion_control.h" -#include "nuts_bolts.h" #include "planner.h" #include "print.h" #include "probe.h" #include "protocol.h" #include "report.h" #include "serial.h" -#include "settings.h" #include "spindle_control.h" #include "stepper.h" -#include "system.h" #endif diff --git a/limits.c b/limits.c index 0a5e391..a8a2583 100644 --- a/limits.c +++ b/limits.c @@ -24,14 +24,8 @@ Copyright (c) 2012 Sungeun K. Jeon */ -#include "system.h" -#include "settings.h" -#include "protocol.h" -#include "planner.h" -#include "stepper.h" -#include "motion_control.h" -#include "limits.h" -#include "report.h" +#include "grbl.h" + // Homing axis search distance multiplier. Computed by this value times the axis max travel. #define HOMING_AXIS_SEARCH_SCALAR 1.5 // Must be > 1 to ensure limit switch will be engaged. diff --git a/main.c b/main.c index bdda1e7..f3557c5 100644 --- a/main.c +++ b/main.c @@ -24,19 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "serial.h" -#include "settings.h" -#include "protocol.h" -#include "gcode.h" -#include "planner.h" -#include "stepper.h" -#include "spindle_control.h" -#include "coolant_control.h" -#include "motion_control.h" -#include "limits.h" -#include "probe.h" -#include "report.h" +#include "grbl.h" // Declare system global variable structure diff --git a/motion_control.c b/motion_control.c index 1cd9d05..4a0fdb9 100644 --- a/motion_control.c +++ b/motion_control.c @@ -25,18 +25,7 @@ Copyright (c) 2011 Jens Geisler */ -#include "system.h" -#include "settings.h" -#include "protocol.h" -#include "gcode.h" -#include "planner.h" -#include "stepper.h" -#include "motion_control.h" -#include "spindle_control.h" -#include "coolant_control.h" -#include "limits.h" -#include "probe.h" -#include "report.h" +#include "grbl.h" // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second diff --git a/motion_control.h b/motion_control.h index 285a928..1cd1b2e 100644 --- a/motion_control.h +++ b/motion_control.h @@ -26,7 +26,7 @@ #ifndef motion_control_h #define motion_control_h -#include "gcode.h" + #define HOMING_CYCLE_LINE_NUMBER -1 diff --git a/nuts_bolts.c b/nuts_bolts.c index d620a62..7da9d7e 100644 --- a/nuts_bolts.c +++ b/nuts_bolts.c @@ -24,8 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "print.h" +#include "grbl.h" #define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float) diff --git a/planner.c b/planner.c index 44ab051..0946ce1 100644 --- a/planner.c +++ b/planner.c @@ -25,12 +25,7 @@ Copyright (c) 2011 Jens Geisler */ -#include "system.h" -#include "planner.h" -#include "protocol.h" -#include "stepper.h" -#include "settings.h" - +#include "grbl.h" #define SOME_LARGE_VALUE 1.0E+38 // Used by rapids and acceleration maximization calculations. Just needs // to be larger than any feasible (mm/min)^2 or mm/sec^2 value. @@ -388,13 +383,19 @@ uint8_t plan_check_full_buffer() change the overall maximum entry speed conditions of all blocks. */ // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). - junction_cos_theta = min(junction_cos_theta, 1.0); // Check for numerical round-off. - float sin_theta_d2 = sqrt(0.5*(1.0-junction_cos_theta)); // Trig half angle identity. Always positive. + if (junction_cos_theta > 0.99) { + // For a 0 degree acute junction, just set minimum junction speed. + block->max_junction_speed_sqr = MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED; + } else { + junction_cos_theta = max(junction_cos_theta,-0.99); // Check for numerical round-off to avoid divide by zero. + float sin_theta_d2 = sqrt(0.5*(1.0-junction_cos_theta)); // Trig half angle identity. Always positive. - // TODO: Technically, the acceleration used in calculation needs to be limited by the minimum of the - // two junctions. However, this shouldn't be a significant problem except in extreme circumstances. - block->max_junction_speed_sqr = max( MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED, - (block->acceleration * settings.junction_deviation * sin_theta_d2)/(1.0-sin_theta_d2) ); + // TODO: Technically, the acceleration used in calculation needs to be limited by the minimum of the + // two junctions. However, this shouldn't be a significant problem except in extreme circumstances. + block->max_junction_speed_sqr = max( MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED, + (block->acceleration * settings.junction_deviation * sin_theta_d2)/(1.0-sin_theta_d2) ); + + } } // Store block nominal speed diff --git a/print.c b/print.c index 65fb975..781cedc 100644 --- a/print.c +++ b/print.c @@ -24,9 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "serial.h" -#include "settings.h" +#include "grbl.h" void printString(const char *s) diff --git a/probe.c b/probe.c index 5d0224f..74121e8 100644 --- a/probe.c +++ b/probe.c @@ -18,9 +18,8 @@ along with Grbl. If not, see . */ -#include "system.h" -#include "settings.h" -#include "probe.h" +#include "grbl.h" + // Inverts the probe pin state depending on user settings and probing cycle mode. uint8_t probe_invert_mask; diff --git a/protocol.c b/protocol.c index 1c2651a..239bb16 100644 --- a/protocol.c +++ b/protocol.c @@ -24,15 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "serial.h" -#include "settings.h" -#include "protocol.h" -#include "gcode.h" -#include "planner.h" -#include "stepper.h" -#include "motion_control.h" -#include "report.h" +#include "grbl.h" static char line[LINE_BUFFER_SIZE]; // Line to be executed. Zero-terminated. diff --git a/report.c b/report.c index 6e0d2da..c611452 100644 --- a/report.c +++ b/report.c @@ -26,16 +26,7 @@ methods to accomodate their needs. */ -#include "system.h" -#include "report.h" -#include "print.h" -#include "settings.h" -#include "gcode.h" -#include "coolant_control.h" -#include "planner.h" -#include "spindle_control.h" -#include "stepper.h" -#include "serial.h" +#include "grbl.h" // Handles the primary confirmation protocol response for streaming interfaces and human-feedback. diff --git a/serial.c b/serial.c index 7b2339c..e4a63d2 100644 --- a/serial.c +++ b/serial.c @@ -24,11 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include -#include "system.h" -#include "serial.h" -#include "motion_control.h" -#include "protocol.h" +#include "grbl.h" uint8_t serial_rx_buffer[RX_BUFFER_SIZE]; diff --git a/settings.c b/settings.c index a81e0e8..d018fef 100644 --- a/settings.c +++ b/settings.c @@ -24,13 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "settings.h" -#include "eeprom.h" -#include "protocol.h" -#include "report.h" -#include "limits.h" -#include "stepper.h" +#include "grbl.h" settings_t settings; diff --git a/settings.h b/settings.h index df70906..a86c0e9 100644 --- a/settings.h +++ b/settings.h @@ -27,9 +27,8 @@ #ifndef settings_h #define settings_h +#include "grbl.h" -#define GRBL_VERSION "0.9h" -#define GRBL_VERSION_BUILD "20150204" // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl // when firmware is upgraded. Always stored in byte 0 of eeprom diff --git a/spindle_control.c b/spindle_control.c index b928ada..abad6c2 100644 --- a/spindle_control.c +++ b/spindle_control.c @@ -24,10 +24,7 @@ Copyright (c) 2012 Sungeun K. Jeon */ -#include "system.h" -#include "spindle_control.h" -#include "protocol.h" -#include "gcode.h" +#include "grbl.h" void spindle_init() diff --git a/stepper.c b/stepper.c index fbc0426..cd71aa0 100644 --- a/stepper.c +++ b/stepper.c @@ -24,12 +24,7 @@ Copyright (c) 2011-2012 Sungeun K. Jeon */ -#include "system.h" -#include "nuts_bolts.h" -#include "stepper.h" -#include "settings.h" -#include "planner.h" -#include "probe.h" +#include "grbl.h" // Some useful constants. diff --git a/system.c b/system.c index 12838ae..bec36d6 100644 --- a/system.c +++ b/system.c @@ -18,14 +18,7 @@ along with Grbl. If not, see . */ -#include "system.h" -#include "settings.h" -#include "protocol.h" -#include "gcode.h" -#include "motion_control.h" -#include "stepper.h" -#include "report.h" -#include "print.h" +#include "grbl.h" void system_init() diff --git a/system.h b/system.h index 94139be..2c2a89d 100644 --- a/system.h +++ b/system.h @@ -21,25 +21,7 @@ #ifndef system_h #define system_h -// Define system header files and standard libraries used by Grbl -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Define Grbl configuration and shared header files -#include "config.h" -#include "defaults.h" -#include "cpu_map.h" -#include "nuts_bolts.h" - +#include "grbl.h" // Define system executor bit map. Used internally by realtime protocol as realtime command flags, // which notifies the main program to execute the specified realtime command asynchronously.