Bug fix for certain motions. Re-org of includes.
- Critical bug fix for diagonal motions that continue on the same direction or return in the exact opposite direction. This issue could cause Grbl to crash intermittently due to a numerical round-off error. Grbl versions prior to v0.9g shouldn’t have this issue. - Reorganized all of the includes used by Grbl. Centralized it into a single “grbl.h” include. This will help simplify the compiling and uploading process through the Arduino IDE. - Added an example .INO file for users to simply open and run when compiling and uploading through the IDE. More to come later.
This commit is contained in:
parent
23c1e154aa
commit
3b468f602b
1
config.h
1
config.h
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#ifndef config_h
|
#ifndef config_h
|
||||||
#define config_h
|
#define config_h
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
|
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "coolant_control.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "gcode.h"
|
|
||||||
|
|
||||||
|
|
||||||
void coolant_init()
|
void coolant_init()
|
||||||
|
22
examples/Grbl/Grbl.ino
Normal file
22
examples/Grbl/Grbl.ino
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <config.h>
|
||||||
|
#include <coolant_control.h>
|
||||||
|
#include <cpu_map.h>
|
||||||
|
#include <defaults.h>
|
||||||
|
#include <eeprom.h>
|
||||||
|
#include <gcode.h>
|
||||||
|
#include <grbl.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>
|
||||||
|
|
||||||
|
#include <src/main.h>
|
10
gcode.c
10
gcode.c
@ -24,15 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.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"
|
|
||||||
|
|
||||||
// NOTE: Max line number is defined by the g-code standard to be 99999. It seems to be an
|
// 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
|
// arbitrary value, and some GUIs may require more. So we increased it based on a max safe
|
||||||
|
28
grbl.h
28
grbl.h
@ -25,25 +25,41 @@
|
|||||||
#ifndef grbl_h
|
#ifndef grbl_h
|
||||||
#define 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 <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// Define the Grbl system include files.
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "coolant_control.h"
|
#include "nuts_bolts.h"
|
||||||
#include "cpu_map.h"
|
#include "settings.h"
|
||||||
|
#include "system.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
|
#include "cpu_map.h"
|
||||||
|
#include "coolant_control.h"
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "gcode.h"
|
#include "gcode.h"
|
||||||
#include "limits.h"
|
#include "limits.h"
|
||||||
#include "motion_control.h"
|
#include "motion_control.h"
|
||||||
#include "nuts_bolts.h"
|
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "probe.h"
|
#include "probe.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "spindle_control.h"
|
#include "spindle_control.h"
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
limits.c
10
limits.c
@ -24,14 +24,8 @@
|
|||||||
Copyright (c) 2012 Sungeun K. Jeon
|
Copyright (c) 2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "planner.h"
|
|
||||||
#include "stepper.h"
|
|
||||||
#include "motion_control.h"
|
|
||||||
#include "limits.h"
|
|
||||||
#include "report.h"
|
|
||||||
|
|
||||||
// Homing axis search distance multiplier. Computed by this value times the axis max travel.
|
// 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.
|
#define HOMING_AXIS_SEARCH_SCALAR 1.5 // Must be > 1 to ensure limit switch will be engaged.
|
||||||
|
14
main.c
14
main.c
@ -24,19 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.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"
|
|
||||||
|
|
||||||
|
|
||||||
// Declare system global variable structure
|
// Declare system global variable structure
|
||||||
|
@ -25,18 +25,7 @@
|
|||||||
Copyright (c) 2011 Jens Geisler
|
Copyright (c) 2011 Jens Geisler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.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"
|
|
||||||
|
|
||||||
|
|
||||||
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
|
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#ifndef motion_control_h
|
#ifndef motion_control_h
|
||||||
#define motion_control_h
|
#define motion_control_h
|
||||||
#include "gcode.h"
|
|
||||||
|
|
||||||
#define HOMING_CYCLE_LINE_NUMBER -1
|
#define HOMING_CYCLE_LINE_NUMBER -1
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "print.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float)
|
#define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float)
|
||||||
|
15
planner.c
15
planner.c
@ -25,12 +25,7 @@
|
|||||||
Copyright (c) 2011 Jens Geisler
|
Copyright (c) 2011 Jens Geisler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "planner.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "stepper.h"
|
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define SOME_LARGE_VALUE 1.0E+38 // Used by rapids and acceleration maximization calculations. Just needs
|
#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.
|
// 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.
|
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).
|
// 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.
|
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.
|
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
|
// 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.
|
// 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->max_junction_speed_sqr = max( MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED,
|
||||||
(block->acceleration * settings.junction_deviation * sin_theta_d2)/(1.0-sin_theta_d2) );
|
(block->acceleration * settings.junction_deviation * sin_theta_d2)/(1.0-sin_theta_d2) );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store block nominal speed
|
// Store block nominal speed
|
||||||
|
4
print.c
4
print.c
@ -24,9 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "serial.h"
|
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
|
|
||||||
void printString(const char *s)
|
void printString(const char *s)
|
||||||
|
5
probe.c
5
probe.c
@ -18,9 +18,8 @@
|
|||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "probe.h"
|
|
||||||
|
|
||||||
// Inverts the probe pin state depending on user settings and probing cycle mode.
|
// Inverts the probe pin state depending on user settings and probing cycle mode.
|
||||||
uint8_t probe_invert_mask;
|
uint8_t probe_invert_mask;
|
||||||
|
10
protocol.c
10
protocol.c
@ -24,15 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.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"
|
|
||||||
|
|
||||||
|
|
||||||
static char line[LINE_BUFFER_SIZE]; // Line to be executed. Zero-terminated.
|
static char line[LINE_BUFFER_SIZE]; // Line to be executed. Zero-terminated.
|
||||||
|
11
report.c
11
report.c
@ -26,16 +26,7 @@
|
|||||||
methods to accomodate their needs.
|
methods to accomodate their needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.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"
|
|
||||||
|
|
||||||
|
|
||||||
// Handles the primary confirmation protocol response for streaming interfaces and human-feedback.
|
// Handles the primary confirmation protocol response for streaming interfaces and human-feedback.
|
||||||
|
6
serial.c
6
serial.c
@ -24,11 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include "grbl.h"
|
||||||
#include "system.h"
|
|
||||||
#include "serial.h"
|
|
||||||
#include "motion_control.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t serial_rx_buffer[RX_BUFFER_SIZE];
|
uint8_t serial_rx_buffer[RX_BUFFER_SIZE];
|
||||||
|
@ -24,13 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "report.h"
|
|
||||||
#include "limits.h"
|
|
||||||
#include "stepper.h"
|
|
||||||
|
|
||||||
settings_t settings;
|
settings_t settings;
|
||||||
|
|
||||||
|
@ -27,9 +27,8 @@
|
|||||||
#ifndef settings_h
|
#ifndef settings_h
|
||||||
#define 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
|
// 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
|
// when firmware is upgraded. Always stored in byte 0 of eeprom
|
||||||
|
@ -24,10 +24,7 @@
|
|||||||
Copyright (c) 2012 Sungeun K. Jeon
|
Copyright (c) 2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "spindle_control.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "gcode.h"
|
|
||||||
|
|
||||||
|
|
||||||
void spindle_init()
|
void spindle_init()
|
||||||
|
@ -24,12 +24,7 @@
|
|||||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "nuts_bolts.h"
|
|
||||||
#include "stepper.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "planner.h"
|
|
||||||
#include "probe.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Some useful constants.
|
// Some useful constants.
|
||||||
|
9
system.c
9
system.c
@ -18,14 +18,7 @@
|
|||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "grbl.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "protocol.h"
|
|
||||||
#include "gcode.h"
|
|
||||||
#include "motion_control.h"
|
|
||||||
#include "stepper.h"
|
|
||||||
#include "report.h"
|
|
||||||
#include "print.h"
|
|
||||||
|
|
||||||
|
|
||||||
void system_init()
|
void system_init()
|
||||||
|
20
system.h
20
system.h
@ -21,25 +21,7 @@
|
|||||||
#ifndef system_h
|
#ifndef system_h
|
||||||
#define system_h
|
#define system_h
|
||||||
|
|
||||||
// Define system header files and standard libraries used by Grbl
|
#include "grbl.h"
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
// Define Grbl configuration and shared header files
|
|
||||||
#include "config.h"
|
|
||||||
#include "defaults.h"
|
|
||||||
#include "cpu_map.h"
|
|
||||||
#include "nuts_bolts.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Define system executor bit map. Used internally by realtime protocol as realtime command flags,
|
// 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.
|
// which notifies the main program to execute the specified realtime command asynchronously.
|
||||||
|
Loading…
Reference in New Issue
Block a user